Software /
code /
prosody-modules
Comparison
mod_pinger/mod_pinger.lua @ 2674:c971b2cee2cc
mod_pinger: Try to solve smacks related issues, see #712
author | tmolitor <thilo@eightysoft.de> |
---|---|
date | Fri, 07 Apr 2017 23:34:40 +0200 |
parent | 2672:75ab061069aa |
child | 3103:5bf79bb3cf7e |
comparison
equal
deleted
inserted
replaced
2673:2e1a4740adee | 2674:c971b2cee2cc |
---|---|
13 | 13 |
14 function check_session(watchdog) | 14 function check_session(watchdog) |
15 local session = watchdog.session; | 15 local session = watchdog.session; |
16 if not session.idle_pinged then | 16 if not session.idle_pinged then |
17 session.idle_pinged = true; | 17 session.idle_pinged = true; |
18 if session.smacks and not session.awaiting_ack then | 18 if session.smacks then |
19 if not session.awaiting_ack then | |
19 session.send(st.stanza("r", { xmlns = session.smacks })) | 20 session.send(st.stanza("r", { xmlns = session.smacks })) |
21 end | |
20 else | 22 else |
21 session.send(st.iq({ type = "get", from = module.host, id = "idle-check" }) | 23 session.send(st.iq({ type = "get", from = module.host, id = "idle-check" }) |
22 :tag("ping", { xmlns = "urn:xmpp:ping" })); | 24 :tag("ping", { xmlns = "urn:xmpp:ping" })); |
23 end | 25 end |
24 return ping_timeout; -- Call us again after ping_timeout | 26 return ping_timeout; -- Call us again after ping_timeout |
25 else | 27 else |
26 module:log("info", "Client %q silent for too long, closing...", session.full_jid); | 28 module:log("info", "Client %q silent for too long, closing...", session.full_jid); |
27 session:close("connection-timeout"); | 29 session:close("connection-timeout"); |
49 module:hook("resource-bind", function (event) watch_session(event.session); end); | 51 module:hook("resource-bind", function (event) watch_session(event.session); end); |
50 module:hook("resource-unbind", function (event) unwatch_session(event.session); end); | 52 module:hook("resource-unbind", function (event) unwatch_session(event.session); end); |
51 | 53 |
52 -- handle smacks sessions properly (not pinging in hibernated state) | 54 -- handle smacks sessions properly (not pinging in hibernated state) |
53 module:hook("smacks-hibernation-start", function (event) unwatch_session(event.origin); end); | 55 module:hook("smacks-hibernation-start", function (event) unwatch_session(event.origin); end); |
54 module:hook("smacks-hibernation-end", function (event) watch_session(event.origin); end); | 56 module:hook("smacks-hibernation-end", function (event) watch_session(event.resumed); end); |