Software /
code /
prosody
Comparison
plugins/mod_bosh.lua @ 5729:8de1f9290588
Merge 0.9->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 09 Jul 2013 00:04:30 +0100 |
parent | 5674:ebdbf4cf0b2f |
parent | 5727:372ecf3630cf |
child | 5748:cef2a1122b43 |
comparison
equal
deleted
inserted
replaced
5725:c4200292758c | 5729:8de1f9290588 |
---|---|
18 local st = require "util.stanza"; | 18 local st = require "util.stanza"; |
19 local logger = require "util.logger"; | 19 local logger = require "util.logger"; |
20 local log = logger.init("mod_bosh"); | 20 local log = logger.init("mod_bosh"); |
21 local initialize_filters = require "util.filters".initialize; | 21 local initialize_filters = require "util.filters".initialize; |
22 local math_min = math.min; | 22 local math_min = math.min; |
23 local xpcall, tostring, type = xpcall, tostring, type; | |
24 local traceback = debug.traceback; | |
23 | 25 |
24 local xmlns_streams = "http://etherx.jabber.org/streams"; | 26 local xmlns_streams = "http://etherx.jabber.org/streams"; |
25 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; | 27 local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; |
26 local xmlns_bosh = "http://jabber.org/protocol/httpbind"; -- (hard-coded into a literal in session.send) | 28 local xmlns_bosh = "http://jabber.org/protocol/httpbind"; -- (hard-coded into a literal in session.send) |
27 | 29 |
351 session.send(features); | 353 session.send(features); |
352 session.notopen = nil; | 354 session.notopen = nil; |
353 end | 355 end |
354 end | 356 end |
355 | 357 |
358 local function handleerr(err) log("error", "Traceback[bosh]: %s", traceback(tostring(err), 2)); end | |
356 function stream_callbacks.handlestanza(context, stanza) | 359 function stream_callbacks.handlestanza(context, stanza) |
357 if context.ignore then return; end | 360 if context.ignore then return; end |
358 log("debug", "BOSH stanza received: %s\n", stanza:top_tag()); | 361 log("debug", "BOSH stanza received: %s\n", stanza:top_tag()); |
359 local session = sessions[context.sid]; | 362 local session = sessions[context.sid]; |
360 if session then | 363 if session then |
361 if stanza.attr.xmlns == xmlns_bosh then | 364 if stanza.attr.xmlns == xmlns_bosh then |
362 stanza.attr.xmlns = nil; | 365 stanza.attr.xmlns = nil; |
363 end | 366 end |
364 stanza = session.filter("stanzas/in", stanza); | 367 stanza = session.filter("stanzas/in", stanza); |
365 core_process_stanza(session, stanza); | 368 if stanza then |
369 return xpcall(function () return core_process_stanza(session, stanza) end, handleerr); | |
370 end | |
366 end | 371 end |
367 end | 372 end |
368 | 373 |
369 function stream_callbacks.streamclosed(context) | 374 function stream_callbacks.streamclosed(context) |
370 local session = sessions[context.sid]; | 375 local session = sessions[context.sid]; |