stop method

Future<void> stop()

Stops the connection.

Implementation

Future<void> stop() async {
  // Capture the start future before the connection might be restarted in an onclose callback.
  final startFuture = _startFuture;

  _stopFuture = _stopInternal();
  await _stopFuture;

  try {
    // Awaiting undefined continues immediately
    await startFuture;
  } catch (e) {
    // This exception is returned to the user as a rejected Future from the start method.
  }
}