Software /
code /
prosody
Annotate
util/session.lua @ 6938:9df70e9e006b
util.session: What is the identity of a session?
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 24 Nov 2015 19:09:51 +0100 |
parent | 6937:f5d2e58fbefa |
child | 6939:a9ae0c6ac4f4 |
rev | line source |
---|---|
6937 | 1 |
2 local function new_session(typ) | |
3 local session = { | |
4 type = typ .. "_unauthed"; | |
5 }; | |
6 return session; | |
7 end | |
8 | |
6938
9df70e9e006b
util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents:
6937
diff
changeset
|
9 local function set_id(session) |
9df70e9e006b
util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents:
6937
diff
changeset
|
10 local id = typ .. tostring(session):match("%x+$"):lower(); |
9df70e9e006b
util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents:
6937
diff
changeset
|
11 session.id = id; |
9df70e9e006b
util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents:
6937
diff
changeset
|
12 return session; |
9df70e9e006b
util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents:
6937
diff
changeset
|
13 end |
9df70e9e006b
util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents:
6937
diff
changeset
|
14 |
6937 | 15 return { |
16 new = new_session; | |
6938
9df70e9e006b
util.session: What is the identity of a session?
Kim Alvefur <zash@zash.se>
parents:
6937
diff
changeset
|
17 set_id = set_id; |
6937 | 18 } |