Mercurial > prosody-hg
comparison plugins/mod_bosh.lua @ 3807:bfd72edfd95c
mod_bosh: Use util.timer for timers instead of server.addtimer.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Thu, 02 Dec 2010 22:47:29 +0500 |
| parents | 2acaf129e1c3 |
| children | 79f62694d36e |
comparison
equal
deleted
inserted
replaced
| 3806:38a13e0ac29c | 3807:bfd72edfd95c |
|---|---|
| 9 module.host = "*" -- Global module | 9 module.host = "*" -- Global module |
| 10 | 10 |
| 11 local hosts = _G.hosts; | 11 local hosts = _G.hosts; |
| 12 local lxp = require "lxp"; | 12 local lxp = require "lxp"; |
| 13 local init_xmlhandlers = require "core.xmlhandlers" | 13 local init_xmlhandlers = require "core.xmlhandlers" |
| 14 local server = require "net.server"; | |
| 15 local httpserver = require "net.httpserver"; | 14 local httpserver = require "net.httpserver"; |
| 16 local sm = require "core.sessionmanager"; | 15 local sm = require "core.sessionmanager"; |
| 17 local sm_destroy_session = sm.destroy_session; | 16 local sm_destroy_session = sm.destroy_session; |
| 18 local new_uuid = require "util.uuid".generate; | 17 local new_uuid = require "util.uuid".generate; |
| 19 local fire_event = prosody.events.fire_event; | 18 local fire_event = prosody.events.fire_event; |
| 20 local core_process_stanza = core_process_stanza; | 19 local core_process_stanza = core_process_stanza; |
| 21 local st = require "util.stanza"; | 20 local st = require "util.stanza"; |
| 22 local logger = require "util.logger"; | 21 local logger = require "util.logger"; |
| 23 local log = logger.init("mod_bosh"); | 22 local log = logger.init("mod_bosh"); |
| 23 local timer = require "util.timer"; | |
| 24 | 24 |
| 25 local xmlns_streams = "http://etherx.jabber.org/streams"; | 25 local xmlns_streams = "http://etherx.jabber.org/streams"; |
| 26 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; | 26 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; |
| 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 |
| 399 for i=1,n_dead_sessions do | 399 for i=1,n_dead_sessions do |
| 400 local session = dead_sessions[i]; | 400 local session = dead_sessions[i]; |
| 401 dead_sessions[i] = nil; | 401 dead_sessions[i] = nil; |
| 402 sm_destroy_session(session, "BOSH client silent for over "..session.bosh_max_inactive.." seconds"); | 402 sm_destroy_session(session, "BOSH client silent for over "..session.bosh_max_inactive.." seconds"); |
| 403 end | 403 end |
| 404 return 1; | |
| 404 end | 405 end |
| 405 | 406 |
| 406 | 407 |
| 407 local function setup() | 408 local function setup() |
| 408 local ports = module:get_option("bosh_ports") or { 5280 }; | 409 local ports = module:get_option("bosh_ports") or { 5280 }; |
| 409 httpserver.new_from_config(ports, handle_request, { base = "http-bind" }); | 410 httpserver.new_from_config(ports, handle_request, { base = "http-bind" }); |
| 410 server.addtimer(on_timer); | 411 timer.add_task(1, on_timer); |
| 411 end | 412 end |
| 412 if prosody.start_time then -- already started | 413 if prosody.start_time then -- already started |
| 413 setup(); | 414 setup(); |
| 414 else | 415 else |
| 415 prosody.events.add_handler("server-started", setup); | 416 prosody.events.add_handler("server-started", setup); |
