--- a/mod_smacks/mod_smacks.lua Fri Oct 01 16:15:36 2010 +0200
+++ b/mod_smacks/mod_smacks.lua Thu Oct 07 16:14:31 2010 +0100
@@ -30,8 +30,8 @@
local queue = {};
session.outgoing_stanza_queue = queue;
session.last_acknowledged_stanza = 0;
- local _send = session.send;
- function session.send(stanza)
+ local _send = session.sends2s or session.send;
+ local function new_send(stanza)
local attr = stanza.attr;
if attr and not attr.xmlns then -- Stanza in default stream namespace
queue[#queue+1] = st.reply(stanza);
@@ -44,6 +44,12 @@
return ok, err;
end
+ if session.sends2s then
+ session.sends2s = new_send;
+ else
+ session.send = new_send;
+ end
+
session.handled_stanza_count = 0;
add_filter(session, "stanzas/in", function (stanza)
if not stanza.attr.xmlns then
@@ -66,7 +72,7 @@
end
module:log("debug", "Received ack request, acking for %d", origin.handled_stanza_count);
-- Reply with <a>
- origin.send(st.stanza("a", { xmlns = xmlns_sm, h = tostring(origin.handled_stanza_count) }));
+ (origin.sends2s or origin.send)(st.stanza("a", { xmlns = xmlns_sm, h = tostring(origin.handled_stanza_count) }));
return true;
end);