disconnect static method

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

will disable 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 disables , you will stop receiving all the real-time events for the logged in user

Implementation

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