comparison lightstring.js @ 71:f12c759e4097

Fix service-unavailable handler and errors stanzas.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 02 Feb 2012 01:59:42 +0100
parents e1ccfb580228
children 5dbf93cef55d
comparison
equal deleted inserted replaced
70:fdd1ae375067 71:f12c759e4097
41 close: function() { 41 close: function() {
42 return "</stream:stream>"; 42 return "</stream:stream>";
43 } 43 }
44 }, 44 },
45 errors: { 45 errors: {
46 iq: function(type, error) { 46 iq: function(from, id, type, error) {
47 return "<iq to='" + stanza.DOM.getAttributeNS(null, 'from') + "'" + 47 return "<iq to='" + from + "'" +
48 " id='" + stanza.DOM.getAttributeNS(null, 'id') + "'" + 48 " id='" + id + "'" +
49 " type='error'>" + 49 " type='error'>" +
50 "<error type='" + type + "'>" + 50 "<error type='" + type + "'>" +
51 "<" + error + " xmlns='" + Lightstring.namespaces['xmpp_stanzas'] + "'/>" + //TODO: allow text content. 51 "<" + error + " xmlns='" + Lightstring.ns['xmpp_stanzas'] + "'/>" + //TODO: allow text content.
52 //TODO: allow text and payload. 52 //TODO: allow text and payload.
53 "</error>" + 53 "</error>" +
54 "</iq>"; 54 "</iq>";
55 } 55 }
56 } 56 }
344 344
345 if (ret) 345 if (ret)
346 return; 346 return;
347 } 347 }
348 348
349 conn.send(Lightstring.stanzas.errors.iq('cancel', 'service-unavailable')); 349 if (aData && aData.DOM) {
350 var from = aData.DOM.getAttributeNS(null, 'from');
351 var id = aData.DOM.getAttributeNS(null, 'id');
352 this.send(Lightstring.stanzas.errors.iq(from, id, 'cancel', 'service-unavailable'));
353 }
350 }, 354 },
351 /** 355 /**
352 * @function Register an event handler. 356 * @function Register an event handler.
353 * @param {String} aName The event name. 357 * @param {String} aName The event name.
354 * @param {Function} aCallback The callback to call when the event is emitted. 358 * @param {Function} aCallback The callback to call when the event is emitted.