# HG changeset patch # User Chris Jones # Date 1325183126 25200 # Node ID 4e68d8f89dc3c0091a52c961bc829bf76aa49725 # Parent 1dc47df5c99fe1b1143579974c79261570eb01f0 Make the server's advertised features available to the app. diff -r 1dc47df5c99f -r 4e68d8f89dc3 stream.go --- a/stream.go Thu Dec 29 11:17:52 2011 -0700 +++ b/stream.go Thu Dec 29 11:25:26 2011 -0700 @@ -253,6 +253,7 @@ } func (cl *Client) handleFeatures(fe *Features) { + cl.Features = fe if fe.Starttls != nil { start := &starttls{XMLName: xml.Name{Space: nsTLS, Local: "starttls"}} @@ -297,6 +298,7 @@ tcp.SetReadTimeout(0) log.Println("TLS negotiation succeeded.") + cl.Features = nil // Now re-send the initial handshake message to start the new // session. @@ -357,6 +359,7 @@ log.Println("SASL authentication failed") case "success": log.Println("SASL authentication succeeded") + cl.Features = nil ss := &stream{To: cl.Jid.Domain, Version: Version} cl.xmlOut <- ss } diff -r 1dc47df5c99f -r 4e68d8f89dc3 structs.go --- a/structs.go Thu Dec 29 11:17:52 2011 -0700 +++ b/structs.go Thu Dec 29 11:25:26 2011 -0700 @@ -52,11 +52,12 @@ } var _ xml.Marshaler = &errText{} -// BUG(cjyar) Store this in Client and make it available to the app. type Features struct { Starttls *starttls Mechanisms mechs Bind *Generic + Session *Generic + Any *Generic } type starttls struct { diff -r 1dc47df5c99f -r 4e68d8f89dc3 xmpp.go --- a/xmpp.go Thu Dec 29 11:17:52 2011 -0700 +++ b/xmpp.go Thu Dec 29 11:25:26 2011 -0700 @@ -68,6 +68,11 @@ // channel. Out chan<- Stanza xmlOut chan<- interface{} + // Features advertised by the remote. This will be updated + // asynchronously as new features are received throughout the + // connection process. It should not be updated once + // StartSession() returns. + Features *Features } var _ io.Closer = &Client{}