feat(session): fix sessions getting disregarded due to reload

This commit is contained in:
ItzCrazyKns
2025-12-23 17:12:56 +05:30
parent 216332fb20
commit 8ba64be446

View File

@@ -2,8 +2,14 @@ import { EventEmitter } from 'stream';
import { applyPatch } from 'rfc6902'; import { applyPatch } from 'rfc6902';
import { Block } from './types'; import { Block } from './types';
const sessions =
(global as any)._sessionManagerSessions || new Map<string, SessionManager>();
if (process.env.NODE_ENV !== 'production') {
(global as any)._sessionManagerSessions = sessions;
}
class SessionManager { class SessionManager {
private static sessions = new Map<string, SessionManager>(); private static sessions: Map<string, SessionManager> = sessions;
readonly id: string; readonly id: string;
private blocks = new Map<string, Block>(); private blocks = new Map<string, Block>();
private events: { event: string; data: any }[] = []; private events: { event: string; data: any }[] = [];