Software /
code /
prosody
Changeset
585:033817e12ddb
Code tidying for xmpp{client,server}_listeners
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 06 Dec 2008 23:16:46 +0000 |
parents | 584:eb0cea29c8d7 |
children | 586:b828d7d47973 |
files | net/xmppclient_listener.lua net/xmppserver_listener.lua |
diffstat | 2 files changed, 17 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/net/xmppclient_listener.lua Sat Dec 06 23:15:48 2008 +0000 +++ b/net/xmppclient_listener.lua Sat Dec 06 23:16:46 2008 +0000 @@ -47,7 +47,7 @@ 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 @@ -- 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
--- a/net/xmppserver_listener.lua Sat Dec 06 23:15:48 2008 +0000 +++ b/net/xmppserver_listener.lua Sat Dec 06 23:16:46 2008 +0000 @@ -39,6 +39,11 @@ 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 @@ -- 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 @@ 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);