Mercurial > prosody-hg
comparison plugins/mod_bosh.lua @ 3847:9ffcf7df0c62
mod_bosh: Fixes to the session creation response - add mandatory 'wait' attribute, remove optional 'maxpause' which we don't support, and reformat the code to prevent long lines and wacky indentation. Fixes #219.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 11 Dec 2010 00:19:15 +0000 |
| parents | 8d0f2acbfb28 |
| children | ca91d6e1d802 |
comparison
equal
deleted
inserted
replaced
| 3846:763df64fdd9d | 3847:9ffcf7df0c62 |
|---|---|
| 31 | 31 |
| 32 local BOSH_DEFAULT_HOLD = tonumber(module:get_option("bosh_default_hold")) or 1; | 32 local BOSH_DEFAULT_HOLD = tonumber(module:get_option("bosh_default_hold")) or 1; |
| 33 local BOSH_DEFAULT_INACTIVITY = tonumber(module:get_option("bosh_max_inactivity")) or 60; | 33 local BOSH_DEFAULT_INACTIVITY = tonumber(module:get_option("bosh_max_inactivity")) or 60; |
| 34 local BOSH_DEFAULT_POLLING = tonumber(module:get_option("bosh_max_polling")) or 5; | 34 local BOSH_DEFAULT_POLLING = tonumber(module:get_option("bosh_max_polling")) or 5; |
| 35 local BOSH_DEFAULT_REQUESTS = tonumber(module:get_option("bosh_max_requests")) or 2; | 35 local BOSH_DEFAULT_REQUESTS = tonumber(module:get_option("bosh_max_requests")) or 2; |
| 36 local BOSH_DEFAULT_MAXPAUSE = tonumber(module:get_option("bosh_max_pause")) or 300; | |
| 37 | 36 |
| 38 local consider_bosh_secure = module:get_option_boolean("consider_bosh_secure"); | 37 local consider_bosh_secure = module:get_option_boolean("consider_bosh_secure"); |
| 39 | 38 |
| 40 local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" }; | 39 local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" }; |
| 41 | 40 |
| 281 local features = st.stanza("stream:features"); | 280 local features = st.stanza("stream:features"); |
| 282 hosts[session.host].events.fire_event("stream-features", { origin = session, features = features }); | 281 hosts[session.host].events.fire_event("stream-features", { origin = session, features = features }); |
| 283 fire_event("stream-features", session, features); | 282 fire_event("stream-features", session, features); |
| 284 --xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh' | 283 --xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh' |
| 285 local response = st.stanza("body", { xmlns = xmlns_bosh, | 284 local response = st.stanza("body", { xmlns = xmlns_bosh, |
| 286 inactivity = tostring(BOSH_DEFAULT_INACTIVITY), polling = tostring(BOSH_DEFAULT_POLLING), requests = tostring(BOSH_DEFAULT_REQUESTS), hold = tostring(session.bosh_hold), maxpause = "120", | 285 wait = attr.wait, |
| 287 sid = sid, authid = sid, ver = '1.6', from = session.host, secure = 'true', ["xmpp:version"] = "1.0", | 286 inactivity = tostring(BOSH_DEFAULT_INACTIVITY), |
| 288 ["xmlns:xmpp"] = "urn:xmpp:xbosh", ["xmlns:stream"] = "http://etherx.jabber.org/streams" }):add_child(features); | 287 polling = tostring(BOSH_DEFAULT_POLLING), |
| 288 requests = tostring(BOSH_DEFAULT_REQUESTS), | |
| 289 hold = tostring(session.bosh_hold), | |
| 290 sid = sid, authid = sid, | |
| 291 ver = '1.6', from = session.host, | |
| 292 secure = 'true', ["xmpp:version"] = "1.0", | |
| 293 ["xmlns:xmpp"] = "urn:xmpp:xbosh", | |
| 294 ["xmlns:stream"] = "http://etherx.jabber.org/streams" | |
| 295 }):add_child(features); | |
| 289 request:send{ headers = default_headers, body = tostring(response) }; | 296 request:send{ headers = default_headers, body = tostring(response) }; |
| 290 | 297 |
| 291 request.sid = sid; | 298 request.sid = sid; |
| 292 return; | 299 return; |
| 293 end | 300 end |
