Agora Java API Reference for Android
Public Member Functions | List of all members
agora::rtm::IRtmService Class Referenceabstract

#include <IAgoraRtmService.h>

Public Member Functions

virtual int initialize (const char *appId, IRtmServiceEventHandler *eventHandler)=0
 
virtual void unregisterObserver (IRtmServiceEventHandler *eventHandler)=0
 
virtual int release (bool sync=false)=0
 
virtual int login (const char *token, const char *userId)=0
 
virtual int logout ()=0
 
virtual int sendMessageToPeer (const char *peerId, const IMessage *message)=0
 
virtual IChannelcreateChannel (const char *channelId, IChannelEventHandler *eventHandler)=0
 

Detailed Description

The IRtmService class.

Member Function Documentation

◆ initialize()

virtual int agora::rtm::IRtmService::initialize ( const char *  appId,
IRtmServiceEventHandler eventHandler 
)
pure virtual

Creates and gets an IRtmService instance.

Parameters
appIdThe pointer to the app ID.
eventHandlerThe pointer to the IRtmServiceEventHandler object.
eventSpaceThe connection specific ID, used during report to argus.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unregisterObserver()

virtual void agora::rtm::IRtmService::unregisterObserver ( IRtmServiceEventHandler eventHandler)
pure virtual

Releases the IRtmServiceEventHandler object.

Parameters
eventHandlerThe pointer to the IRtmServiceEventHandler object.

◆ release()

virtual int agora::rtm::IRtmService::release ( bool  sync = false)
pure virtual

Releases the IRtmService instance.

Parameters
syncDetermines whether to report the result of this method call synchronously.
  • true: Report the result of this method call after the IRtmService instance is released.
  • false: (Default) Report the result of this method call immediately, even when the IRtmService is not released.
Returns
  • 0: Success.
  • < 0: Failure.

◆ login()

virtual int agora::rtm::IRtmService::login ( const char *  token,
const char *  userId 
)
pure virtual

Logs in the RTM service.

Note
  • If you login with the same user ID from a different instance, your previous login will be kicked.
  • The call frequency limit of this method is 2 queries per second.
Parameters
tokenThe token used to log in the RTM service.
userIdID of the user logging in the RTM service.
Returns
  • 0: Success.
  • < 0: Failure.

◆ logout()

virtual int agora::rtm::IRtmService::logout ( )
pure virtual

Logs out of the RTM service.

Returns
  • 0: Success.
  • < 0: Failure.

◆ sendMessageToPeer()

virtual int agora::rtm::IRtmService::sendMessageToPeer ( const char *  peerId,
const IMessage message 
)
pure virtual

Sends a peer message to a specified remote user.

Parameters
peerIdThe pointer to the ID of the remote user.
messageThe pointer to message: IMessage.
Returns
  • 0: Success.
  • < 0: Failure.

◆ createChannel()

virtual IChannel* agora::rtm::IRtmService::createChannel ( const char *  channelId,
IChannelEventHandler eventHandler 
)
pure virtual

Creates an RTM channel.

Parameters
channelIdThe unique channel name for an RTM session. Supported character scopes are:
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • The space character.
  • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ","
eventHandlerThe pointer to IChannelEventHandler.
Returns
  • The pointer to an IChannel instance, if the method call succeeds.
  • An empty pointer NULL, if the method call fails.