ensureSession method

AcpOutboundHub<Object?> ensureSession(
  1. String sessionId
)

Returns the interned hub for sessionId.

Implementation

AcpOutboundHub<Object?> ensureSession(String sessionId) {
  if (_isClosed) {
    throw StateError('Cannot create a session route on a closed connection');
  }
  if (sessionId.isEmpty) {
    throw ArgumentError.value(sessionId, 'sessionId', 'must not be empty');
  }
  final AcpOutboundHub<Object?>? existing = _sessionHubs[sessionId];
  if (existing != null) {
    return existing;
  }
  if (_sessionHubs.length >= maximumSessions) {
    throw StateError('ACP session route limit exceeded');
  }
  final hub = AcpOutboundHub<Object?>(
    capacity: outboundCapacity,
    onOverflow: _onOverflow,
  );
  _sessionHubs[sessionId] = hub;
  return hub;
}