plugins/mod_bosh.lua
changeset 4690 55f690fdc915
parent 4684 dc70c4ffb66d
child 4692 8e7c683d78ca
equal deleted inserted replaced
4689:e8c357259993 4690:55f690fdc915
   163 		
   163 		
   164 		if not request.destroyed then
   164 		if not request.destroyed then
   165 			-- We're keeping this request open, to respond later
   165 			-- We're keeping this request open, to respond later
   166 			log("debug", "Have nothing to say, so leaving request unanswered for now");
   166 			log("debug", "Have nothing to say, so leaving request unanswered for now");
   167 			if session.bosh_wait then
   167 			if session.bosh_wait then
   168 				request.reply_before = os_time() + session.bosh_wait;
   168 				waiting_requests[request] = os_time() + session.bosh_wait;
   169 				waiting_requests[request] = true;
       
   170 			end
   169 			end
   171 		end
   170 		end
   172 		
   171 		
   173 		if session.bosh_terminate then
   172 		if session.bosh_terminate then
   174 			session.log("debug", "Closing session with %d requests open", #session.requests);
   173 			session.log("debug", "Closing session with %d requests open", #session.requests);
   397 local dead_sessions = {};
   396 local dead_sessions = {};
   398 function on_timer()
   397 function on_timer()
   399 	-- log("debug", "Checking for requests soon to timeout...");
   398 	-- log("debug", "Checking for requests soon to timeout...");
   400 	-- Identify requests timing out within the next few seconds
   399 	-- Identify requests timing out within the next few seconds
   401 	local now = os_time() + 3;
   400 	local now = os_time() + 3;
   402 	for request in pairs(waiting_requests) do
   401 	for request, reply_before in pairs(waiting_requests) do
   403 		if request.reply_before <= now then
   402 		if reply_before <= now then
   404 			log("debug", "%s was soon to timeout, sending empty response", request.id);
   403 			log("debug", "%s was soon to timeout, sending empty response", request.id);
   405 			-- Send empty response to let the
   404 			-- Send empty response to let the
   406 			-- client know we're still here
   405 			-- client know we're still here
   407 			if request.conn then
   406 			if request.conn then
   408 				sessions[request.sid].send("");
   407 				sessions[request.sid].send("");