Annotate

plugins/ping.lua @ 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
child 34:dd5899412e3f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 function verse.plugins.ping(stream)
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 function stream:ping(jid, callback)
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local t = socket.gettime();
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 stream:send_iq(verse.iq{ to = jid, type = "get" }:tag("ping", { xmlns = xmlns_ping }),
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 function (reply)
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 callback(socket.gettime()-t, jid);
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 end);
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 end
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 end