close method

Future<void> close()

cancels stream subscription and closes relay transport

Implementation

Future<void> close() async {
  final streamSubscription = _streamSubscription;
  final transport = relayTransport;

  _streamSubscription = null;
  relayTransport = null;
  // the socket carried them, they die with it
  stats.openRequestIds.clear();

  if (streamSubscription != null) {
    await streamSubscription.cancel();
  }
  if (transport != null) {
    await transport.close().timeout(
      const Duration(seconds: 3),
      onTimeout: () {
        Logger.log.w(() => "timeout while trying to close socket $url");
      },
    );
  }
}