protocolConnect method

  1. @override
Future<void> protocolConnect()
inherited

Implementation

@override
Future<void> protocolConnect() async {
  // If a reconnection is going on
  // and the enduser called disconnect in between
  // then don't try to connect
  if (connectionAborted) {
    return;
  }

  final url = '${uri.scheme}://${uri.host}:${uri.port}';

  await _subscription?.cancel();
  _subscription = null;

  await _webSocket?.close();
  _webSocket = null;

  _webSocket = await WebSocket.connect(url);

  _webSocket!.pingInterval = pingInterval;

  _subscription = _webSocket!.listen(_handlePayload,
      onError: _handleError, onDone: _handleDone);
}