diff mod_cloud_notify/mod_cloud_notify.lua @ 2395:2e641ab995b3

mod_cloud_notify: added code to respond to the new event "smacks-ack-delayed" issued by mod_smacks when acks are delayed for a certain amount of time. This allows to send out notification requests before the read timeout or connection close event really happens, thus allowing conversations to be smoother.
author tmolitor <thilo@eightysoft.de>
date Thu, 24 Nov 2016 01:15:08 +0100
parents 92af641fcf48
children 6ab46ff685d0
line wrap: on
line diff
--- a/mod_cloud_notify/mod_cloud_notify.lua	Thu Nov 24 00:47:32 2016 +0100
+++ b/mod_cloud_notify/mod_cloud_notify.lua	Thu Nov 24 01:15:08 2016 +0100
@@ -160,7 +160,7 @@
 local function hibernate_session(event)
 	local session = event.origin;
 	local queue = event.queue;
-	-- process already unacked stanzas
+	-- process unacked stanzas
 	for i=1,#queue do
 		process_new_stanza(queue[i], session);
 	end
@@ -174,8 +174,19 @@
 	filters.remove_filter(session, "stanzas/out", process_new_stanza);
 end
 
+-- smacks ack is delayed
+local function ack_delayed(event)
+	local session = event.origin;
+	local queue = event.queue;
+	-- process unacked stanzas (process_new_stanza will only send push requests for new messages)
+	for i=1,#queue do
+		process_new_stanza(queue[i], session);
+	end
+end
+
 module:hook("smacks-hibernation-start", hibernate_session);
 module:hook("smacks-hibernation-end", restore_session);
+module:hook("smacks-ack-delayed", ack_delayed);
 
 
 module:hook("message/offline/broadcast", function(event)