Interface ChatConnectEventListener

The connection event listener.

In the case of disconnection in an unstable network environment, the app using the SDK receives the onDisconnected callback.

You do not need to reconnect manually as the chat SDK will handle it automatically.

There are two connection-related callbacks:

  • onConnected: Occurs when the connection is set up.
  • onDisconnected: Occurs when the connection breaks down.

Adds a connection event listener:

let listener = new (class s implements ChatConnectEventListener {
onTokenWillExpire(): void {
chatlog.log('ConnectScreen.onTokenWillExpire');
}
onTokenDidExpire(): void {
chatlog.log('ConnectScreen.onTokenDidExpire');
}
onConnected(): void {
chatlog.log('ConnectScreen.onConnected');
}
onDisconnected(errorCode?: number): void {
chatlog.log('ConnectScreen.onDisconnected', errorCode);
}
})();
ChatClient.getInstance().addConnectionListener(listener);

Removes a connection event listener:

ChatClient.getInstance().removeConnectionListener(listener);
interface ChatConnectEventListener {
    onAppActiveNumberReachLimit?(): void;
    onConnected?(): void;
    onDisconnected?(): void;
    onTokenDidExpire?(): void;
    onTokenWillExpire?(): void;
    onUserAuthenticationFailed?(): void;
    onUserDidChangePassword?(): void;
    onUserDidForbidByServer?(): void;
    onUserDidLoginFromOtherDevice?(deviceName?: string): void;
    onUserDidLoginTooManyDevice?(): void;
    onUserDidRemoveFromServer?(): void;
    onUserKickedByOtherDevice?(): void;
}

Methods

  • The number of daily active users (DAU) or monthly active users (MAU) for the app has reached the upper limit.

    The user is disconnected by the server.

    Returns void

  • Occurs when the SDK connects to the chat server successfully.

    Returns void

  • Occurs when the Agora token has expired.

    Returns void

  • Occurs when the Agora token is about to expire.

    Returns void

  • Occurs when the current chat user authentication failed.

    This callback is triggered in the following typical scenarios: The token expires or token authentication fails.

    The user is disconnected by the server.

    Returns void

  • Occurs when the current chat user changed the password.

    The user is disconnected by the server.

    Returns void

  • Occurs when the current chat user is banned from accessing the server.

    The user is disconnected by the server.

    Returns void

  • Occurs when the current user account is logged in to another device.

    The user is disconnected by the server.

    Parameters

    • OptionaldeviceName: string

    Returns void

  • Occurs when the current chat user logged in to many devices.

    The user is disconnected by the server.

    Returns void

  • Occurs when the current chat user is removed from the server.

    The user is disconnected by the server.

    Returns void

  • Occurs when the current chat user is kicked out of the app by another device.

    The user is disconnected by the server.

    Returns void