Public Member Functions | |
void | onConnected () |
void | onDisconnected (final int errorCode) |
default void | onTokenExpired () |
default void | onTokenWillExpire () |
default void | onLogout (final int errorCode) |
default void | onLogout (final int errorCode, String info) |
default void | onLogout (final int errorCode, LoginExtensionInfo info) |
default void | onOfflineMessageSyncStart () |
default void | onOfflineMessageSyncFinish () |
The chat connection listener.
Under unstable network conditions, the app receives the onDisconnected callback. In this case, you don't need to reconnect manually as the chat SDK will handle it automatically.
There are two callback methods for connection: onConnected, onDisconnected.
Note: We recommend you not to update the UI based on the two methods, because they are called on the worker thread. If you update the UI in the methods, other UI errors might occur. Also remember not to make the two methods do a lot of time-consuming work, which might invoke other listeners to handle this connection event.
Adds a connection listener: ```java ChatClient.getInstance().addConnectionListener(mConnectionListener); ``` Removes a connection listener: ```java ChatClient.getInstance().removeConnectionListener(mConnectionListener); ```
void io.agora.ConnectionListener.onConnected | ( | ) |
Occurs when the SDK connects to the chat server successfully.
void io.agora.ConnectionListener.onDisconnected | ( | final int | errorCode | ) |
Occurs when the SDK disconnects from the chat server.
Note that the logout may not be performed at the bottom level when the SDK is disconnected.
Common errors are as follows: Error#USER_REMOVED
,Error#USER_LOGIN_ANOTHER_DEVICE
, Error#SERVER_SERVICE_RESTRICTED
,Error#USER_KICKED_BY_CHANGE_PASSWORD
and Error#USER_KICKED_BY_OTHER_DEVICE
default void io.agora.ConnectionListener.onLogout | ( | final int | errorCode | ) |
Occurs when the UNDERLYING SDK logs out.
Common errors are as follows:
Error#USER_LOGIN_ANOTHER_DEVICE
,Error#USER_REMOVED
, Error#USER_BIND_ANOTHER_DEVICE
,Error#SERVER_SERVICE_RESTRICTED
, Error#USER_LOGIN_TOO_MANY_DEVICES
,Error#USER_KICKED_BY_CHANGE_PASSWORD
, Error#USER_KICKED_BY_OTHER_DEVICE
errorCode |
ConnectionListener#onLogout(int, String)
instead。 default void io.agora.ConnectionListener.onLogout | ( | final int | errorCode, |
LoginExtensionInfo | info ) |
Occurs when the UNDERLYING SDK logs out.
Common errors are as follows:
Error#USER_LOGIN_ANOTHER_DEVICE
,Error#USER_REMOVED
, Error#USER_BIND_ANOTHER_DEVICE
,Error#SERVER_SERVICE_RESTRICTED
, Error#USER_LOGIN_TOO_MANY_DEVICES
,Error#USER_KICKED_BY_CHANGE_PASSWORD
, Error#USER_KICKED_BY_OTHER_DEVICE
info | The login extension information Object that contains two parameters: info.deviceExt and info.deviceInfo. |
If errorCode
is Error#USER_LOGIN_ANOTHER_DEVICE
:
deviceInfo
is empty.errorCode | The error code. |
default void io.agora.ConnectionListener.onLogout | ( | final int | errorCode, |
String | info ) |
Occurs when the UNDERLYING SDK logs out.
errorCode | The error code. |
Common errors are as follows:
Error#USER_LOGIN_ANOTHER_DEVICE
,Error#USER_REMOVED
, Error#USER_BIND_ANOTHER_DEVICE
,Error#SERVER_SERVICE_RESTRICTED
, Error#USER_LOGIN_TOO_MANY_DEVICES
,Error#USER_KICKED_BY_CHANGE_PASSWORD
, Error#USER_KICKED_BY_OTHER_DEVICE
info | The error extension information. |
If errorCode
is Error#USER_LOGIN_ANOTHER_DEVICE
, info
is the user-defined name of the device that kicks the current device offline. If the device does not have a custom name, the device model is indicated in the callback by default. In the case of other errors, info
is empty.
default void io.agora.ConnectionListener.onOfflineMessageSyncFinish | ( | ) |
Occurs when the SDK finishes pulling offline messages from the server.
default void io.agora.ConnectionListener.onOfflineMessageSyncStart | ( | ) |
Occurs when the SDK starts pulling offline messages from the server.
default void io.agora.ConnectionListener.onTokenExpired | ( | ) |
Occurs when the token has expired.
The common error is Error#TOKEN_EXPIRED
.
default void io.agora.ConnectionListener.onTokenWillExpire | ( | ) |
Occurs when the token is about to expire.
The common error is Error#TOKEN_WILL_EXPIRE
.