Comparison

plugins/mod_bosh.lua @ 4442:bc0a68cae236

mod_bosh: Experimental option 'bosh_auto_cork' which witholds any response to a request until all stanzas in it have been processed.
author Matthew Wild <mwild1@gmail.com>
date Wed, 07 Dec 2011 05:54:17 +0000
parent 4438:7f51186ed28b
child 4447:57d7362a9312
comparison
equal deleted inserted replaced
4441:a01b7207cb37 4442:bc0a68cae236
33 local BOSH_DEFAULT_INACTIVITY = module:get_option_number("bosh_max_inactivity", 60); 33 local BOSH_DEFAULT_INACTIVITY = module:get_option_number("bosh_max_inactivity", 60);
34 local BOSH_DEFAULT_POLLING = module:get_option_number("bosh_max_polling", 5); 34 local BOSH_DEFAULT_POLLING = module:get_option_number("bosh_max_polling", 5);
35 local BOSH_DEFAULT_REQUESTS = module:get_option_number("bosh_max_requests", 2); 35 local BOSH_DEFAULT_REQUESTS = module:get_option_number("bosh_max_requests", 2);
36 36
37 local consider_bosh_secure = module:get_option_boolean("consider_bosh_secure"); 37 local consider_bosh_secure = module:get_option_boolean("consider_bosh_secure");
38 local auto_cork = module:get_option_boolean("bosh_auto_cork", false);
38 39
39 local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" }; 40 local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" };
40 41
41 local cross_domain = module:get_option("cross_domain_bosh", false); 42 local cross_domain = module:get_option("cross_domain_bosh", false);
42 if cross_domain then 43 if cross_domain then
266 s = st.clone(s); 267 s = st.clone(s);
267 s.attr.xmlns = "jabber:client"; 268 s.attr.xmlns = "jabber:client";
268 end 269 end
269 --log("debug", "Sending BOSH data: %s", tostring(s)); 270 --log("debug", "Sending BOSH data: %s", tostring(s));
270 local oldest_request = r[1]; 271 local oldest_request = r[1];
271 if oldest_request then 272 if oldest_request and (not(auto_cork) or waiting_requests[oldest_request]) then
272 log("debug", "We have an open request, so sending on that"); 273 log("debug", "We have an open request, so sending on that");
273 response.body = t_concat({ 274 response.body = t_concat({
274 "<body xmlns='http://jabber.org/protocol/httpbind' ", 275 "<body xmlns='http://jabber.org/protocol/httpbind' ",
275 session.bosh_terminate and "type='terminate' " or "", 276 session.bosh_terminate and "type='terminate' " or "",
276 "sid='", sid, "' xmlns:stream = 'http://etherx.jabber.org/streams'>", 277 "sid='", sid, "' xmlns:stream = 'http://etherx.jabber.org/streams'>",