core/sessionmanager.lua

Tue, 30 Sep 2008 19:52:00 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 30 Sep 2008 19:52:00 +0100
changeset 30
bcf539295f2d
child 38
3fdfd6e0cb4e
permissions
-rw-r--r--

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

30
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 local tostring = tostring;
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local log = require "util.logger".init("sessionmanager");
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 module "sessionmanager"
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 function new_session(conn)
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 local session = { conn = conn, notopen = true, priority = 0, type = "c2s_unauthed" };
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 local w = conn.write;
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 session.send = function (t) w(tostring(t)); end
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 return session;
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 end
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 function send_to_session(session, data)
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 log("debug", "Sending...", tostring(data));
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 session.conn.write(tostring(data));
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 end
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 return _M;

mercurial