Mercurial > eldonilo > lightstring
comparison lightstring.js @ 65:2e8fbf3bce7f
ANONYMOUS auth plugin.
author | Sonny Piers <sonny.piers@gmail.com> |
---|---|
date | Wed, 01 Feb 2012 21:23:28 +0100 |
parents | d9f5ae0b6d98 |
children | 1c8f326fe3ef |
comparison
equal
deleted
inserted
replaced
64:d9f5ae0b6d98 | 65:2e8fbf3bce7f |
---|---|
139 if (aPassword) | 139 if (aPassword) |
140 this.password = aPassword; | 140 this.password = aPassword; |
141 | 141 |
142 if (!this.jid.bare) | 142 if (!this.jid.bare) |
143 throw 'Lightstring: Connection.jid is undefined.'; | 143 throw 'Lightstring: Connection.jid is undefined.'; |
144 if (!this.password) | |
145 throw 'Lightstring: Connection.password is undefined.'; | |
146 if (!this.service) | 144 if (!this.service) |
147 throw 'Lightstring: Connection.service is undefined.'; | 145 throw 'Lightstring: Connection.service is undefined.'; |
148 | 146 |
149 if(typeof(WebSocket) === "function") { | 147 if(typeof(WebSocket) === "function") { |
150 this.socket = new WebSocket(this.service, 'xmpp'); | 148 this.socket = new WebSocket(this.service, 'xmpp'); |
184 if(!stanza.DOM) | 182 if(!stanza.DOM) |
185 return; | 183 return; |
186 | 184 |
187 | 185 |
188 var name = stanza.DOM.localName; | 186 var name = stanza.DOM.localName; |
187 //FIXME SASL mechanisms and XMPP features can be both in a stream:features | |
189 if (name === 'features') { | 188 if (name === 'features') { |
190 //SASL mechanisms | 189 //SASL mechanisms |
191 if (stanza.DOM.firstChild.localName === 'mechanisms') { | 190 if (stanza.DOM.firstChild.localName === 'mechanisms') { |
192 stanza.mechanisms = []; | 191 stanza.mechanisms = []; |
193 var nodes = stanza.DOM.querySelectorAll('mechanism'); | 192 var nodes = stanza.DOM.querySelectorAll('mechanism'); |
194 for (var i = 0; i < nodes.length; i++) | 193 for (var i = 0; i < nodes.length; i++) |
195 stanza.mechanisms.push(nodes[i].textContent); | 194 stanza.mechanisms.push(nodes[i].textContent); |
196 that.emit('mechanisms', stanza); | 195 that.emit('mechanisms', stanza); |
197 } | 196 } |
198 //XMPP features | 197 //XMPP features |
199 else if (stanza.DOM.firstChild.localName === 'c') { | 198 else { |
200 //TODO: stanza.features | 199 //TODO: stanza.features |
201 that.emit('features', stanza); | 200 that.emit('features', stanza); |
202 } | 201 } |
203 } | 202 } |
204 else if (name === 'challenge') { | 203 else if (name === 'challenge') { |