private void BindResult(object sender, IQ iq, object data) { // Once the server has generated a resource identifier for the client or accepted the resource // identifier provided by the client, it MUST return an IQ stanza of type "result" // to the client, which MUST include a <jid/> child element that specifies the full JID for // the connected resource as determined by the server: // Server informs client of successful resource binding: // <iq type='result' id='bind_2'> // <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'> // <jid>[email protected]/someresource</jid> // </bind> // </iq> if (iq.Type == IqType.result) { // i assume the server could assign another resource here to the client // so grep the resource assigned by the server now var bind = iq.SelectSingleElement(typeof(Bind)); if (bind != null) { var jid = ((Bind)bind).Jid; m_XmppClient.Resource = jid.Resource; m_XmppClient.Username = jid.User; } m_XmppClient.DoChangeXmppConnectionState(XmppConnectionState.Binded); m_XmppClient.m_Binded = true; m_XmppClient.DoRaiseEventBinded(); // success, so start the session now m_XmppClient.DoChangeXmppConnectionState(XmppConnectionState.StartSession); var sIq = new SessionIq(IqType.set, new Jid(m_XmppClient.Server)); m_XmppClient.IqGrabber.SendIq(sIq, SessionResult, null); } else if (iq.Type == IqType.error) { // TODO, handle bind errors m_XmppClient.DoRaiseEventBindError(iq); } }