Software /
code /
prosody
Comparison
net/xmppclient_listener.lua @ 545:60002993be04
Abstract xmlhandlers a bit more, also add error callbacks
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 04 Dec 2008 18:47:26 +0000 |
parent | 543:cf6e19ea1cbc |
child | 557:c9b3ffb08fe3 |
comparison
equal
deleted
inserted
replaced
544:efde848869c5 | 545:60002993be04 |
---|---|
34 local sm_new_session, sm_destroy_session = sessionmanager.new_session, sessionmanager.destroy_session; --import("core.sessionmanager", "new_session", "destroy_session"); | 34 local sm_new_session, sm_destroy_session = sessionmanager.new_session, sessionmanager.destroy_session; --import("core.sessionmanager", "new_session", "destroy_session"); |
35 local sm_streamopened = sessionmanager.streamopened; | 35 local sm_streamopened = sessionmanager.streamopened; |
36 local sm_streamclosed = sessionmanager.streamclosed; | 36 local sm_streamclosed = sessionmanager.streamclosed; |
37 local st = stanza; | 37 local st = stanza; |
38 | 38 |
39 local stream_callbacks = { streamopened = sm_streamopened, streamclosed = sm_streamclosed }; | 39 local stream_callbacks = { streamopened = sm_streamopened, streamclosed = sm_streamclosed, handlestanza = core_process_stanza }; |
40 | 40 |
41 local sessions = {}; | 41 local sessions = {}; |
42 local xmppclient = { default_port = 5222, default_mode = "*a" }; | 42 local xmppclient = { default_port = 5222, default_mode = "*a" }; |
43 | 43 |
44 -- These are session methods -- | 44 -- These are session methods -- |
117 -- TODO: Below function should be session,stanza - and xmlhandlers should use :method() notation to call, | 117 -- TODO: Below function should be session,stanza - and xmlhandlers should use :method() notation to call, |
118 -- this will avoid the useless indirection we have atm | 118 -- this will avoid the useless indirection we have atm |
119 -- (I'm on a mission, no time to fix now) | 119 -- (I'm on a mission, no time to fix now) |
120 | 120 |
121 -- Debug version -- | 121 -- Debug version -- |
122 local function handleerr(err) print("Traceback:", err, debug.traceback()); end | 122 --local function handleerr(err) print("Traceback:", err, debug.traceback()); end |
123 session.stanza_dispatch = function (stanza) return select(2, xpcall(function () return core_process_stanza(session, stanza); end, handleerr)); end | 123 --session.stanza_dispatch = function (stanza) return select(2, xpcall(function () return core_process_stanza(session, stanza); end, handleerr)); end |
124 | |
124 end | 125 end |
125 if data then | 126 if data then |
126 session.data(conn, data); | 127 session.data(conn, data); |
127 end | 128 end |
128 end | 129 end |