Software / code / prosody
Comparison
plugins/mod_bosh.lua @ 1662:b31ea419dff5
mod_bosh: Correct reply when closing sessions
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 11 Aug 2009 19:48:41 +0100 |
| parent | 1655:dc42bf326713 |
| child | 1663:b30c4d0bbe84 |
comparison
equal
deleted
inserted
replaced
| 1661:33b1aee4b77f | 1662:b31ea419dff5 |
|---|---|
| 29 local BOSH_DEFAULT_POLLING = tonumber(module:get_option("bosh_max_polling")) or 5; | 29 local BOSH_DEFAULT_POLLING = tonumber(module:get_option("bosh_max_polling")) or 5; |
| 30 local BOSH_DEFAULT_REQUESTS = tonumber(module:get_option("bosh_max_requests")) or 2; | 30 local BOSH_DEFAULT_REQUESTS = tonumber(module:get_option("bosh_max_requests")) or 2; |
| 31 local BOSH_DEFAULT_MAXPAUSE = tonumber(module:get_option("bosh_max_pause")) or 300; | 31 local BOSH_DEFAULT_MAXPAUSE = tonumber(module:get_option("bosh_max_pause")) or 300; |
| 32 | 32 |
| 33 local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" }; | 33 local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" }; |
| 34 local session_close_reply = { headers = default_headers, body = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate" }), attr = {} }; | |
| 34 | 35 |
| 35 local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat; | 36 local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat; |
| 36 local os_time = os.time; | 37 local os_time = os.time; |
| 37 | 38 |
| 38 local sessions = {}; | 39 local sessions = {}; |
| 108 end | 109 end |
| 109 | 110 |
| 110 | 111 |
| 111 local function bosh_reset_stream(session) session.notopen = true; end | 112 local function bosh_reset_stream(session) session.notopen = true; end |
| 112 | 113 |
| 113 local session_close_reply = { headers = default_headers, body = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate" }), attr = {} }; | |
| 114 local function bosh_close_stream(session, reason) | 114 local function bosh_close_stream(session, reason) |
| 115 (session.log or log)("info", "BOSH client disconnected"); | 115 (session.log or log)("info", "BOSH client disconnected"); |
| 116 session_close_reply.attr.condition = reason; | 116 session_close_reply.attr.condition = reason; |
| 117 local session_close_reply = tostring(session_close_reply); | |
| 118 for _, held_request in ipairs(session.requests) do | 117 for _, held_request in ipairs(session.requests) do |
| 119 held_request:send(session_close_reply); | 118 held_request:send(session_close_reply); |
| 120 held_request:destroy(); | 119 held_request:destroy(); |
| 121 end | 120 end |
| 122 sessions[session.sid] = nil; | 121 sessions[session.sid] = nil; |