Agora Java API Reference for Android
Classes | Public Member Functions | List of all members
io.agora.rtm2.IRtmEventHandler Interface Reference

Classes

class  RtmConnectionState
 

Public Member Functions

void onMessageEvent (MessageEvent event)
 
void onPresenceEvent (PresenceEvent event)
 
void onJoinResult (String channelName, String userId, int errorCode)
 
void onLeaveResult (String channelName, String userId, int errorCode)
 
void onJoinTopicResult (String channelName, String userId, String topicName, String meta, int errorCode)
 
void onLeaveTopicResult (String channelName, String userId, String topicName, String meta, int errorCode)
 
void onTopicSubscribed (String channelName, String userId, String topicName, UserList successUsers, UserList failedUsers, int errorCode)
 
void onTopicUnsubscribed (String channelName, String userId, String topicName, UserList successUsers, UserList failedUsers, int errorCode)
 
void onConnectionStateChange (String channelName, int state, int reason)
 

Detailed Description

The IRtmEventHandler class.

The SDK uses this class to send callback event notifications to the app, and the app inherits the methods in this class to retrieve these event notifications.

All methods in this class have their default (empty) implementations, and the app can inherit only some of the required events instead of all. In the callback methods, the app should avoid time-consuming tasks or calling blocking APIs, otherwise the SDK may not work properly.

Member Function Documentation

◆ onMessageEvent()

void io.agora.rtm2.IRtmEventHandler.onMessageEvent ( MessageEvent  event)

Occurs when receive a message.

Parameters
eventdetails of message event.

◆ onPresenceEvent()

void io.agora.rtm2.IRtmEventHandler.onPresenceEvent ( PresenceEvent  event)

Occurs when remote user join/leave channel, join/leave topic or local user joined channel.

note: When remote user join/leave channel will trigger this callback. When remote user(in same channel) joinTopic/destroy Topic will trigger this callback. When local user join channel will trigger this callback.

For type(RTM_PRESENCE_TYPE_REMOTE_JOIN_CHANNEL/RTM_PRESENCE_TYPE_REMOTE_LEAVE_CHANNEL), valid field will be channelType/type/channelName/userId For type(RTM_PRESENCE_TYPE_REMOTE_JOIN_TOPIC/RTM_PRESENCE_TYPE_REMOTE_LEAVE_TOPIC) valid field will be channelType/type/channelName/topicInfos/topicInfoNumber For type(RTM_PRESENCE_TYPE_SELF_JOIN_CHANNEL) valid field will be channelType/type/channelName/topicInfos/topicInfoNumber/userId

Parameters
eventdetails of presence event.

◆ onJoinResult()

void io.agora.rtm2.IRtmEventHandler.onJoinResult ( String  channelName,
String  userId,
int  errorCode 
)

Occurs when user join a channel.

Parameters
channelNameThe Name of the channel.
userIdThe id of the user.
errorCodeThe error code.

◆ onLeaveResult()

void io.agora.rtm2.IRtmEventHandler.onLeaveResult ( String  channelName,
String  userId,
int  errorCode 
)

Occurs when user leave a channel.

Parameters
channelNameThe Name of the channel.
userIdThe id of the user.
errorCodeThe error code.

◆ onJoinTopicResult()

void io.agora.rtm2.IRtmEventHandler.onJoinTopicResult ( String  channelName,
String  userId,
String  topicName,
String  meta,
int  errorCode 
)

Occurs when user join topic.

Parameters
channelNameThe Name of the channel.
userIdThe id of the user.
topicNameThe name of the topic.
metaThe meta of the topic.
errorCodeThe error code.

◆ onLeaveTopicResult()

void io.agora.rtm2.IRtmEventHandler.onLeaveTopicResult ( String  channelName,
String  userId,
String  topicName,
String  meta,
int  errorCode 
)

Occurs when user leave topic.

Parameters
channelNameThe Name of the channel.
userIdThe id of the user.
topicNameThe name of the topic.
metaThe meta of the topic.
errorCodeThe error code.

◆ onTopicSubscribed()

void io.agora.rtm2.IRtmEventHandler.onTopicSubscribed ( String  channelName,
String  userId,
String  topicName,
UserList  successUsers,
UserList  failedUsers,
int  errorCode 
)

Occurs when user subscribed topic.

Parameters
channelNameThe Name of the channel.
userIdThe id of the user.
topicNameThe name of the topic.
succeedUsersThe subscribed users.
failedUserThe failed to subscribe users.
errorCodeThe error code.

◆ onTopicUnsubscribed()

void io.agora.rtm2.IRtmEventHandler.onTopicUnsubscribed ( String  channelName,
String  userId,
String  topicName,
UserList  successUsers,
UserList  failedUsers,
int  errorCode 
)

Occurs when user unsubscribed topic.

Parameters
channelNameThe Name of the channel.
userIdThe id of the user.
topicNameThe name of the topic.
succeedUsersThe unsubscribed users.
failedUserThe failed to unsubscribe users.
errorCodeThe error code.

◆ onConnectionStateChange()

void io.agora.rtm2.IRtmEventHandler.onConnectionStateChange ( String  channelName,
int  state,
int  reason 
)

Occurs when the connection state changes between rtm sdk and agora server.

Parameters
channelNameThe Name of the channel.
stateThe new connection state.
reasonThe reason for the connection state change.