comparison mod_smacks/mod_smacks.lua @ 202:d11478ae374e

mod_smacks: Clean outgoing stanza queue correctly on session close
author Matthew Wild <mwild1@gmail.com>
date Thu, 08 Jul 2010 14:01:52 +0100
parents bc24f58a0d39
children 263858d40ceb
comparison
equal deleted inserted replaced
201:bc24f58a0d39 202:d11478ae374e
88 88
89 function handle_unacked_stanzas(session) 89 function handle_unacked_stanzas(session)
90 local queue = session.outgoing_stanza_queue; 90 local queue = session.outgoing_stanza_queue;
91 local error_attr = { type = "cancel" }; 91 local error_attr = { type = "cancel" };
92 if #queue > 0 then 92 if #queue > 0 then
93 session.outgoing_stanza_queue = {};
93 for i=1,#queue do 94 for i=1,#queue do
94 local reply = queue[i]; 95 local reply = queue[i];
95 if reply.attr.to ~= session.full_jid then 96 if reply.attr.to ~= session.full_jid then
96 reply.attr.type = "error"; 97 reply.attr.type = "error";
97 reply:tag("error", error_attr) 98 reply:tag("error", error_attr)
98 :tag("recipient-unavailable", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}); 99 :tag("recipient-unavailable", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"});
99 core_process_stanza(session, queue[i]); 100 core_process_stanza(session, queue[i]);
100 end 101 end
101 queue[i] = nil;
102 end 102 end
103 end 103 end
104 end 104 end
105 105
106 local _destroy_session = sessionmanager.destroy_session; 106 local _destroy_session = sessionmanager.destroy_session;