Changeset

32:391048601d54

plugins.ping: Add ping plugin to XMPP ping a JID
author Matthew Wild <mwild1@gmail.com>
date Sun, 20 Dec 2009 21:33:55 +0000
parents 31:f1e9d1d7cf5d
children 33:4581b2e61429
files plugins/ping.lua
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/ping.lua	Sun Dec 20 21:33:55 2009 +0000
@@ -0,0 +1,10 @@
+
+function verse.plugins.ping(stream)
+	function stream:ping(jid, callback)
+		local t = socket.gettime();
+		stream:send_iq(verse.iq{ to = jid, type = "get" }:tag("ping", { xmlns = xmlns_ping }), 
+			function (reply)
+				callback(socket.gettime()-t, jid);
+			end);
+	end
+end