Software /
code /
prosody-modules
Comparison
mod_smacks/mod_smacks.lua @ 256:57de4a7840ef
mod_smacks: Fixes for storing the unacked stanzas so that they can be properly replayed to clients on stream resume
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 07 Oct 2010 16:16:49 +0100 |
parent | 255:9b9b089407b1 |
child | 257:08fa42e1ab06 |
comparison
equal
deleted
inserted
replaced
255:9b9b089407b1 | 256:57de4a7840ef |
---|---|
32 session.last_acknowledged_stanza = 0; | 32 session.last_acknowledged_stanza = 0; |
33 local _send = session.sends2s or session.send; | 33 local _send = session.sends2s or session.send; |
34 local function new_send(stanza) | 34 local function new_send(stanza) |
35 local attr = stanza.attr; | 35 local attr = stanza.attr; |
36 if attr and not attr.xmlns then -- Stanza in default stream namespace | 36 if attr and not attr.xmlns then -- Stanza in default stream namespace |
37 queue[#queue+1] = st.reply(stanza); | 37 queue[#queue+1] = st.clone(stanza); |
38 end | 38 end |
39 local ok, err = _send(stanza); | 39 local ok, err = _send(stanza); |
40 if ok and #queue > max_unacked_stanzas and not session.awaiting_ack then | 40 if ok and #queue > max_unacked_stanzas and not session.awaiting_ack then |
41 session.awaiting_ack = true; | 41 session.awaiting_ack = true; |
42 return _send(st.stanza("r", { xmlns = xmlns_sm })); | 42 return _send(st.stanza("r", { xmlns = xmlns_sm })); |
105 local queue = session.outgoing_stanza_queue; | 105 local queue = session.outgoing_stanza_queue; |
106 local error_attr = { type = "cancel" }; | 106 local error_attr = { type = "cancel" }; |
107 if #queue > 0 then | 107 if #queue > 0 then |
108 session.outgoing_stanza_queue = {}; | 108 session.outgoing_stanza_queue = {}; |
109 for i=1,#queue do | 109 for i=1,#queue do |
110 local reply = queue[i]; | 110 local reply = st.reply(queue[i]); |
111 if reply.attr.to ~= session.full_jid then | 111 if reply.attr.to ~= session.full_jid then |
112 reply.attr.type = "error"; | 112 reply.attr.type = "error"; |
113 reply:tag("error", error_attr) | 113 reply:tag("error", error_attr) |
114 :tag("recipient-unavailable", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}); | 114 :tag("recipient-unavailable", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}); |
115 core_process_stanza(session, queue[i]); | 115 core_process_stanza(session, reply); |
116 end | 116 end |
117 end | 117 end |
118 end | 118 end |
119 end | 119 end |
120 | 120 |