diff options
author | Matthew Wild <mwild1@gmail.com> | 2008-09-30 19:52:00 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2008-09-30 19:52:00 +0100 |
commit | a53395e6b72ac0abad00123e1d07b3504f585e08 (patch) | |
tree | abcdd55cfafbc477ea75067efd89b5845f4cad19 /main.lua | |
parent | 733c39e3dacf91f10fcb2f9501b6f0618a0b11fc (diff) | |
download | prosody-a53395e6b72ac0abad00123e1d07b3504f585e08.tar.gz prosody-a53395e6b72ac0abad00123e1d07b3504f585e08.zip |
Huge commit to:
* Break stanza routing (to be restored in a future commit)
* Remove the old stanza_dispatcher code, which was never going to be maintainable nor extendable :)
* Bring us plugins, starting with mod_legacyauth and mod_roster
* Sessions are now created/destroyed using a standard sessionmanager interface
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -13,7 +13,10 @@ require "core.stanza_dispatch" require "core.xmlhandlers" require "core.rostermanager" require "core.offlinemessage" +require "core.modulemanager" require "core.usermanager" +require "core.sessionmanager" +require "core.stanza_router" require "util.stanza" require "util.jid" @@ -113,7 +116,7 @@ function handler(conn, data, err) local session = sessions[conn]; if not session then - sessions[conn] = { conn = conn, notopen = true, priority = 0 }; + sessions[conn] = sessionmanager.new_session(conn); session = sessions[conn]; -- Logging functions -- @@ -127,16 +130,9 @@ function handler(conn, data, err) local print = function (...) log("info", "core", t_concatall({...}, "\t")); end session.log = log; - -- -- -- - - -- Send buffers -- - - local send = function (data) print("Sending...", tostring(data)); conn.write(tostring(data)); end; - session.send, session.send_to = send, send_to; - print("Client connected"); - session.stanza_dispatch = init_stanza_dispatcher(session); + session.stanza_dispatch = function (stanza) return core_process_stanza(session, stanza); end session.xml_handlers = init_xmlhandlers(session); session.parser = lxp.new(session.xml_handlers, ":"); @@ -168,6 +164,7 @@ end setmetatable(_G, { __index = function (t, k) print("WARNING: ATTEMPT TO READ A NIL GLOBAL!!!", k); error("Attempt to read a non-existent global. Naughty boy.", 2); end, __newindex = function (t, k, v) print("ATTEMPT TO SET A GLOBAL!!!!", tostring(k).." = "..tostring(v)); error("Attempt to set a global. Naughty boy.", 2); end }) --]][][[]][]; +modulemanager.loadall(); local protected_handler = function (conn, data, err) local success, ret = pcall(handler, conn, data, err); if not success then print("ERROR on "..tostring(conn)..": "..ret); conn:close(); end end; local protected_disconnect = function (conn, err) local success, ret = pcall(disconnect, conn, err); if not success then print("ERROR on "..tostring(conn).." disconnect: "..ret); conn:close(); end end; |