Software /
code /
prosody-modules
Comparison
mod_smacks/mod_smacks.lua @ 1531:7d86fc477993
mod_smacks: Delay initiation of outgoing smacks on s2s until after queued stanzas are sent
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 20 Oct 2014 13:15:55 +0200 |
parent | 1530:fb7cd669f41b |
child | 1539:05fa54404012 |
comparison
equal
deleted
inserted
replaced
1530:fb7cd669f41b | 1531:7d86fc477993 |
---|---|
154 module:hook_stanza(xmlns_sm2, "enable", function (session, stanza) return handle_enable(session, stanza, xmlns_sm2); end, 100); | 154 module:hook_stanza(xmlns_sm2, "enable", function (session, stanza) return handle_enable(session, stanza, xmlns_sm2); end, 100); |
155 module:hook_stanza(xmlns_sm3, "enable", function (session, stanza) return handle_enable(session, stanza, xmlns_sm3); end, 100); | 155 module:hook_stanza(xmlns_sm3, "enable", function (session, stanza) return handle_enable(session, stanza, xmlns_sm3); end, 100); |
156 | 156 |
157 module:hook_stanza("http://etherx.jabber.org/streams", "features", | 157 module:hook_stanza("http://etherx.jabber.org/streams", "features", |
158 function (session, stanza) | 158 function (session, stanza) |
159 if can_do_smacks(session) then | 159 module:add_timer(0, function () |
160 if stanza:get_child("sm", xmlns_sm3) then | 160 if can_do_smacks(session) then |
161 session.sends2s(st.stanza("enable", sm3_attr)); | 161 if stanza:get_child("sm", xmlns_sm3) then |
162 session.smacks = xmlns_sm3; | 162 session.sends2s(st.stanza("enable", sm3_attr)); |
163 elseif stanza:get_child("sm", xmlns_sm2) then | 163 session.smacks = xmlns_sm3; |
164 session.sends2s(st.stanza("enable", sm2_attr)); | 164 elseif stanza:get_child("sm", xmlns_sm2) then |
165 session.smacks = xmlns_sm2; | 165 session.sends2s(st.stanza("enable", sm2_attr)); |
166 else | 166 session.smacks = xmlns_sm2; |
167 return; | 167 else |
168 return; | |
169 end | |
170 wrap_session_out(session, false); | |
168 end | 171 end |
169 wrap_session_out(session, false); | 172 end); |
170 end | |
171 end); | 173 end); |
172 | 174 |
173 function handle_enabled(session, stanza, xmlns_sm) | 175 function handle_enabled(session, stanza, xmlns_sm) |
174 module:log("debug", "Enabling stream management"); | 176 module:log("debug", "Enabling stream management"); |
175 session.smacks = xmlns_sm; | 177 session.smacks = xmlns_sm; |