File

plugins/ping.lua @ 37:0ccd523e110a

verse.client: Don't hook the stanza event every time a stanza comes in :)
author Matthew Wild <mwild1@gmail.com>
date Mon, 21 Dec 2009 14:25:44 +0000
parent 36:fc2cd2f36cdd
child 41:1a1bd8cd4bdb
line wrap: on
line source


local xmlns_ping = "urn:xmpp:ping";

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
	return true;
end