3 local xmlns_ping = "urn:xmpp:ping"; |
3 local xmlns_ping = "urn:xmpp:ping"; |
4 |
4 |
5 function verse.plugins.ping(stream) |
5 function verse.plugins.ping(stream) |
6 function stream:ping(jid, callback) |
6 function stream:ping(jid, callback) |
7 local t = socket.gettime(); |
7 local t = socket.gettime(); |
8 stream:send_iq(verse.iq{ to = jid, type = "get" }:tag("ping", { xmlns = xmlns_ping }), |
8 stream:send_iq(verse.iq{ to = jid, type = "get" }:tag("ping", { xmlns = xmlns_ping }), |
9 function (reply) |
9 function (reply) |
10 if reply.attr.type == "error" then |
10 if reply.attr.type == "error" then |
11 local type, condition, text = reply:get_error(); |
11 local type, condition, text = reply:get_error(); |
12 if condition ~= "service-unavailable" and condition ~= "feature-not-implemented" then |
12 if condition ~= "service-unavailable" and condition ~= "feature-not-implemented" then |
13 callback(nil, jid, { type = type, condition = condition, text = text }); |
13 callback(nil, jid, { type = type, condition = condition, text = text }); |