SessionPlugin<CTX extends Context, TSession> constructor

SessionPlugin<CTX extends Context, TSession>({
  1. required TSession initial(),
  2. String getSessionKey(
    1. CTX ctx
    )?,
  3. SessionStorage<TSession>? storage,
  4. String? keyPrefix,
})

Creates a session plugin.

Parameters:

  • initial: Factory function to create initial session data
  • getSessionKey: 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>();