Comparison

plugins/mod_bosh.lua @ 1109:bb21eb3cd364

mod_bosh: Give BOSH sessions a logger (thanks Florob)
author Matthew Wild <mwild1@gmail.com>
date Mon, 04 May 2009 19:38:21 +0100
parent 1049:c476bceaf2db
child 1112:e8a00a2ea910
comparison
equal deleted inserted replaced
1108:368754c54045 1109:bb21eb3cd364
9 local sm_destroy_session = sm.destroy_session; 9 local sm_destroy_session = sm.destroy_session;
10 local new_uuid = require "util.uuid".generate; 10 local new_uuid = require "util.uuid".generate;
11 local fire_event = require "core.eventmanager".fire_event; 11 local fire_event = require "core.eventmanager".fire_event;
12 local core_process_stanza = core_process_stanza; 12 local core_process_stanza = core_process_stanza;
13 local st = require "util.stanza"; 13 local st = require "util.stanza";
14 local log = require "util.logger".init("bosh"); 14 local logger = require "util.logger";
15 local log = logger.init("mod_bosh");
15 local stream_callbacks = { stream_tag = "http://jabber.org/protocol/httpbind|body" }; 16 local stream_callbacks = { stream_tag = "http://jabber.org/protocol/httpbind|body" };
16 local config = require "core.configmanager"; 17 local config = require "core.configmanager";
17 local xmlns_bosh = "http://jabber.org/protocol/httpbind"; -- (hard-coded into a literal in session.send) 18 local xmlns_bosh = "http://jabber.org/protocol/httpbind"; -- (hard-coded into a literal in session.send)
18 19
19 local BOSH_DEFAULT_HOLD = tonumber(config.get("*", "core", "bosh_default_hold")) or 1; 20 local BOSH_DEFAULT_HOLD = tonumber(config.get("*", "core", "bosh_default_hold")) or 1;
134 135
135 -- New session 136 -- New session
136 sid = new_uuid(); 137 sid = new_uuid();
137 local session = { type = "c2s_unauthed", conn = {}, sid = sid, rid = attr.rid, host = attr.to, bosh_version = attr.ver, bosh_wait = attr.wait, streamid = sid, 138 local session = { type = "c2s_unauthed", conn = {}, sid = sid, rid = attr.rid, host = attr.to, bosh_version = attr.ver, bosh_wait = attr.wait, streamid = sid,
138 bosh_hold = BOSH_DEFAULT_HOLD, bosh_max_inactive = BOSH_DEFAULT_INACTIVITY, 139 bosh_hold = BOSH_DEFAULT_HOLD, bosh_max_inactive = BOSH_DEFAULT_INACTIVITY,
139 requests = { }, send_buffer = {}, reset_stream = bosh_reset_stream, close = bosh_close_stream, dispatch_stanza = core_process_stanza }; 140 requests = { }, send_buffer = {}, reset_stream = bosh_reset_stream, close = bosh_close_stream,
141 dispatch_stanza = core_process_stanza, log = logger.init("bosh"..sid) };
140 sessions[sid] = session; 142 sessions[sid] = session;
143
141 log("info", "New BOSH session, assigned it sid '%s'", sid); 144 log("info", "New BOSH session, assigned it sid '%s'", sid);
142 local r, send_buffer = session.requests, session.send_buffer; 145 local r, send_buffer = session.requests, session.send_buffer;
143 local response = { headers = default_headers } 146 local response = { headers = default_headers }
144 function session.send(s) 147 function session.send(s)
145 log("debug", "Sending BOSH data: %s", tostring(s)); 148 log("debug", "Sending BOSH data: %s", tostring(s));