comparison lightstring.js @ 42:ee874d064650

Check iq sending.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 31 Jan 2012 17:40:06 +0100
parents 2895891f19bb
children 136df1708856
comparison
equal deleted inserted replaced
41:2895891f19bb 42:ee874d064650
332 332
333 if(!stanza) 333 if(!stanza)
334 return; 334 return;
335 335
336 if (stanza.DOM.tagName === 'iq') { 336 if (stanza.DOM.tagName === 'iq') {
337 var id = stanza.DOM.getAttribute('id'); 337 var type = stanza.DOM.getAttributeNS(null, 'type');
338 //TODO: This should be done by a plugin 338 if (type !== 'get' || type !== 'set')
339 if (!id) 339 ; //TODO: emit an error.
340 stanza.DOM.setAttribute('id', Lightstring.newId('sendiq:')); 340
341 if (aCallback) 341 var id = stanza.DOM.getAttributeNS(null, 'id');
342 this.on(stanza.DOM.getAttribute('id'), aCallback); 342 if (!id) {
343 } 343 if (aCallback)
344 else if (aCallback) { 344 ; //TODO: emit an error.
345 this.emit('warning', 'Callback can\'t be called with non-iq stanza.'); 345 else
346 } 346 ; //TODO: emit an warning.
347 } else if (aCallback)
348 this.on(id, aCallback);
349 }
350 else if (aCallback)
351 ; //TODO: callback can’t be called with non-iq stanza.
347 352
348 353
349 //TODO this.socket.send(stanza.XML); (need some work on Lightstring.Stanza) 354 //TODO this.socket.send(stanza.XML); (need some work on Lightstring.Stanza)
350 var fixme = Lightstring.DOM2XML(stanza.DOM); 355 var fixme = Lightstring.DOM2XML(stanza.DOM);
351 stanza.XML = fixme; 356 stanza.XML = fixme;