diff -r 6a65142052c8 -r 73d4eb93657b plugins/ping.lua --- a/plugins/ping.lua Fri Mar 03 12:10:54 2023 +0000 +++ b/plugins/ping.lua Thu Mar 16 11:41:52 2023 +0000 @@ -1,12 +1,15 @@ local verse = require "verse"; local gettime = require"socket".gettime; +local new_id = require "util.id".short; local xmlns_ping = "urn:xmpp:ping"; function verse.plugins.ping(stream) function stream:ping(jid, callback) local t = gettime(); - stream:send_iq(verse.iq{ to = jid, type = "get" }:tag("ping", { xmlns = xmlns_ping }), + local id = new_id(); + local ping = verse.iq{ id = id, to = jid, type = "get" }:tag("ping", { xmlns = xmlns_ping }); + stream:send_iq(ping, function (reply) if reply.attr.type == "error" then local type, condition, text = reply:get_error(); @@ -17,6 +20,7 @@ end callback(gettime()-t, jid); end); + return id; end stream:hook("iq/"..xmlns_ping, function(stanza) return stream:send(verse.reply(stanza));