aboutsummaryrefslogtreecommitdiffstats
path: root/util/session.lua
blob: 7703c2655952e04fe9939da9a4380286afaf41f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
local logger = require "util.logger";

local function new_session(typ)
	local session = {
		type = typ .. "_unauthed";
	};
	return session;
end

local function set_id(session)
	local id = typ .. tostring(session):match("%x+$"):lower();
	session.id = id;
	return session;
end

local function set_logger(session)
	local log = logger.init(id);
	session.log = log;
	return session;
end

return {
	new = new_session;
	set_id = set_id;
	set_logger = set_logger;
}