diff -r 48be1ae93fd4 -r 122ab6208c3c stream.go --- a/stream.go Tue Dec 27 15:36:07 2011 -0700 +++ b/stream.go Tue Dec 27 20:42:44 2011 -0700 @@ -114,6 +114,8 @@ case nsSASL + " challenge", nsSASL + " failure", nsSASL + " success": obj = &auth{} + case "jabber:client iq": + obj = &Iq{} default: obj = &Unrecognized{} log.Printf("Ignoring unrecognized: %s %s\n", @@ -208,6 +210,10 @@ cl.chooseSasl(fe) return } + + if fe.Bind != nil { + cl.bind(fe.Bind) + } } // readTransport() is running concurrently. We need to stop it, @@ -436,3 +442,16 @@ hex(h(a2)))) return response } + +func (cl *Client) bind(bind *Unrecognized) { + res := cl.Jid.Resource + msg := &Iq{Type: "set", Id: cl.NextId(), Any: + &Unrecognized{XMLName: xml.Name{Space: nsBind, Local: + "bind"}}} + if res != "" { + msg.Any.Any = &Unrecognized{XMLName: xml.Name{Local: + "resource"}, Chardata: res} + } + cl.xmlOut <- msg + // TODO Grab the iq result from the server and update cl.Jid. +}