Class IRtmClientAbstract

The IRtmClient class.

This class provides the main methods that can be invoked by your app.

IRtmClient is the basic interface class of the Agora RTM SDK. Creating an IRtmClient object and then calling the methods of this object enables you to use Agora RTM SDK's functionality.

Hierarchy

  • IRtmClient

Constructors

Methods

  • Adds one IRtmClientEvent listener. After calling this method, you can listen for the corresponding events in the IRtcEngine object and obtain data through IRtmClientEvent. Depending on your project needs, you can add multiple listeners for the same event.

    Type Parameters

    Parameters

    • eventType: EventType

      The name of the target event to listen for. See IRtmClientEvent.

    • listener: IRtmEventHandler[EventType]

      The callback function for eventType. Take adding a listener for onTopicEvent as an example: // Create an onTopicEvent object const onTopicEvent = (connection: RtcConnection, elapsed: number) => {}; // Add one onTopicEvent listener engine.addEventListener('onTopicEvent', onTopicEvent);

    Returns void

  • Initializes the rtm client instance.

    Parameters

    Returns number

    • 0: Success.
    • < 0: Failure.
  • Login the Agora RTM service. The operation result will be notified by \ref agora::rtm::IRtmEventHandler::onLoginResult callback.

    Parameters

    • token: string

    Returns number

    • 0: Success.
    • < 0: Failure.
  • Logout the Agora RTM service. Be noticed that this method will break the rtm service including storage/lock/presence.

    Returns number

    • 0: Success.
    • < 0: Failure.
  • Publish a message in the channel.

    Parameters

    • channelName: string
    • message: string
    • length: number
    • option: PublishOptions
    • Optional requestId: number

    Returns number

    • 0: Success.
    • < 0: Failure.
  • Parameters

    • channelName: string
    • message: Uint8Array
    • length: number
    • option: PublishOptions
    • Optional requestId: number

    Returns number

  • Release the rtm client instance.

    Returns number

    • 0: Success.
    • < 0: Failure.
  • Removes all listeners for the specified event.

    Type Parameters

    Parameters

    • Optional eventType: EventType

      The name of the target event to listen for. See IRtmClientEvent.

    Returns void

  • Removes the specified IRtmClientEvent listener. For listened events, if you no longer need to receive the callback message, you can call this method to remove the corresponding listener.

    Type Parameters

    Parameters

    • eventType: EventType

      The name of the target event to listen for. See IRtmClientEvent.

    • Optional listener: IRtmEventHandler[EventType]

      The callback function for eventType. Must pass in the same function object in addEventListener . Take removing the listener for onTopicEvent as an example: // Create an onTopicEvent object const onTopicEvent = (connection: RtcConnection, elapsed: number) => {}; // Add one onTopicEvent listener engine.addEventListener('onTopicEvent', onTopicEvent); // Remove the onTopicEvent listener engine.removeEventListener('onTopicEvent', onTopicEvent);

    Returns void

  • Renews the token. Once a token is enabled and used, it expires after a certain period of time. You should generate a new token on your server, call this method to renew it.

    Parameters

    • token: string

    Returns number

  • Set parameters of the sdk or engine

    Parameters

    • parameters: string

    Returns number

    • 0: Success.
    • < 0: Failure.
  • Subscribe a channel.

    Parameters

    Returns number

    • 0: Success.
    • < 0: Failure.
  • Unsubscribe a channel.

    Parameters

    • channelName: string

    Returns number

    • 0: Success.
    • < 0: Failure.