# HG changeset patch # User Matthew Wild # Date 1265230880 0 # Node ID ec839631a35fce193d737da5514f6d96b9c1a815 # Parent 20a58dcf2323364093cf243cad4435f34f69b16b Add addHandler() method diff -r 20a58dcf2323 -r ec839631a35f xmpp.js --- 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):"");