# connect method

Future <Result<bool, XmppError>> connect(

1. {bool? shouldReconnect,
2. bool waitForConnection = false,
3. bool waitUntilLogin = false,
4. bool enableReconnectOnSuccess = true}

)

Start the connection process using the provided connection settings.

`shouldReconnect` indicates whether the reconnection attempts should be automatically performed after a fatal failure of any kind occurs.

`waitForConnection` indicates whether the connection should wait for the "go" signal from a registered connectivity manager.

If `waitUntilLogin` is set to true, the future will resolve when either the connection has been successfully established (authentication included) or a failure occured. If set to false, then the future will immediately resolve to true.

`enableReconnectOnSuccess` indicates that automatic reconnection is to be enabled once the connection has been successfully established.

## Implementation

    Future<Result<bool, XmppError>> connect({
      bool? shouldReconnect,
      bool waitForConnection = false,
      bool waitUntilLogin = false,
      bool enableReconnectOnSuccess = true,
    }) async {
      final result = _connectImpl(
        shouldReconnect: shouldReconnect ?? !waitUntilLogin,
        waitForConnection: waitForConnection,
        waitUntilLogin: waitUntilLogin,
        enableReconnectOnSuccess: enableReconnectOnSuccess,
      );
      if (waitUntilLogin) {
        return result;
      } else {
        return Future.value(
          const Result(
            true,
          ),
        );
      }
    }