Public Member Functions | |
| void | onConnected () |
| void | onDisconnected (final int errorCode) |
| default void | onDatabaseOpened (String username) |
| default void | onTokenExpired () |
| default void | onTokenWillExpire () |
| default void | onLogout (final int errorCode, EMLoginExtensionInfo info) |
| default void | onOfflineMessageSyncStart () |
| default void | onOfflineMessageSyncFinish () |
| default void | onDataSyncStart (EMOptions.EMDataSyncType type) |
| default void | onDataSyncFinish (EMOptions.EMDataSyncType type, int errorCode) |
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 EMClient.getInstance().addConnectionListener(mConnectionListener); ``` Removes a connection listener: ```java EMClient.getInstance().removeConnectionListener(mConnectionListener); ```
| void com.hyphenate.EMConnectionListener.onConnected | ( | ) |
Occurs when the SDK connects to the chat server successfully.
| default void com.hyphenate.EMConnectionListener.onDatabaseOpened | ( | String | username | ) |
Occurs when the local database is opened successfully.
This callback only indicates that the local database for the specified user is available. It does not indicate an online login success and does not replace onConnected().
| username | The user ID that owns the opened database. |
| default void com.hyphenate.EMConnectionListener.onDataSyncFinish | ( | EMOptions.EMDataSyncType | type, |
| int | errorCode ) |
Occurs when automatic data sync finishes after login.
| type | The data sync type:
|
| errorCode | The error code. EMError#EM_NO_ERROR means success. |
| default void com.hyphenate.EMConnectionListener.onDataSyncStart | ( | EMOptions.EMDataSyncType | type | ) |
Occurs when automatic data sync starts after login.
| type | The data sync type:
|
| void com.hyphenate.EMConnectionListener.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: EMError#USER_REMOVED,EMError#USER_LOGIN_ANOTHER_DEVICE, EMError#SERVER_SERVICE_RESTRICTED,EMError#USER_KICKED_BY_CHANGE_PASSWORD and EMError#USER_KICKED_BY_OTHER_DEVICE
| default void com.hyphenate.EMConnectionListener.onLogout | ( | final int | errorCode, |
| EMLoginExtensionInfo | info ) |
Occurs when the UNDERLYING SDK logs out.
Common errors are as follows:
EMError#USER_LOGIN_ANOTHER_DEVICE,EMError#USER_REMOVED, EMError#USER_BIND_ANOTHER_DEVICE,EMError#SERVER_SERVICE_RESTRICTED, EMError#USER_LOGIN_TOO_MANY_DEVICES,EMError#USER_KICKED_BY_CHANGE_PASSWORD, EMError#USER_KICKED_BY_OTHER_DEVICE
| info | The login extension information Object that contains two parameters: info.deviceExt and info.deviceInfo. |
If errorCode is EMError#USER_LOGIN_ANOTHER_DEVICE:
deviceInfo is empty.| errorCode | The error code. |
| default void com.hyphenate.EMConnectionListener.onOfflineMessageSyncFinish | ( | ) |
Occurs when the SDK finishes pulling offline messages from the server.
| default void com.hyphenate.EMConnectionListener.onOfflineMessageSyncStart | ( | ) |
Occurs when the SDK starts pulling offline messages from the server.
| default void com.hyphenate.EMConnectionListener.onTokenExpired | ( | ) |
Occurs when the token has expired.
The common error is EMError#TOKEN_EXPIRED.
| default void com.hyphenate.EMConnectionListener.onTokenWillExpire | ( | ) |
Occurs when the token is about to expire.
The common error is EMError#TOKEN_WILL_EXPIRE.