Mercurial > eldonilo > lightstring
changeset 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 | fdd1ae375067 |
children | 5dbf93cef55d |
files | lightstring.js |
diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/lightstring.js +++ b/lightstring.js @@ -43,12 +43,12 @@ var Lightstring = { } }, errors: { - iq: function(type, error) { - return "<iq to='" + stanza.DOM.getAttributeNS(null, 'from') + "'" + - " id='" + stanza.DOM.getAttributeNS(null, 'id') + "'" + + iq: function(from, id, type, error) { + return "<iq to='" + from + "'" + + " id='" + id + "'" + " type='error'>" + "<error type='" + type + "'>" + - "<" + error + " xmlns='" + Lightstring.namespaces['xmpp_stanzas'] + "'/>" + //TODO: allow text content. + "<" + error + " xmlns='" + Lightstring.ns['xmpp_stanzas'] + "'/>" + //TODO: allow text content. //TODO: allow text and payload. "</error>" + "</iq>"; @@ -346,7 +346,11 @@ Lightstring.Connection.prototype = { return; } - conn.send(Lightstring.stanzas.errors.iq('cancel', 'service-unavailable')); + if (aData && aData.DOM) { + var from = aData.DOM.getAttributeNS(null, 'from'); + var id = aData.DOM.getAttributeNS(null, 'id'); + this.send(Lightstring.stanzas.errors.iq(from, id, 'cancel', 'service-unavailable')); + } }, /** * @function Register an event handler.