Fri, 24 Aug 2018 23:29:32 +0200
clix.publish_atom: Fix prefix for activitystreams
Since when does it turn '-' into '_' ?
104
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
1 | return function (opts, arg) |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
2 | if opts.short_help then |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
3 | print("Measure the round-trip latency time of a given JID"); |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
4 | return; |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
5 | end |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
6 | if #arg == 0 or opts.help then |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
7 | return 0; |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
8 | end |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
9 | local conn; |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
10 | local function on_reply(time, jid, reply) |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
11 | if time then |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
12 | print(string.format("%s latency: %1.3fs", jid, time)); |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
13 | else |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
14 | print("Error requesting ping ("..(reply.condition or "unknown")..")"..(reply.text and (": "..reply.text) or "")); |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
15 | end |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
16 | conn:close(); |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
17 | end |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
18 | local function on_connect(_conn) |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
19 | conn = _conn; |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
20 | conn:add_plugin("ping"); |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
21 | conn:ping(arg[1], on_reply); |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
22 | end |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
23 | clix_connect(opts, on_connect); |
16cdeb9cd879
Add clix module to send XMPP pings to JIDs
"Georg Lukas <georg@op-co.de>"
parents:
diff
changeset
|
24 | end |