connectHandler method

void connectHandler({
  1. VoidCallback? onConnected,
  2. VoidCallback? onDisconnected,
  3. dynamic onUserDidLoginFromOtherDevice(
    1. LoginExtensionInfo
    )?,
  4. VoidCallback? onUserDidRemoveFromServer,
  5. VoidCallback? onUserDidForbidByServer,
  6. VoidCallback? onUserDidChangePassword,
  7. VoidCallback? onUserDidLoginTooManyDevice,
  8. VoidCallback? onUserKickedByOtherDevice,
  9. VoidCallback? onUserAuthenticationFailed,
  10. VoidCallback? onTokenWillExpire,
  11. VoidCallback? onTokenDidExpire,
  12. VoidCallback? onAppActiveNumberReachLimit,
})

Implementation

void connectHandler({
  VoidCallback? onConnected,
  VoidCallback? onDisconnected,
  Function(LoginExtensionInfo)? onUserDidLoginFromOtherDevice,
  VoidCallback? onUserDidRemoveFromServer,
  VoidCallback? onUserDidForbidByServer,
  VoidCallback? onUserDidChangePassword,
  VoidCallback? onUserDidLoginTooManyDevice,
  VoidCallback? onUserKickedByOtherDevice,
  VoidCallback? onUserAuthenticationFailed,
  VoidCallback? onTokenWillExpire,
  VoidCallback? onTokenDidExpire,
  VoidCallback? onAppActiveNumberReachLimit,
}) {
  Client.getInstance.addConnectionEventHandler(
    'chat_sdk_wrapper',
    ConnectionEventHandler(
      onConnected: onConnected,
      onDisconnected: onDisconnected,
      onUserDidLoginFromOtherDevice: onUserDidLoginFromOtherDevice,
      onUserDidRemoveFromServer: onUserDidRemoveFromServer,
      onUserDidForbidByServer: onUserDidForbidByServer,
      onUserDidChangePassword: onUserDidChangePassword,
      onUserDidLoginTooManyDevice: onUserDidLoginTooManyDevice,
      onUserKickedByOtherDevice: onUserKickedByOtherDevice,
      onUserAuthenticationFailed: onUserAuthenticationFailed,
      onTokenWillExpire: onTokenWillExpire,
      onTokenDidExpire: onTokenDidExpire,
      onAppActiveNumberReachLimit: onAppActiveNumberReachLimit,
    ),
  );
  Client.getInstance.userInfoManager
      .fetchOwnInfo()
      .then((value) => null)
      .catchError((e) {
    if (e is ChatError) {
      if (e.code == 401) {
        onUserAuthenticationFailed?.call();
      }
    }
  });
}