apollo/services/session-manager.js

33 lines
529 B
JavaScript

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();