Comparison

plugins/mod_bosh.lua @ 1050:9552c08241af

Merge with 0.4 branch
author Matthew Wild <mwild1@gmail.com>
date Thu, 23 Apr 2009 03:28:35 +0100
parent 1042:a3d77353c18a
parent 1049:c476bceaf2db
child 1112:e8a00a2ea910
comparison
equal deleted inserted replaced
1044:41a0c76127f4 1050:9552c08241af
101 end 101 end
102 102
103 103
104 local function bosh_reset_stream(session) session.notopen = true; end 104 local function bosh_reset_stream(session) session.notopen = true; end
105 105
106 local session_close_reply = { headers = default_headers, body = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate" }) }; 106 local session_close_reply = { headers = default_headers, body = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate" }), attr = {} };
107 local function bosh_close_stream(session, reason) 107 local function bosh_close_stream(session, reason)
108 (session.log or log)("info", "BOSH client disconnected"); 108 (session.log or log)("info", "BOSH client disconnected");
109 session_close_reply.attr.condition = reason; 109 session_close_reply.attr.condition = reason;
110 local session_close_reply = tostring(session_close_reply); 110 local session_close_reply = tostring(session_close_reply);
111 for _, held_request in ipairs(session.requests) do 111 for _, held_request in ipairs(session.requests) do
124 request.notopen = nil; -- Signals that we accept this opening tag 124 request.notopen = nil; -- Signals that we accept this opening tag
125 125
126 -- TODO: Sanity checks here (rid, to, known host, etc.) 126 -- TODO: Sanity checks here (rid, to, known host, etc.)
127 if not hosts[attr.to] then 127 if not hosts[attr.to] then
128 -- Unknown host 128 -- Unknown host
129 log("debug", "BOSH client tried to connect to unknown host: %s", tostring(attr.to));
129 session_close_reply.attr.condition = "host-unknown"; 130 session_close_reply.attr.condition = "host-unknown";
130 request:send{ headers = default_headers, body = tostring(session_close_reply) }; 131 request:send{ headers = default_headers, body = tostring(session_close_reply) };
131 request.notopen = nil 132 request.notopen = nil
132 return; 133 return;
133 end 134 end
178 local features = st.stanza("stream:features"); 179 local features = st.stanza("stream:features");
179 fire_event("stream-features", session, features); 180 fire_event("stream-features", session, features);
180 --xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh' 181 --xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'
181 local response = st.stanza("body", { xmlns = xmlns_bosh, 182 local response = st.stanza("body", { xmlns = xmlns_bosh,
182 inactivity = tostring(BOSH_DEFAULT_INACTIVITY), polling = tostring(BOSH_DEFAULT_POLLING), requests = tostring(BOSH_DEFAULT_REQUESTS), hold = tostring(session.bosh_hold), maxpause = "120", 183 inactivity = tostring(BOSH_DEFAULT_INACTIVITY), polling = tostring(BOSH_DEFAULT_POLLING), requests = tostring(BOSH_DEFAULT_REQUESTS), hold = tostring(session.bosh_hold), maxpause = "120",
183 sid = sid, ver = '1.6', from = session.host, secure = 'true', ["xmpp:version"] = "1.0", 184 sid = sid, authid = sid, ver = '1.6', from = session.host, secure = 'true', ["xmpp:version"] = "1.0",
184 ["xmlns:xmpp"] = "urn:xmpp:xbosh", ["xmlns:stream"] = "http://etherx.jabber.org/streams" }):add_child(features); 185 ["xmlns:xmpp"] = "urn:xmpp:xbosh", ["xmlns:stream"] = "http://etherx.jabber.org/streams" }):add_child(features);
185 request:send{ headers = default_headers, body = tostring(response) }; 186 request:send{ headers = default_headers, body = tostring(response) };
186 187
187 request.sid = sid; 188 request.sid = sid;
188 return; 189 return;