Added the ability to parse <stream:features>.
--- a/structs.go Sun Dec 25 19:02:53 2011 -0700
+++ b/structs.go Mon Dec 26 11:48:35 2011 -0700
@@ -66,9 +66,23 @@
}
var _ xml.Marshaler = &errText{}
+type Features struct {
+ Starttls starttls
+ Mechanisms mechs
+}
+
+type starttls struct {
+ required *string
+}
+
+type mechs struct {
+ Mechanism []string
+}
+
type Unrecognized struct {
XMLName xml.Name
}
+var _ fmt.Stringer = &Unrecognized{}
func (jid *JID) String() string {
result := jid.Domain
@@ -171,3 +185,8 @@
io.WriteString(w, `"`)
}
}
+
+func (u *Unrecognized) String() string {
+ return fmt.Sprintf("unrecognized{%s %s}", u.XMLName.Space,
+ u.XMLName.Local)
+}
--- a/xmpp.go Sun Dec 25 19:02:53 2011 -0700
+++ b/xmpp.go Mon Dec 26 11:48:35 2011 -0700
@@ -73,6 +73,10 @@
go readXml(cl.tcp, cl.in, debug)
go writeXml(cl.tcp, cl.out, debug)
+ // Initial handshake.
+ hsOut := &Stream{To: jid.Domain, Version: Version}
+ cl.Out <- hsOut
+
return cl, nil
}
@@ -125,8 +129,12 @@
continue
case "stream error":
obj = &StreamError{}
+ case nsStream + " features":
+ obj = &Features{}
default:
obj = &Unrecognized{}
+ log.Printf("Ignoring unrecognized: %s %s\n",
+ se.Name.Space, se.Name.Local)
}
// Read the complete XML stanza.