BaseSessionManager
Defined in: session/manager.ts:129
Base implementation of session manager with common functionality.
Extend this class to create domain-specific session managers.
You only need to implement createSession and closeSession.
Example
Section titled “Example”class APIClientManager extends BaseSessionManager<APIClient, APIConfig> { async createSession(config?: APIConfig): Promise<string> { const client = new APIClient(config); const id = this.generateId("api"); this.sessions.set(id, client); return id; }
async closeSession(id: string): Promise<void> { const client = this.sessions.get(id); if (client) { await client.disconnect(); this.sessions.delete(id); } }}Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”TSession
Section titled “TSession”TSession
Type of session object
TConfig
Section titled “TConfig”TConfig = unknown
Configuration type for creating sessions
Implements
Section titled “Implements”ISessionManager<TSession,TConfig>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BaseSessionManager<
TSession,TConfig>():BaseSessionManager<TSession,TConfig>
Returns
Section titled “Returns”BaseSessionManager<TSession, TConfig>
Methods
Section titled “Methods”closeAll()
Section titled “closeAll()”closeAll():
Promise<void>
Defined in: session/manager.ts:196
Close all sessions. Closes sessions in reverse order (most recent first).
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”closeSession()
Section titled “closeSession()”
abstractcloseSession(id):Promise<void>
Defined in: session/manager.ts:158
Close and remove a session. Must be implemented by subclasses.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”createSession()
Section titled “createSession()”
abstractcreateSession(config?):Promise<string>
Defined in: session/manager.ts:152
Create a new session. Must be implemented by subclasses.
Parameters
Section titled “Parameters”config?
Section titled “config?”TConfig
Returns
Section titled “Returns”Promise<string>
Implementation of
Section titled “Implementation of”getSession()
Section titled “getSession()”getSession(
id):TSession|undefined
Defined in: session/manager.ts:163
Get a session by ID.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”TSession | undefined
Implementation of
Section titled “Implementation of”hasSession()
Section titled “hasSession()”hasSession(
id):boolean
Defined in: session/manager.ts:188
Check if a session exists.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”listSessions()
Section titled “listSessions()”listSessions():
string[]
Defined in: session/manager.ts:181
List all active session IDs.
Returns
Section titled “Returns”string[]
Implementation of
Section titled “Implementation of”requireSession()
Section titled “requireSession()”requireSession(
id):TSession
Defined in: session/manager.ts:170
Get a session by ID, throwing if not found.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”TSession