connect static method

Future<Null> connect({
  1. dynamic onSuccess(
    1. String successMessage
    )?,
  2. dynamic onError(
    1. CometChatException e
    )?,
})

will establish the Web-socket connections manually

While calling the init() function on the app startup, need to inform the SDK that you will be managing the web socket connect from autoEstablishSocketConnection.

Once the connection is established, you will start receiving all the real-time events for the logged in user

Implementation

static Future<Null> connect(
    {Function(String successMessage)? onSuccess,
    Function(CometChatException e)? onError}) async {
  try {
    if (onSuccess != null && onError != null) {
      final result = await channel.invokeMethod('connectNew', null);
      onSuccess(result);
    } else {
      await channel.invokeMethod('connect', {});
    }
  } on PlatformException catch (p) {
    _errorCallbackHandler(null, p, null, onError);
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
  }
}