Added session & session manager

This commit is contained in:
Tom
2024-12-05 01:05:58 +00:00
parent 1b91e330c1
commit 478bd76aeb
2 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,33 @@
class SessionManager {
constructor() {
this._sessions = {};
}
add(session) {
if (!session || !session.id)
return;
this._sessions[session.id] = session;
}
contains(sessionId) {
return this._sessions[sessionId] != null;
}
get(sessionId) {
return this._sessions[sessionId];
}
getSessionIds() {
return Object.keys(this._sessions);
}
remove(sessionId) {
if (!sessionId)
return;
delete this._sessions[sessionId];
}
}
module.exports = new SessionManager();