Software /
code /
prosody
Comparison
plugins/mod_bosh.lua @ 4332:8154bc28e520
mod_bosh: Update to use typed variants of module:get_option(), makes it more tolerant to config variations and simplifies the code.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 20 Jul 2011 17:22:21 -0400 |
parent | 4327:98ae0d0b4d07 |
child | 4379:e4d88f4a780c |
comparison
equal
deleted
inserted
replaced
4331:9c45858e3208 | 4332:8154bc28e520 |
---|---|
27 local xmlns_bosh = "http://jabber.org/protocol/httpbind"; -- (hard-coded into a literal in session.send) | 27 local xmlns_bosh = "http://jabber.org/protocol/httpbind"; -- (hard-coded into a literal in session.send) |
28 | 28 |
29 local stream_callbacks = { | 29 local stream_callbacks = { |
30 stream_ns = xmlns_bosh, stream_tag = "body", default_ns = "jabber:client" }; | 30 stream_ns = xmlns_bosh, stream_tag = "body", default_ns = "jabber:client" }; |
31 | 31 |
32 local BOSH_DEFAULT_HOLD = tonumber(module:get_option("bosh_default_hold")) or 1; | 32 local BOSH_DEFAULT_HOLD = module:get_option_number("bosh_default_hold", 1); |
33 local BOSH_DEFAULT_INACTIVITY = tonumber(module:get_option("bosh_max_inactivity")) or 60; | 33 local BOSH_DEFAULT_INACTIVITY = module:get_option_number("bosh_max_inactivity", 60); |
34 local BOSH_DEFAULT_POLLING = tonumber(module:get_option("bosh_max_polling")) or 5; | 34 local BOSH_DEFAULT_POLLING = module:get_option_number("bosh_max_polling", 5); |
35 local BOSH_DEFAULT_REQUESTS = tonumber(module:get_option("bosh_max_requests")) or 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 | 38 |
39 local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" }; | 39 local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" }; |
40 | 40 |
41 local cross_domain = module:get_option("cross_domain_bosh"); | 41 local cross_domain = module:get_option("cross_domain_bosh", false); |
42 if cross_domain then | 42 if cross_domain then |
43 default_headers["Access-Control-Allow-Methods"] = "GET, POST, OPTIONS"; | 43 default_headers["Access-Control-Allow-Methods"] = "GET, POST, OPTIONS"; |
44 default_headers["Access-Control-Allow-Headers"] = "Content-Type"; | 44 default_headers["Access-Control-Allow-Headers"] = "Content-Type"; |
45 default_headers["Access-Control-Max-Age"] = "7200"; | 45 default_headers["Access-Control-Max-Age"] = "7200"; |
46 | 46 |
424 return 1; | 424 return 1; |
425 end | 425 end |
426 | 426 |
427 | 427 |
428 local function setup() | 428 local function setup() |
429 local ports = module:get_option("bosh_ports") or { 5280 }; | 429 local ports = module:get_option_array("bosh_ports") or { 5280 }; |
430 httpserver.new_from_config(ports, handle_request, { base = "http-bind" }); | 430 httpserver.new_from_config(ports, handle_request, { base = "http-bind" }); |
431 timer.add_task(1, on_timer); | 431 timer.add_task(1, on_timer); |
432 end | 432 end |
433 if prosody.start_time then -- already started | 433 if prosody.start_time then -- already started |
434 setup(); | 434 setup(); |