# HG changeset patch # User Chris Jones # Date 1327033946 21600 # Node ID a74e7fc4ecee88a3efeff4cda7c8d68d73f7fd82 # Parent b0aa1bf902ee25358db1efc26415bece5100b3ea Consolidate how we generate the "open stream" XML. diff -r b0aa1bf902ee -r a74e7fc4ecee stream.go --- a/stream.go Thu Jan 19 22:31:56 2012 -0600 +++ b/stream.go Thu Jan 19 22:32:26 2012 -0600 @@ -33,6 +33,16 @@ f func(Stanza) bool } +// BUG(cjyar): There's no way to specify xml:lang for the top-level +// element as the default language for this client. + +// Generate the "open stream" element which tells the remote we want +// to speak XMPP. This is actually done 3 times, since we renegotiate +// our transport layer with TLS and then with SASL. +func openStream(jid *JID) *stream { + return &stream{To: jid.Domain, Version: Version} +} + // BUG(cjyar) Review all these *Client receiver methods. They should // probably either all be receivers, or none. @@ -420,7 +430,7 @@ // Now re-send the initial handshake message to start the new // session. - hsOut := &stream{To: cl.Jid.Domain, Version: Version} + hsOut := openStream() cl.xmlOut <- hsOut } @@ -483,8 +493,7 @@ Log.Println("Sasl authentication succeeded") } cl.Features = nil - ss := &stream{To: cl.Jid.Domain, Version: Version} - cl.xmlOut <- ss + cl.xmlOut <- openStream(cl.Jid) } } diff -r b0aa1bf902ee -r a74e7fc4ecee xmpp.go --- a/xmpp.go Thu Jan 19 22:31:56 2012 -0600 +++ b/xmpp.go Thu Jan 19 22:32:26 2012 -0600 @@ -182,8 +182,7 @@ } // Initial handshake. - hsOut := &stream{To: jid.Domain, Version: Version} - cl.xmlOut <- hsOut + cl.xmlOut <- openStream(jid) return cl, nil }