plugins/mod_smacks.lua
changeset 12528 dd5ab9a6b599
parent 12527 d2177cb5a766
child 12531 923d6fe5ee41
equal deleted inserted replaced
12527:d2177cb5a766 12528:dd5ab9a6b599
   171 	return queue:count_unacked() > max_unacked and expected_h ~= session.last_requested_h;
   171 	return queue:count_unacked() > max_unacked and expected_h ~= session.last_requested_h;
   172 end
   172 end
   173 
   173 
   174 local function request_ack(session, reason)
   174 local function request_ack(session, reason)
   175 	local queue = session.outgoing_stanza_queue;
   175 	local queue = session.outgoing_stanza_queue;
   176 	session.log("debug", "Sending <r> (inside timer, before send) from %s - #queue=%d", reason, queue:count_unacked());
   176 	session.log("debug", "Sending <r> from %s - #queue=%d", reason, queue:count_unacked());
   177 	(session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks }))
   177 	(session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks }))
   178 	if session.destroyed then return end -- sending something can trigger destruction
   178 	if session.destroyed then return end -- sending something can trigger destruction
   179 	session.awaiting_ack = true;
   179 	session.awaiting_ack = true;
   180 	-- expected_h could be lower than this expression e.g. more stanzas added to the queue meanwhile)
   180 	-- expected_h could be lower than this expression e.g. more stanzas added to the queue meanwhile)
   181 	session.last_requested_h = queue:count_acked() + queue:count_unacked();
   181 	session.last_requested_h = queue:count_acked() + queue:count_unacked();
   182 	session.log("debug", "Sending <r> (inside timer, after send) from %s - #queue=%d", reason, queue:count_unacked());
       
   183 	if not session.delayed_ack_timer then
   182 	if not session.delayed_ack_timer then
   184 		session.delayed_ack_timer = timer.add_task(delayed_ack_timeout, function()
   183 		session.delayed_ack_timer = timer.add_task(delayed_ack_timeout, function()
   185 			ack_delayed(session, nil); -- we don't know if this is the only new stanza in the queue
   184 			ack_delayed(session, nil); -- we don't know if this is the only new stanza in the queue
   186 		end);
   185 		end);
   187 	end
   186 	end