Add sendIQ() method

Wed, 03 Feb 2010 21:02:33 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 03 Feb 2010 21:02:33 +0000
changeset 8
ca881dab2577
parent 7
394b0c8cad04
child 9
c4ff2c2fea6d

Add sendIQ() method

xmpp.js file | annotate | diff | comparison | revisions
--- a/xmpp.js	Wed Feb 03 21:02:21 2010 +0000
+++ b/xmpp.js	Wed Feb 03 21:02:33 2010 +0000
@@ -149,6 +149,20 @@
 		this.socket.send(data.toString());
 	},
 	
+	sendIQ: function (iq, on_result, on_error)
+	{
+		if(!iq.attr.id)
+			iq.attr.id = this.getUniqueId();
+		this.addHandler(function (reply) {
+			if(reply.attr.type == "result")
+				return on_result(reply);
+			elseif(on_error)
+				return on_error(reply);
+			return false;
+			
+		}, null, "iq", null, iq.attr.id);
+		this.send(iq);
+	},
 	
 	addHandler: function (handler, ns, name, type, id, from, options)
 	{

mercurial