Mercurial > prosody-modules
comparison 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 |
| parents | 2f9ee9ed6267 |
| children | 3683eb95bc1a |
comparison
equal
deleted
inserted
replaced
| 1732:2f9ee9ed6267 | 1733:9abd3dce619a |
|---|---|
| 375 end | 375 end |
| 376 return true; | 376 return true; |
| 377 end | 377 end |
| 378 module:hook_stanza(xmlns_sm2, "resume", function (session, stanza) return handle_resume(session, stanza, xmlns_sm2); end); | 378 module:hook_stanza(xmlns_sm2, "resume", function (session, stanza) return handle_resume(session, stanza, xmlns_sm2); end); |
| 379 module:hook_stanza(xmlns_sm3, "resume", function (session, stanza) return handle_resume(session, stanza, xmlns_sm3); end); | 379 module:hook_stanza(xmlns_sm3, "resume", function (session, stanza) return handle_resume(session, stanza, xmlns_sm3); end); |
| 380 | |
| 381 local function handle_read_timeout(event) | |
| 382 local session = event.session; | |
| 383 if session.smacks then | |
| 384 if session.awaiting_ack then | |
| 385 return false; -- Kick the session | |
| 386 end | |
| 387 (session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks })); | |
| 388 session.awaiting_ack = true; | |
| 389 return true; | |
| 390 end | |
| 391 end | |
| 392 | |
| 393 module:hook("s2s-read-timeout", handle_read_timeout); | |
| 394 module:hook("c2s-read-timeout", handle_read_timeout); |
