plugins/mod_bosh.lua

changeset 2279
27441b099984
parent 2099
73e083d01449
child 2354
5a00668ba0ab
child 2923
b7049746bd29
equal deleted inserted replaced
2278:0b0fe49e5251 2279:27441b099984
150 150
151 log("info", "New BOSH session, assigned it sid '%s'", sid); 151 log("info", "New BOSH session, assigned it sid '%s'", sid);
152 local r, send_buffer = session.requests, session.send_buffer; 152 local r, send_buffer = session.requests, session.send_buffer;
153 local response = { headers = default_headers } 153 local response = { headers = default_headers }
154 function session.send(s) 154 function session.send(s)
155 log("debug", "Sending BOSH data: %s", tostring(s)); 155 --log("debug", "Sending BOSH data: %s", tostring(s));
156 local oldest_request = r[1]; 156 local oldest_request = r[1];
157 while oldest_request and oldest_request.destroyed do 157 while oldest_request and oldest_request.destroyed do
158 t_remove(r, 1); 158 t_remove(r, 1);
159 waiting_requests[oldest_request] = nil; 159 waiting_requests[oldest_request] = nil;
160 oldest_request = r[1]; 160 oldest_request = r[1];
161 end 161 end
162 if oldest_request then 162 if oldest_request then
163 log("debug", "We have an open request, so using that to send with"); 163 log("debug", "We have an open request, so sending on that");
164 response.body = t_concat{"<body xmlns='http://jabber.org/protocol/httpbind' sid='", sid, "' xmlns:stream = 'http://etherx.jabber.org/streams'>", tostring(s), "</body>" }; 164 response.body = t_concat{"<body xmlns='http://jabber.org/protocol/httpbind' sid='", sid, "' xmlns:stream = 'http://etherx.jabber.org/streams'>", tostring(s), "</body>" };
165 oldest_request:send(response); 165 oldest_request:send(response);
166 --log("debug", "Sent"); 166 --log("debug", "Sent");
167 if oldest_request.stayopen then 167 if oldest_request.stayopen then
168 if #r>1 then 168 if #r>1 then

mercurial