close method

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

Closes the connection. Idempotent.

Implementation

@override
Future<void> close() async {
  if (_closed) return;
  _closed = true;
  await _rxSub?.cancel();
  _rxSub = null;
  final ws = _ws;
  _ws = null;
  if (ws != null) {
    try {
      await ws.close();
    } on Object {
      // Best-effort.
    }
  }
  if (!_rxCtrl.isClosed) {
    await _rxCtrl.close();
  }
}