comparison 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
comparison
equal deleted inserted replaced
2394:4c27ebcf4cbd 2395:2e641ab995b3
158 158
159 -- smacks hibernation is started 159 -- smacks hibernation is started
160 local function hibernate_session(event) 160 local function hibernate_session(event)
161 local session = event.origin; 161 local session = event.origin;
162 local queue = event.queue; 162 local queue = event.queue;
163 -- process already unacked stanzas 163 -- process unacked stanzas
164 for i=1,#queue do 164 for i=1,#queue do
165 process_new_stanza(queue[i], session); 165 process_new_stanza(queue[i], session);
166 end 166 end
167 -- process future unacked (hibernated) stanzas 167 -- process future unacked (hibernated) stanzas
168 filters.add_filter(session, "stanzas/out", process_new_stanza); 168 filters.add_filter(session, "stanzas/out", process_new_stanza);
172 local function restore_session(event) 172 local function restore_session(event)
173 local session = event.origin; 173 local session = event.origin;
174 filters.remove_filter(session, "stanzas/out", process_new_stanza); 174 filters.remove_filter(session, "stanzas/out", process_new_stanza);
175 end 175 end
176 176
177 -- smacks ack is delayed
178 local function ack_delayed(event)
179 local session = event.origin;
180 local queue = event.queue;
181 -- process unacked stanzas (process_new_stanza will only send push requests for new messages)
182 for i=1,#queue do
183 process_new_stanza(queue[i], session);
184 end
185 end
186
177 module:hook("smacks-hibernation-start", hibernate_session); 187 module:hook("smacks-hibernation-start", hibernate_session);
178 module:hook("smacks-hibernation-end", restore_session); 188 module:hook("smacks-hibernation-end", restore_session);
189 module:hook("smacks-ack-delayed", ack_delayed);
179 190
180 191
181 module:hook("message/offline/broadcast", function(event) 192 module:hook("message/offline/broadcast", function(event)
182 local origin = event.origin; 193 local origin = event.origin;
183 local user_push_services = push_enabled:get(origin.username); 194 local user_push_services = push_enabled:get(origin.username);