Software /
code /
prosody
Comparison
plugins/mod_bosh.lua @ 5071:0382f456ac82
mod_bosh: Remove redundant code (send stream features in only one place) (thanks Zash)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 01 Aug 2012 01:03:53 +0100 |
parent | 5070:4bf6bd22ad11 |
child | 5179:f3662fea95d9 |
comparison
equal
deleted
inserted
replaced
5070:4bf6bd22ad11 | 5071:0382f456ac82 |
---|---|
244 local session = { | 244 local session = { |
245 type = "c2s_unauthed", conn = {}, sid = sid, rid = tonumber(attr.rid)-1, host = attr.to, | 245 type = "c2s_unauthed", conn = {}, sid = sid, rid = tonumber(attr.rid)-1, host = attr.to, |
246 bosh_version = attr.ver, bosh_wait = attr.wait, streamid = sid, | 246 bosh_version = attr.ver, bosh_wait = attr.wait, streamid = sid, |
247 bosh_hold = BOSH_DEFAULT_HOLD, bosh_max_inactive = BOSH_DEFAULT_INACTIVITY, | 247 bosh_hold = BOSH_DEFAULT_HOLD, bosh_max_inactive = BOSH_DEFAULT_INACTIVITY, |
248 requests = { }, send_buffer = {}, reset_stream = bosh_reset_stream, | 248 requests = { }, send_buffer = {}, reset_stream = bosh_reset_stream, |
249 close = bosh_close_stream, dispatch_stanza = core_process_stanza, | 249 close = bosh_close_stream, dispatch_stanza = core_process_stanza, notopen = true, |
250 log = logger.init("bosh"..sid), secure = consider_bosh_secure or request.secure, | 250 log = logger.init("bosh"..sid), secure = consider_bosh_secure or request.secure, |
251 ip = get_ip_from_request(request); | 251 ip = get_ip_from_request(request); |
252 }; | 252 }; |
253 sessions[sid] = session; | 253 sessions[sid] = session; |
254 | 254 |
255 session.log("debug", "BOSH session created for request from %s", session.ip); | 255 session.log("debug", "BOSH session created for request from %s", session.ip); |
256 log("info", "New BOSH session, assigned it sid '%s'", sid); | 256 log("info", "New BOSH session, assigned it sid '%s'", sid); |
257 | 257 |
258 -- Send creation response | 258 -- Send creation response |
259 local creating_session = true; | 259 local creating_session = true; |
260 local features = st.stanza("stream:features"); | |
261 hosts[session.host].events.fire_event("stream-features", { origin = session, features = features }); | |
262 fire_event("stream-features", session, features); | |
263 table.insert(session.send_buffer, tostring(features)); | |
264 | 260 |
265 local r = session.requests; | 261 local r = session.requests; |
266 function session.send(s) | 262 function session.send(s) |
267 -- We need to ensure that outgoing stanzas have the jabber:client xmlns | 263 -- We need to ensure that outgoing stanzas have the jabber:client xmlns |
268 if s.attr and not s.attr.xmlns then | 264 if s.attr and not s.attr.xmlns then |