comparison mod_smacks/mod_smacks.lua @ 2744:f70c02c14161

mod_smacks: Trigger event smacks-hibernation-end after queue resend This is more sensible and allows other modules to send out stanzas when handling this event without messing with the order of stanzas.
author tmolitor <thilo@eightysoft.de>
date Fri, 18 Aug 2017 00:56:38 +0200
parents 91cbeb6ad987
children dbba101601b4
comparison
equal deleted inserted replaced
2743:1fa9620220e3 2744:f70c02c14161
507 h = stanza.attr.h })); 507 h = stanza.attr.h }));
508 508
509 -- Ok, we need to re-send any stanzas that the client didn't see 509 -- Ok, we need to re-send any stanzas that the client didn't see
510 -- ...they are what is now left in the outgoing stanza queue 510 -- ...they are what is now left in the outgoing stanza queue
511 local queue = original_session.outgoing_stanza_queue; 511 local queue = original_session.outgoing_stanza_queue;
512 module:fire_event("smacks-hibernation-end", {origin = session, resumed = original_session, queue = queue});
513 original_session.log("debug", "#queue = %d", #queue); 512 original_session.log("debug", "#queue = %d", #queue);
514 for i=1,#queue do 513 for i=1,#queue do
515 original_session.send(queue[i]); 514 original_session.send(queue[i]);
516 end 515 end
517 original_session.log("debug", "#queue = %d -- after send", #queue); 516 original_session.log("debug", "#queue = %d -- after send", #queue);
518 function session.send(stanza) 517 function session.send(stanza)
519 session.log("warn", "Tried to send stanza on old session migrated by smacks resume (maybe there is a bug?): %s", tostring(stanza)); 518 session.log("warn", "Tried to send stanza on old session migrated by smacks resume (maybe there is a bug?): %s", tostring(stanza));
520 return false; 519 return false;
521 end 520 end
521 module:fire_event("smacks-hibernation-end", {origin = session, resumed = original_session, queue = queue});
522 request_ack_if_needed(original_session, true); 522 request_ack_if_needed(original_session, true);
523 else 523 else
524 module:log("warn", "Client %s@%s[%s] tried to resume stream for %s@%s[%s]", 524 module:log("warn", "Client %s@%s[%s] tried to resume stream for %s@%s[%s]",
525 session.username or "?", session.host or "?", session.type, 525 session.username or "?", session.host or "?", session.type,
526 original_session.username or "?", original_session.host or "?", original_session.type); 526 original_session.username or "?", original_session.host or "?", original_session.type);