# HG changeset patch # User Matthew Wild # Date 1278594005 -3600 # Node ID 64a573203c209eaeb6bdfc78ed432f2c3f283999 # Parent 27b8a7482149f534f7044b9f690e7aa3f5296baf mod_smacks: Better logic for deciding what is a stanza and what is not, and deciding when to send ack requests diff -r 27b8a7482149 -r 64a573203c20 mod_smacks/mod_smacks.lua --- a/mod_smacks/mod_smacks.lua Thu Jul 08 13:46:04 2010 +0800 +++ b/mod_smacks/mod_smacks.lua Thu Jul 08 14:00:05 2010 +0100 @@ -7,6 +7,8 @@ local sm_attr = { xmlns = xmlns_sm }; +local max_unacked_stanzas = 0; + module:add_event_hook("stream-features", function (session, features) features:tag("sm", sm_attr):tag("optional"):up():up(); @@ -34,7 +36,8 @@ queue[queue_length] = st.reply(stanza); end local ok, err = _send(stanza); - if ok then + if ok and queue_length > max_unacked_stanzas and not session.awaiting_ack then + session.awaiting_ack = true; return _send(st.stanza("r", { xmlns = xmlns_sm })); end return ok, err; @@ -56,7 +59,7 @@ module:hook_stanza(xmlns_sm, "a", function (origin, stanza) if not origin.smacks then return; end - + origin.awaiting_ack = nil; -- Remove handled stanzas from outgoing_stanza_queue local handled_stanza_count = tonumber(stanza.attr.h)+1; for i=1,handled_stanza_count do