Sat, 10 Apr 2021 00:21:05 +0200
clix.raw: Linearise condition
Goal of having the 'send_xml' string always exist in one place, so we
can do things with it regardless of where it came from.
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