Software /
code /
verse
File
plugins/ping.lua @ 445:b119dc4d8bc2
plugins.smacks: Don't warn about zero stanzas acked
It's only if the count somehow goes backwards that something is really
wrong. An ack for zero stanzas is fine and we don't need to do anything.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 10 Jun 2021 11:58:23 +0200 |
parent | 393:69229fa1d24f |
child | 457:73d4eb93657b |
line wrap: on
line source
local verse = require "verse"; local gettime = require"socket".gettime; 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 }), function (reply) if reply.attr.type == "error" then local type, condition, text = reply:get_error(); if condition ~= "service-unavailable" and condition ~= "feature-not-implemented" then callback(nil, jid, { type = type, condition = condition, text = text }); return; end end callback(gettime()-t, jid); end); end stream:hook("iq/"..xmlns_ping, function(stanza) return stream:send(verse.reply(stanza)); end); return true; end