close method

  1. @override
Future<void> close()
override

Closes the connection

Implementation

@override
Future<void> close() async {
  // Dispose of health monitoring
  _healthMonitor.dispose();

  // Close all streams
  await _streamsLock.synchronized(() async {
    for (final stream in _streams.values) {
      await stream.close(); // This will also call done() on stream's scope
    }
    _streams.clear();

    if (_isClosed) return;
    _isClosed = true;

    // Signal that the connection scope is done
    _managementScope.done();

    // Close the underlying connection
    await conn.close();

  });
}