Software /
code /
prosody-modules
Diff
mod_smacks/mod_smacks.lua @ 1733:9abd3dce619a
mod_smacks: Handle the read timeout event (0.10+ only) and send an ack request, close the connection the second time if unanswerd
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 11 May 2015 15:07:52 +0200 |
parent | 1732:2f9ee9ed6267 |
child | 1881:3683eb95bc1a |
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua Mon May 11 14:33:37 2015 +0200 +++ b/mod_smacks/mod_smacks.lua Mon May 11 15:07:52 2015 +0200 @@ -377,3 +377,18 @@ end module:hook_stanza(xmlns_sm2, "resume", function (session, stanza) return handle_resume(session, stanza, xmlns_sm2); end); module:hook_stanza(xmlns_sm3, "resume", function (session, stanza) return handle_resume(session, stanza, xmlns_sm3); end); + +local function handle_read_timeout(event) + local session = event.session; + if session.smacks then + if session.awaiting_ack then + return false; -- Kick the session + end + (session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks })); + session.awaiting_ack = true; + return true; + end +end + +module:hook("s2s-read-timeout", handle_read_timeout); +module:hook("c2s-read-timeout", handle_read_timeout);