Wed, 03 Feb 2010 21:01:20 +0000
Add addHandler() method
xmpp.js | file | annotate | diff | comparison | revisions |
--- a/xmpp.js Wed Feb 03 21:00:04 2010 +0000 +++ b/xmpp.js Wed Feb 03 21:01:20 2010 +0000 @@ -135,6 +135,8 @@ this.socket.addListener("disconnect", recontext(this, conn._socket_disconnected)); this.socket.addListener("receive", recontext(this, conn._socket_received)); + this.handlers = []; + // Connect TCP socket this.socket.connect(this.port, this.host); @@ -148,6 +150,18 @@ }, + addHandler: function (handler, ns, name, type, id, from, options) + { + return this.handlers.push({ + callback: handler, + xmlns: ns, + name: name, + type: type, + id: id, + from: from, + matchBare: options && options.matchBare}); + }, + getUniqueId: function (suffix) { return ++this._uniqueId + (suffix?(":"+suffix):"");