SessionPlugin<CTX extends Context, TSession> constructor
SessionPlugin<CTX extends Context, TSession> ({
- required TSession initial(),
- String getSessionKey(
- CTX ctx
- SessionStorage<
TSession> ? storage, - String? keyPrefix,
Creates a session plugin.
Parameters:
initial
: Factory function to create initial session datagetSessionKey
: Function to generate session keys (defaults to chat-based)storage
: Storage backend (defaults to memory storage)keyPrefix
: Optional prefix for session keys
Implementation
SessionPlugin({
required this.initial,
String Function(CTX ctx)? getSessionKey,
SessionStorage<TSession>? storage,
this.keyPrefix,
}) : getSessionKey = getSessionKey ?? _defaultSessionKeyGenerator,
storage = storage ?? MemorySessionStorage<TSession>();