Add addHandler() method

Wed, 03 Feb 2010 21:01:20 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 03 Feb 2010 21:01:20 +0000
changeset 6
ec839631a35f
parent 5
20a58dcf2323
child 7
394b0c8cad04

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):"");

mercurial