connect method

Stream<Session> connect({
  1. ClientConnectOptions? options,
})

Calling this method will start the authentication process and result into a Session object on success. If a pingInterval is given and the underlying transport supports sending of ping messages. the given duration is used by the transport to send ping messages every pingInterval. SocketTransport and WebSocketTransport not within the browser support ping messages. The browser API does not allow to control ping messages. If reconnectCount and the reconnectTime is set the client will try to reestablish the session. Setting reconnectCount to -1 will infinite times reconnect the client or until the stack overflows

Implementation

Stream<Session> connect({ClientConnectOptions? options}) {
  options ??= ClientConnectOptions();

  _changeState(_ClientState.waiting);

  /// Increment reconnectCount by 1 because we use one for initial connect
  options.reconnectCount =
      options.reconnectCount == -1 ? -1 : options.reconnectCount + 1;
  _connectStreamController.add(options);

  return _controller.stream;
}