# HG changeset patch # User Chris Jones # Date 1325098531 25200 # Node ID aa2cf77f0ed3dbea4f60f34f0da1732a3e69e56c # Parent fd6781a41e6f9797596e01753264523a87feeaf5 When the server sends us our newly bound resource, update Client.Jid and allow the to pass through to the app so they know it's changed. diff -r fd6781a41e6f -r aa2cf77f0ed3 stream.go --- a/stream.go Wed Dec 28 11:35:21 2011 -0700 +++ b/stream.go Wed Dec 28 11:55:31 2011 -0700 @@ -475,6 +475,36 @@ msg.Any.Any = &Unrecognized{XMLName: xml.Name{Local: "resource"}, Chardata: res} } + f := func(st Stanza) bool { + if st.XType() == "error" { + log.Println("Resource binding failed") + return false + } + bind := st.XChild() + if bind == nil { + log.Println("nil resource bind") + return false + } + jidEle := bind.Any + if jidEle == nil { + log.Println("nil resource") + return false + } + jidStr := jidEle.Chardata + if jidStr == "" { + log.Println("empty resource") + return false + } + jid := new(JID) + if !jid.Set(jidStr) { + log.Println("Can't parse JID %s", jidStr) + return false + } + cl.Jid = *jid + log.Printf("Bound resource: %s", cl.Jid.String()) + return true + } + cl.HandleStanza(msg.Id, f) cl.xmlOut <- msg } diff -r fd6781a41e6f -r aa2cf77f0ed3 xmpp.go --- a/xmpp.go Wed Dec 28 11:35:21 2011 -0700 +++ b/xmpp.go Wed Dec 28 11:55:31 2011 -0700 @@ -85,7 +85,7 @@ cl.password = password cl.Jid = *jid cl.socket = tcp - cl.handlers = make(chan *stanzaHandler) + cl.handlers = make(chan *stanzaHandler, 1) // Start the transport handler, initially unencrypted. tlsr, tlsw := cl.startTransport()