open method

  1. @override
Future<void> open({
  1. Duration? pingInterval,
})
override

Implementation

@override
Future<void> open({Duration? pingInterval}) async {
  _onDisconnect = Completer();
  _onConnectionLost = Completer();
  _handshakeCompleter = Completer();
  _inboundBuffer = Uint8List(0);
  _inboundFrameBuffer = null;
  _inboundFrameLength = 0;
  _goodbyeSent = false;
  _goodbyeReceived = false;
  try {
    if (_ssl) {
      _socket = await SecureSocket.connect(
        _host,
        _port,
        context: _tlsSecurityContext as SecurityContext?,
        onBadCertificate: (certificate) => _allowInsecureCertificates,
      );
    } else {
      _socket = await Socket.connect(_host, _port);
    }
    _socket!.setOption(SocketOption.tcpNoDelay, true);
    _pingInterval = pingInterval;
    unawaited(_runPingInterval());
    _sendInitialHandshake();
  } on SocketException catch (error) {
    _onConnectionLost!.complete(error);
  }
}