Mercurial > prosody-hg
comparison plugins/mod_bosh.lua @ 1655:dc42bf326713
mod_bosh: Updated to use module:get_option instead of configmanager
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sun, 09 Aug 2009 17:47:26 +0500 |
| parents | 7812459eeed7 |
| children | b31ea419dff5 |
comparison
equal
deleted
inserted
replaced
| 1654:0ae73e3d306f | 1655:dc42bf326713 |
|---|---|
| 3 -- Copyright (C) 2008-2009 Waqas Hussain | 3 -- Copyright (C) 2008-2009 Waqas Hussain |
| 4 -- | 4 -- |
| 5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
| 6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
| 7 -- | 7 -- |
| 8 | |
| 9 | 8 |
| 10 module.host = "*" -- Global module | 9 module.host = "*" -- Global module |
| 11 | 10 |
| 12 local hosts = _G.hosts; | 11 local hosts = _G.hosts; |
| 13 local lxp = require "lxp"; | 12 local lxp = require "lxp"; |
| 21 local core_process_stanza = core_process_stanza; | 20 local core_process_stanza = core_process_stanza; |
| 22 local st = require "util.stanza"; | 21 local st = require "util.stanza"; |
| 23 local logger = require "util.logger"; | 22 local logger = require "util.logger"; |
| 24 local log = logger.init("mod_bosh"); | 23 local log = logger.init("mod_bosh"); |
| 25 local stream_callbacks = { stream_tag = "http://jabber.org/protocol/httpbind|body" }; | 24 local stream_callbacks = { stream_tag = "http://jabber.org/protocol/httpbind|body" }; |
| 26 local config = require "core.configmanager"; | |
| 27 local xmlns_bosh = "http://jabber.org/protocol/httpbind"; -- (hard-coded into a literal in session.send) | 25 local xmlns_bosh = "http://jabber.org/protocol/httpbind"; -- (hard-coded into a literal in session.send) |
| 28 | 26 |
| 29 local BOSH_DEFAULT_HOLD = tonumber(config.get("*", "core", "bosh_default_hold")) or 1; | 27 local BOSH_DEFAULT_HOLD = tonumber(module:get_option("bosh_default_hold")) or 1; |
| 30 local BOSH_DEFAULT_INACTIVITY = tonumber(config.get("*", "core", "bosh_max_inactivity")) or 60; | 28 local BOSH_DEFAULT_INACTIVITY = tonumber(module:get_option("bosh_max_inactivity")) or 60; |
| 31 local BOSH_DEFAULT_POLLING = tonumber(config.get("*", "core", "bosh_max_polling")) or 5; | 29 local BOSH_DEFAULT_POLLING = tonumber(module:get_option("bosh_max_polling")) or 5; |
| 32 local BOSH_DEFAULT_REQUESTS = tonumber(config.get("*", "core", "bosh_max_requests")) or 2; | 30 local BOSH_DEFAULT_REQUESTS = tonumber(module:get_option("bosh_max_requests")) or 2; |
| 33 local BOSH_DEFAULT_MAXPAUSE = tonumber(config.get("*", "core", "bosh_max_pause")) or 300; | 31 local BOSH_DEFAULT_MAXPAUSE = tonumber(module:get_option("bosh_max_pause")) or 300; |
| 34 | 32 |
| 35 local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" }; | 33 local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" }; |
| 36 | 34 |
| 37 local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat; | 35 local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat; |
| 38 local os_time = os.time; | 36 local os_time = os.time; |
| 273 inactive_sessions[session] = nil; | 271 inactive_sessions[session] = nil; |
| 274 end | 272 end |
| 275 end | 273 end |
| 276 end | 274 end |
| 277 | 275 |
| 278 local ports = config.get(module.host, "core", "bosh_ports") or { 5280 }; | 276 local ports = module:get_option("bosh_ports") or { 5280 }; |
| 279 httpserver.new_from_config(ports, "http-bind", handle_request); | 277 httpserver.new_from_config(ports, "http-bind", handle_request); |
| 280 | 278 |
| 281 server.addtimer(on_timer); | 279 server.addtimer(on_timer); |
