Software /
code /
prosody
Comparison
main.lua @ 38:3fdfd6e0cb4e
SASL!
(but before you get too excited, no resource binding yet. And yes, there are still plenty of rough edges to the code...)
((eg. must move <stream:features> out of xmlhandlers.lua o_O ))
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 02 Oct 2008 01:08:58 +0100 |
parent | 37:06eadafafefa |
child | 49:1cd2a8db392d |
comparison
equal
deleted
inserted
replaced
37:06eadafafefa | 38:3fdfd6e0cb4e |
---|---|
19 require "core.offlinemessage" | 19 require "core.offlinemessage" |
20 require "core.modulemanager" | 20 require "core.modulemanager" |
21 require "core.usermanager" | 21 require "core.usermanager" |
22 require "core.sessionmanager" | 22 require "core.sessionmanager" |
23 require "core.stanza_router" | 23 require "core.stanza_router" |
24 require "net.connhandlers" | |
24 require "util.stanza" | 25 require "util.stanza" |
25 require "util.jid" | 26 require "util.jid" |
26 | 27 |
27 -- Locals for faster access -- | 28 -- Locals for faster access -- |
28 local t_insert = table.insert; | 29 local t_insert = table.insert; |
29 local t_concat = table.concat; | 30 local t_concat = table.concat; |
30 local t_concatall = function (t, sep) local tt = {}; for _, s in ipairs(t) do t_insert(tt, tostring(s)); end return t_concat(tt, sep); end | 31 local t_concatall = function (t, sep) local tt = {}; for _, s in ipairs(t) do t_insert(tt, tostring(s)); end return t_concat(tt, sep); end |
31 local m_random = math.random; | 32 local m_random = math.random; |
32 local format = string.format; | 33 local format = string.format; |
33 local st = stanza; | 34 local st = stanza; |
34 local init_xmlhandlers = xmlhandlers.init_xmlhandlers; | |
35 ------------------------------ | 35 ------------------------------ |
36 | 36 |
37 | 37 |
38 | 38 |
39 local hosts, users = hosts, users; | 39 local hosts, users = hosts, users; |
61 session.log = log; | 61 session.log = log; |
62 | 62 |
63 print("Client connected"); | 63 print("Client connected"); |
64 | 64 |
65 session.stanza_dispatch = function (stanza) return core_process_stanza(session, stanza); end | 65 session.stanza_dispatch = function (stanza) return core_process_stanza(session, stanza); end |
66 session.xml_handlers = init_xmlhandlers(session); | 66 |
67 session.parser = lxp.new(session.xml_handlers, ":"); | 67 session.connhandler = connhandlers.new("xmpp-client", session); |
68 | 68 |
69 function session.disconnect(err) | 69 function session.disconnect(err) |
70 if session.last_presence and session.last_presence.attr.type ~= "unavailable" then | 70 if session.last_presence and session.last_presence.attr.type ~= "unavailable" then |
71 local pres = st.presence{ type = "unavailable" }; | 71 local pres = st.presence{ type = "unavailable" }; |
72 if err == "closed" then err = "connection closed"; end | 72 if err == "closed" then err = "connection closed"; end |
80 print("Disconnected: "..err); | 80 print("Disconnected: "..err); |
81 collectgarbage("collect"); | 81 collectgarbage("collect"); |
82 end | 82 end |
83 end | 83 end |
84 if data then | 84 if data then |
85 session.parser:parse(data); | 85 session.connhandler:data(data); |
86 end | 86 end |
87 | 87 |
88 --log("info", "core", "Client disconnected, connection closed"); | 88 --log("info", "core", "Client disconnected, connection closed"); |
89 end | 89 end |
90 | 90 |