Comparison

mod_smacks/mod_smacks.lua @ 2140:3a94b3cd31e2

mod_smacks: added new events for hibernation start/end
author tmolitor <thilo@eightysoft.de>
date Sun, 27 Mar 2016 16:13:20 +0200
parent 2136:f1be45c9a742
child 2148:c472a454be61
comparison
equal deleted inserted replaced
2139:17408ddd34b0 2140:3a94b3cd31e2
279 else 279 else
280 session.log("debug", "mod_smacks hibernating session for up to %d seconds", resume_timeout); 280 session.log("debug", "mod_smacks hibernating session for up to %d seconds", resume_timeout);
281 local hibernate_time = os_time(); -- Track the time we went into hibernation 281 local hibernate_time = os_time(); -- Track the time we went into hibernation
282 session.hibernating = hibernate_time; 282 session.hibernating = hibernate_time;
283 local resumption_token = session.resumption_token; 283 local resumption_token = session.resumption_token;
284 module:fire_event("smacks-hibernation-start", {origin = session, queue = session.outgoing_stanza_queue});
284 timer.add_task(resume_timeout, function () 285 timer.add_task(resume_timeout, function ()
285 session.log("debug", "mod_smacks hibernation timeout reached..."); 286 session.log("debug", "mod_smacks hibernation timeout reached...");
286 -- We need to check the current resumption token for this resource 287 -- We need to check the current resumption token for this resource
287 -- matches the smacks session this timer is for in case it changed 288 -- matches the smacks session this timer is for in case it changed
288 -- (for example, the client may have bound a new resource and 289 -- (for example, the client may have bound a new resource and
376 h = stanza.attr.h })); 377 h = stanza.attr.h }));
377 378
378 -- Ok, we need to re-send any stanzas that the client didn't see 379 -- Ok, we need to re-send any stanzas that the client didn't see
379 -- ...they are what is now left in the outgoing stanza queue 380 -- ...they are what is now left in the outgoing stanza queue
380 local queue = original_session.outgoing_stanza_queue; 381 local queue = original_session.outgoing_stanza_queue;
382 module:fire_event("smacks-hibernation-end", {origin = session, queue = queue});
381 session.log("debug", "#queue = %d", #queue); 383 session.log("debug", "#queue = %d", #queue);
382 for i=1,#queue do 384 for i=1,#queue do
383 session.send(queue[i]); 385 session.send(queue[i]);
384 end 386 end
385 session.log("debug", "#queue = %d -- after send", #queue); 387 session.log("debug", "#queue = %d -- after send", #queue);