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.
Method | Description |
---|---|
createInstance | Creates an RtmClient instance. |
login | Logs in 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 an (offline) 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. Promise<object> returns the result of this method call. |
Method | Description |
---|---|
setLocalUserAttributes | Substitutes the local user's attributes with new ones. Promise<void> returns the result of this method call. |
addOrUpdateLocalUserAttributes | Adds or updates the local user's attribute(s). Promise<void> returns the result of this method call. |
deleteLocalUserAttributesByKeys | Deletes the local user's attributes using attribute keys. Promise<void> returns the result of this method call. |
clearLocalUserAttributes | Clears all attributes of the local user. Promise<void> returns the result of this method call. |
getUserAttributes | Gets all attributes of a specified user. Promise<object> returns the result of this method call. |
getUserAttributesByKeys | Gets the attributes of a specified user by attribute keys. Promise<object> returns the result of this method call. |
Method | Description |
---|---|
setChannelAttributes | Substitutes the attributes of a specified channel with new ones.Promise<void> returns the result of this method call. |
addOrUpdateChannelAttributes | Adds or updates the attribute(s) of a specified channel.Promise<void> returns the result of this method call. |
deleteChannelAttributesByKeys | Deletes the attributes of a specified channel by attribute keys.Promise<void> returns the result of this method call. |
clearChannelAttributes | Clears all attributes of a specified channel.Promise<void> returns the result of this method call. |
getChannelAttributes | Gets all attributes of a specified channel.Promise<object> returns the result of this method call. |
getChannelAttributesByKeys | Gets the attributes of a specified channel by attribute keys. Promise<object> returns the result of this method call. |
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 channel(s). Promise<object> returns the result of this method call. |
Method | Description |
---|---|
createChannel | Creates an RtmChannel instance. |
join | Joins the channel. Promise<void> returns the result of this method call. |
leave | Leaves the channel. Promise<void> returns the result of this method call. |
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. Promise<void> returns the result of this method call. |
Event | Description |
---|---|
ChannelMessage | Occurs when the local user receives a channel message. |
Method | Description |
---|---|
getMembers | Retrieves a member list of the channel. Promise<string[]> returns the result of this method call. |
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. At the same time, the SDK returns a RemoteInvitation object to the callee. |
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. Promise<void> returns the result of this method call. |
Event | Description |
---|---|
TokenExpired | Occurs when the token expires. |
Method | Description |
---|---|
setParameters | Provides the technical preview functionalities or special customizations. See RtmParameters. |