diff options
author | Matthew Wild <mwild1@gmail.com> | 2008-12-06 23:16:46 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2008-12-06 23:16:46 +0000 |
commit | 36777188133ce74e2fbb82b41d67087005f06967 (patch) | |
tree | a45c87a97bd50d5485427dbd47fb4012030832b9 | |
parent | c16c3b6f6700c9c43c4b42e5e1e923f535eb565f (diff) | |
download | prosody-36777188133ce74e2fbb82b41d67087005f06967.tar.gz prosody-36777188133ce74e2fbb82b41d67087005f06967.zip |
Code tidying for xmpp{client,server}_listeners
-rw-r--r-- | net/xmppclient_listener.lua | 19 | ||||
-rw-r--r-- | net/xmppserver_listener.lua | 30 |
2 files changed, 17 insertions, 32 deletions
diff --git a/net/xmppclient_listener.lua b/net/xmppclient_listener.lua index 22af2de4..c2326a55 100644 --- a/net/xmppclient_listener.lua +++ b/net/xmppclient_listener.lua @@ -47,7 +47,7 @@ function stream_callbacks.error(session, error, data) end end -local function handleerr(err) print("Traceback:", err, debug.traceback()); end +local function handleerr(err) log("error", "Traceback[c2s]:", err, debug.traceback()); end function stream_callbacks.handlestanza(a, b) xpcall(function () core_process_stanza(a, b) end, handleerr); end @@ -116,25 +116,16 @@ function xmppclient.listener(conn, data) -- Logging functions -- - local mainlog, log = log; - do - local conn_name = "c2s"..tostring(conn):match("[a-f0-9]+$"); - log = logger.init(conn_name); - end - local print = function (...) log("info", t_concatall({...}, "\t")); end - session.log = log; - - print("Client connected"); + local conn_name = "c2s"..tostring(conn):match("[a-f0-9]+$"); + session.log = logger.init(conn_name); + + session.log("info", "Client connected"); session.reset_stream = session_reset_stream; session.close = session_close; session_reset_stream(session); -- Initialise, ready for use - -- TODO: Below function should be session,stanza - and xmlhandlers should use :method() notation to call, - -- this will avoid the useless indirection we have atm - -- (I'm on a mission, no time to fix now) - -- Debug version -- --local function handleerr(err) print("Traceback:", err, debug.traceback()); end --session.stanza_dispatch = function (stanza) return select(2, xpcall(function () return core_process_stanza(session, stanza); end, handleerr)); end diff --git a/net/xmppserver_listener.lua b/net/xmppserver_listener.lua index bdd3948d..e4816b1e 100644 --- a/net/xmppserver_listener.lua +++ b/net/xmppserver_listener.lua @@ -39,6 +39,11 @@ function stream_callbacks.error(session, error, data) end end +local function handleerr(err) log("error", "Traceback[s2s]:", err, debug.traceback()); end +function stream_callbacks.handlestanza(a, b) + xpcall(function () core_process_stanza(a, b) end, handleerr); +end + local connlisteners_register = require "net.connlisteners".register; local t_insert = table.insert; @@ -113,25 +118,17 @@ function xmppserver.listener(conn, data) -- Logging functions -- - local mainlog, log = log; - do - local conn_name = "s2sin"..tostring(conn):match("[a-f0-9]+$"); - log = logger.init(conn_name); - end - local print = function (...) log("info", t_concatall({...}, "\t")); end - session.log = log; - - print("Incoming s2s connection"); + + local conn_name = "s2sin"..tostring(conn):match("[a-f0-9]+$"); + session.log = logger.init(conn_name); + + session.log("info", "Incoming s2s connection"); session.reset_stream = session_reset_stream; session.close = session_close; session_reset_stream(session); -- Initialise, ready for use - -- FIXME: Below function should be session,stanza - and xmlhandlers should use :method() notation to call, - -- this will avoid the useless indirection we have atm - -- (I'm on a mission, no time to fix now) - -- Debug version -- -- local function handleerr(err) print("Traceback:", err, debug.traceback()); end -- session.stanza_dispatch = function (stanza) return select(2, xpcall(function () return core_process_stanza(session, stanza); end, handleerr)); end @@ -164,11 +161,8 @@ function xmppserver.register_outgoing(conn, session) session.reset_stream = session_reset_stream; session_reset_stream(session); -- Initialise, ready for use - -- FIXME: Below function should be session,stanza - and xmlhandlers should use :method() notation to call, - -- this will avoid the useless indirection we have atm - -- (I'm on a mission, no time to fix now) - local function handleerr(err) print("Traceback:", err, debug.traceback()); end - session.stanza_dispatch = function (stanza) return select(2, xpcall(function () return core_process_stanza(session, stanza); end, handleerr)); end + --local function handleerr(err) print("Traceback:", err, debug.traceback()); end + --session.stanza_dispatch = function (stanza) return select(2, xpcall(function () return core_process_stanza(session, stanza); end, handleerr)); end end connlisteners_register("xmppserver", xmppserver); |