Software /
code /
clix
Changeset
102:16cdeb9cd879
Add clix module to send XMPP pings to JIDs
Signed-off-by: Georg Lukas <georg@op-co.de>
author | "Georg Lukas <georg@op-co.de>" |
---|---|
date | Sun, 10 Feb 2013 14:09:20 +0100 |
parents | 98:5ad042476235 |
children | 103:82c21f1d6f46 |
files | clix/ping.lua squishy |
diffstat | 2 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clix/ping.lua Sun Feb 10 14:09:20 2013 +0100 @@ -0,0 +1,24 @@ +return function (opts, arg) + if opts.short_help then + print("Measure the round-trip latency time of a given JID"); + return; + end + if #arg == 0 or opts.help then + return 0; + end + local conn; + local function on_reply(time, jid, reply) + if time then + print(string.format("%s latency: %1.3fs", jid, time)); + else + print("Error requesting ping ("..(reply.condition or "unknown")..")"..(reply.text and (": "..reply.text) or "")); + end + conn:close(); + end + local function on_connect(_conn) + conn = _conn; + conn:add_plugin("ping"); + conn:ping(arg[1], on_reply); + end + clix_connect(opts, on_connect); +end