Chat SDK for Android v1.2.1
agora java chat SDK
Public Member Functions | List of all members
io.agora.ConnectionListener Interface Reference

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)
 

Detailed Description

The chat connection listener.

For the occasion of onDisconnected during unstable network condition, you don't need to reconnect manually, the chat SDK will handle it automatically.

There are only two states: onConnected, onDisconnected.

Note: We recommend not to update UI based on those methods, because this method is called on worker thread. If you update UI in those methods, other UI errors might be invoked. Also do not insert heavy computation work here, which might invoke other listeners to handle this connection event.

Register:
```java
ChatClient.getInstance().addConnectionListener(mConnectionListener);
```

Unregister:
```java
ChatClient.getInstance().removeConnectionListener(mConnectionListener);
```

Member Function Documentation

◆ onConnected()

void io.agora.ConnectionListener.onConnected ( )

Occurs when the SDK connects to the chat server successfully.

◆ onDisconnected()

void io.agora.ConnectionListener.onDisconnected ( final int  errorCode)

Occurs when the SDK disconnect 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

◆ onLogout() [1/2]

default void io.agora.ConnectionListener.onLogout ( final int  errorCode)

◆ onLogout() [2/2]

default void io.agora.ConnectionListener.onLogout ( final int  errorCode,
String  info 
)

Occurs when the UNDERLYING SDK logs out.

Parameters
errorCodeerror code . Common errors are as follows: Error#USER_LOGIN_ANOTHER_DEVICEError#USER_REMOVEDError#USER_BIND_ANOTHER_DEVICEError#SERVER_SERVICE_RESTRICTEDError#USER_LOGIN_TOO_MANY_DEVICESError#USER_KICKED_BY_CHANGE_PASSWORDError#USER_KICKED_BY_OTHER_DEVICE
infoerror extend info . If errorCode is Error#USER_LOGIN_ANOTHER_DEVICE, info is the user-defined device name of the peer that kicks or squeeches the current device. If the peer device does not have a user-defined device name, the device name of the peer device is called back by default.In other error code scenarios, info is empty.

◆ onTokenExpired()

default void io.agora.ConnectionListener.onTokenExpired ( )

Occurs when the token has expired.

Common errors are as follows: Error#TOKEN_EXPIRED,Error#TOKEN_WILL_EXPIRE,

◆ onTokenWillExpire()

default void io.agora.ConnectionListener.onTokenWillExpire ( )

Occurs when the token is about to expire.


The documentation for this interface was generated from the following file: