Comparison

plugins/mod_bosh.lua @ 1112:e8a00a2ea910

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