Mercurial > eldonilo > lightstring
changeset 24:119ceb121908
Bind the correct JID received.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 26 Jan 2012 22:17:11 +0100 |
parents | 99bf2bdcfd96 |
children | 06e3a883d3a3 |
files | lightstring.js |
diffstat | 1 files changed, 20 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/lightstring.js +++ b/lightstring.js @@ -119,21 +119,27 @@ Lightstring.Connection = function(aServi else { that.emit('features', stanza); //Bind http://xmpp.org/rfcs/rfc3920.html#bind - that.send( + var bind = "<iq type='set' xmlns='jabber:client'>" + - "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>" + - "</iq>", - function() { - //Session http://xmpp.org/rfcs/rfc3921.html#session - that.send( - "<iq type='set' xmlns='jabber:client'>" + - "<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>" + - "</iq>", - function() { - that.emit('connected'); - } - ); - }); + "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>" + + (that.jid.resource? "<resource>" + that.jid.resource + "</resource>": "") + + "</bind>" + + "</iq>"; + that.send( + bind, + function(stanza) { + //Session http://xmpp.org/rfcs/rfc3921.html#session + that.jid = new Lightstring.JID(stanza.textContent); + that.send( + "<iq type='set' xmlns='jabber:client'>" + + "<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>" + + "</iq>", + function() { + that.emit('connected'); + } + ); + } + ); } }); this.on('success', function(stanza, that) {