The Agora RTM Web SDK is a JavaScript library loaded by an HTML web page. The Agora RTM Web SDK library uses APIs in the web browser to establish real-time messaging services.
AgoraRTM is the exported module of the Agora RTM
SDK. If you import the Agora RTM Web SDK using the <script>
tag,
the SDK creates a global variable called AgoraRTM,
which includes all the module members.
Please use the RtmClient.on and RtmChannel.on methods to add event listeners to the RtmClient and RtmChannel objects.
Following are the core functionalities that the Agora RTM SDK provides.
Method | Description |
---|---|
createInstance | Creates an RtmClient instance. |
login | Logs in to the Agora RTM system. |
logout | Logs out of the Agora RTM system. |
Event | Description |
---|---|
ConnectionStateChanged | Occurs when the connection state between the SDK and the Agora RTM system changes. |
Method | Description |
---|---|
sendMessageToPeer | Sends a peer-to-peer message to a specified user. |
Event | Description |
---|---|
MessageFromPeer | Occurs when receiving a peer-to-peer message. |
Method | Description |
---|---|
queryPeersOnlineStatus | Queries the online status of the specified users. |
Method | Description |
---|---|
subscribePeersOnlineStatus | Subscribes to the online status of the specified users. |
unsubscribePeersOnlineStatus | Unsubscribes from the online status of the specified users. |
queryPeersBySubscriptionOption | Gets a list of the peers, to whose specific status you have subscribed. |
Event | Description |
---|---|
PeersOnlineStatusChanged | Occurs when the online status of the peers, to whom you subscribe, changes. |
Method | Description |
---|---|
subscribePeersOnlineStatus | Subscribes to the online status of the specified users. |
unsubscribePeersOnlineStatus | Unsubscribes from the online status of the specified users. |
queryPeersBySubscriptionOption | Gets a list of the peers, to whose specific status you have subscribed. |
Event | Description |
---|---|
PeersOnlineStatusChanged | Occurs when the online status of the peers, to whom you subscribe, changes. |
Method | Description |
---|---|
setLocalUserAttributes | Resets the local user's attributes. |
addOrUpdateLocalUserAttributes | Adds or updates the local user's attributes. |
deleteLocalUserAttributesByKeys | Deletes the local user's attributes using attribute keys. |
clearLocalUserAttributes | Clears all attributes of the local user. |
getUserAttributes | Gets all attributes of a specified user. |
getUserAttributesByKeys | Gets the attributes of a specified user by attribute keys. |
Method | Description |
---|---|
setChannelAttributes | Resets the attributes of a specified channel. |
addOrUpdateChannelAttributes | Adds or updates the attributes of a specified channel. |
deleteChannelAttributesByKeys | Deletes the attributes of a specified channel by attribute keys. |
clearChannelAttributes | Clears all attributes of a specified channel. |
getChannelAttributes | Gets all attributes of a specified channel. |
getChannelAttributesByKeys | Gets the attributes of a specified channel by attribute keys. |
Event for all channel members | Description |
---|---|
AttributesUpdated | Occurs when the channel attributes are updated, and returns all attributes of the channel. |
Method | Description |
---|---|
getChannelMemberCount |
Gets the member count of specified channels.
|
Method | Description |
---|---|
createMediaMessageByUploading |
Uploads a file or image to the Agora server to get an
RtmFileMessage or RtmImageMessage instance for sending
channel messages and peer-to-peer messages.
|
createMessage | Creates a message instance. For file messages and image messages, if the corresponding files or image files have been uploaded and the media IDs are still valid, you can call this method to get a message instance for sending peer-to-peer or channel messages. |
downloadMedia | Downloads a file or image file from the Agora server by media ID. |
Method | Description |
---|---|
createChannel | Creates an RtmChannel instance. |
join | Joins the channel. |
leave | Leaves the channel. |
Event | Description |
---|---|
MemberJoined | Occurs when a remote user joins the channel. |
MemberLeft | Occurs when a remote member leaves the channel. |
MemberCountUpdated | Occurs when the number of the channel members changes, and returns the new number. |
Method | Description |
---|---|
sendMessage | Allows a channel member to send a message to all members in the channel. |
Event | Description |
---|---|
ChannelMessage | Occurs when the local user receives a channel message. |
Method | Description |
---|---|
getMembers | Retrieves a member list of the current channel. |
Caller Method | Description |
---|---|
createLocalInvitation | Allows the caller to create a LocalInvitation instance. |
send | Allows the caller to send a call invitation to a remote user. |
cancel | Allows the caller to cancel a call invitation. |
Callee Method | Description |
---|---|
accept | Allows the callee to accept a call invitation. |
refuse | Allows the callee to refuse a call invitation. |
Caller Event | Description |
---|---|
LocalInvitationReceivedByPeer | Callback to the caller: occurs when the callee receives the call invitation. |
LocalInvitationCanceled | Callback to the caller: occurs when the caller cancels an outgoing call invitation. |
LocalInvitationAccepted | Callback to the caller: occurs when the callee accepts the call invitation. |
LocalInvitationRefused | Callback to the caller: occurs when the callee declines the call invitation. |
LocalInvitationFailure | Callback to the caller: occurs when the life cycle of an outgoing call invitation ends in failure. |
Callee Event | Description |
---|---|
RemoteInvitationReceived | Callback to the callee: occurs when the callee receives a call invitation. |
RemoteInvitationCanceled | Callback to the callee: occurs when the callee receives a call invitation. |
RemoteInvitationAccepted | Callback to the callee: occurs when the callee accepts a call invitation. |
RemoteInvitationRefused | Callback to the callee: occurs when the callee declines a call invitation. |
RemoteInvitationFailure | Callback to the callee: occurs when the life cycle of the incoming call invitation ends in failure. |
Method | Description |
---|---|
renewToken | Renews the current token. |
Event | Description |
---|---|
TokenExpired | Occurs when the token expires. |
Variable | Description |
---|---|
enableLogUpload | Determines whether to enable log upload. |
logFilter | Sets the output log level of the SDK. |
VERSION | Version of the Agora RTM SDK. |
Method | Description |
---|---|
updateConfig |
Modifies the RtmClient instance configuration. The changes take
effect immediately.
|