Agora C++ API Reference for All Platforms

Public Member Functions | List of all members
agora::rtm::IRtmService Class Referenceabstract

## Public Member Functions
virtual | ~IRtmService ()
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, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int | logout (aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int | sendMessageToPeer (const char *peerId, const IMessage *message, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual IChannel * | createChannel (const char *channelId, IChannelEventHandler *eventHandler)=0

## Detailed Description

The IRtmService class.

## Constructor & Destructor Documentation

## ◆ ~IRtmService()

virtual agora::rtm::IRtmService::~IRtmService | ( |  | ) |
| inline virtual

## Member Function Documentation

## ◆ initialize()

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

Creates and gets an IRtmService instance.

Parameters

  appId | The pointer to the app ID.
  eventHandler | The pointer to the IRtmServiceEventHandler object.
  eventSpace | The 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

  eventHandler | The pointer to the IRtmServiceEventHandler object.

## ◆ release()

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

Releases the IRtmService instance.

Parameters

  sync | Determines 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,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| 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

  token | The token used to log in the RTM service.
  userId | ID of the user logging in the RTM service.

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ logout()

virtual int agora::rtm::IRtmService::logout | ( | aosl_ref_t | ares = `AOSL_REF_INVALID` | ) |
| 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,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual

Sends a peer message to a specified remote user.

Parameters

  peerId | The pointer to the ID of the remote user.
  message | The 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

  channelId | The 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: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ","
  eventHandler | The pointer to IChannelEventHandler.

Returns
  - The pointer to an IChannel instance, if the method call succeeds.
  - An empty pointer NULL, if the method call fails.