Comparison

util/session.lua @ 6939:a9ae0c6ac4f4

util.session: What does the session say?
author Kim Alvefur <zash@zash.se>
date Tue, 24 Nov 2015 19:04:54 +0100
parent 6938:9df70e9e006b
child 6940:2be5e19485aa
comparison
equal deleted inserted replaced
6938:9df70e9e006b 6939:a9ae0c6ac4f4
1 local logger = require "util.logger";
1 2
2 local function new_session(typ) 3 local function new_session(typ)
3 local session = { 4 local session = {
4 type = typ .. "_unauthed"; 5 type = typ .. "_unauthed";
5 }; 6 };
10 local id = typ .. tostring(session):match("%x+$"):lower(); 11 local id = typ .. tostring(session):match("%x+$"):lower();
11 session.id = id; 12 session.id = id;
12 return session; 13 return session;
13 end 14 end
14 15
16 local function set_logger(session)
17 local log = logger.init(id);
18 session.log = log;
19 return session;
20 end
21
15 return { 22 return {
16 new = new_session; 23 new = new_session;
17 set_id = set_id; 24 set_id = set_id;
25 set_logger = set_logger;
18 } 26 }