Annotate

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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
fc2cd2f36cdd plugins.ping: Define xmlns_ping namespace
Matthew Wild <mwild1@gmail.com>
parents: 34
diff changeset
1
fc2cd2f36cdd plugins.ping: Define xmlns_ping namespace
Matthew Wild <mwild1@gmail.com>
parents: 34
diff changeset
2 local xmlns_ping = "urn:xmpp:ping";
32
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 function verse.plugins.ping(stream)
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 function stream:ping(jid, callback)
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 local t = socket.gettime();
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 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
8 function (reply)
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 callback(socket.gettime()-t, jid);
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 end);
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 end
34
dd5899412e3f plugins.ping: Return true on module load to indicate load success
Matthew Wild <mwild1@gmail.com>
parents: 32
diff changeset
12 return true;
32
391048601d54 plugins.ping: Add ping plugin to XMPP ping a JID
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 end