Agora Java API Reference for Android
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
io.agora.rtm.RtmClient Class Referenceabstract

Public Member Functions

abstract void addEventListener (RtmEventListener listener)
 
abstract void removeEventListener (RtmEventListener listener)
 
abstract void login (String token, ResultCallback< Void > resultCallback)
 
abstract void logout (ResultCallback< Void > resultCallback)
 
abstract RtmStorage getStorage ()
 
abstract RtmLock getLock ()
 
abstract RtmPresence getPresence ()
 
abstract RtmHistory getHistory ()
 
abstract String getErrorReason (RtmErrorCode errorCode)
 
abstract void renewToken (String token, ResultCallback< Void > resultCallback)
 
abstract void publish (String channelName, String message, PublishOptions options, ResultCallback< Void > resultCallback)
 
abstract void publish (String channelName, byte[] message, PublishOptions options, ResultCallback< Void > resultCallback)
 
abstract void subscribe (String channelName, SubscribeOptions options, ResultCallback< Void > resultCallback)
 
abstract void unsubscribe (String channelName, ResultCallback< Void > resultCallback)
 
abstract RtmErrorCode setParameters (String parameters)
 
abstract StreamChannel createStreamChannel (String channelName) throws Exception
 

Static Public Member Functions

static synchronized RtmClient create (RtmConfig config) throws Exception
 
static synchronized RtmClient getInstance ()
 
static synchronized void release ()
 
static String getVersion ()
 

Protected Member Functions

abstract RtmErrorCode initialize (RtmConfig config)
 
abstract RtmErrorCode releaseClient ()
 

Detailed Description

The RtmClient class.

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

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

Member Function Documentation

◆ create()

static synchronized RtmClient io.agora.rtm.RtmClient.create ( RtmConfig  config) throws Exception
static

Create rtm client instance.

Returns
If the method call succeeds, will return
RtmClient
instance, if the method call fails, will throw an exception.
Exceptions
Iferror occurs

◆ getInstance()

static synchronized RtmClient io.agora.rtm.RtmClient.getInstance ( )
static

Get rtm client instance.

Returns
The instance of RtmClient RtmClient.

◆ release()

static synchronized void io.agora.rtm.RtmClient.release ( )
static

Release the rtm client instance.

◆ getVersion()

static String io.agora.rtm.RtmClient.getVersion ( )
static

Get the version info of the Agora RTM SDK.

Returns
The version info of the Agora RTM SDK.

◆ addEventListener()

abstract void io.agora.rtm.RtmClient.addEventListener ( RtmEventListener  listener)
abstract

Adds an event listener for receiving rtm events.

Note: The listener must implement the RtmEventListener interface or use RtmEventListener default implements if do not care about some event.

Parameters
listenerthe RtmEventListener object to be added

◆ removeEventListener()

abstract void io.agora.rtm.RtmClient.removeEventListener ( RtmEventListener  listener)
abstract

Remove the specified event listener.

Note: By removing the event listener, the listener will no longer receive notifications from rtm client.

Parameters
listenerThe event specified listener object

◆ login()

abstract void io.agora.rtm.RtmClient.login ( String  token,
ResultCallback< Void >  resultCallback 
)
abstract

Login the Agora RTM service.

Parameters
tokenToken used to login RTM service.
resultCallbackA ResultCallback object.

◆ logout()

abstract void io.agora.rtm.RtmClient.logout ( ResultCallback< Void >  resultCallback)
abstract

Logout the Agora RTM service.

Parameters
resultCallbackA ResultCallback object.

◆ getStorage()

abstract RtmStorage io.agora.rtm.RtmClient.getStorage ( )
abstract

Get the storage instance.

Returns
The instance of RtmStorage

◆ getLock()

abstract RtmLock io.agora.rtm.RtmClient.getLock ( )
abstract

Get the lock instance.

Returns
The instance of RtmLock

◆ getPresence()

abstract RtmPresence io.agora.rtm.RtmClient.getPresence ( )
abstract

Get the presence instance.

Returns
The instance of RtmPresence

◆ getHistory()

abstract RtmHistory io.agora.rtm.RtmClient.getHistory ( )
abstract

Get the history instance.

Returns
The instance of RtmHistory

◆ getErrorReason()

abstract String io.agora.rtm.RtmClient.getErrorReason ( RtmErrorCode  errorCode)
abstract

Convert error code to error string.

Parameters
errorCodeReceived error code
Returns
The error reason

◆ renewToken()

abstract void io.agora.rtm.RtmClient.renewToken ( String  token,
ResultCallback< Void >  resultCallback 
)
abstract

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
tokenThe new token
resultCallbackA ResultCallback object.

◆ publish() [1/2]

abstract void io.agora.rtm.RtmClient.publish ( String  channelName,
String  message,
PublishOptions  options,
ResultCallback< Void >  resultCallback 
)
abstract

Publish a string message in the channel.

Parameters
channelNameThe name of the channel.
messageThe content of the string message.
optionsThe options of the message.
resultCallbackA ResultCallback object.

◆ publish() [2/2]

abstract void io.agora.rtm.RtmClient.publish ( String  channelName,
byte[]  message,
PublishOptions  options,
ResultCallback< Void >  resultCallback 
)
abstract

Publish a binary message in the channel.

Parameters
channelNameThe name of the channel.
messageThe content of the string message.
optionsThe options of the message.
resultCallbackA ResultCallback object.

◆ subscribe()

abstract void io.agora.rtm.RtmClient.subscribe ( String  channelName,
SubscribeOptions  options,
ResultCallback< Void >  resultCallback 
)
abstract

Subscribe a channel.

Parameters
channelNameThe name of the channel.
optionsThe options of subscribe the channel.
resultCallbackA ResultCallback object.

◆ unsubscribe()

abstract void io.agora.rtm.RtmClient.unsubscribe ( String  channelName,
ResultCallback< Void >  resultCallback 
)
abstract

Unsubscribe a channel.

Parameters
channelNameThe name of the channel.
resultCallbackA ResultCallback object.

◆ setParameters()

abstract RtmErrorCode io.agora.rtm.RtmClient.setParameters ( String  parameters)
abstract

Set parameters of the sdk or engine

Parameters
parametersThe parameters in json format
Returns
RtmErrorCode

◆ createStreamChannel()

abstract StreamChannel io.agora.rtm.RtmClient.createStreamChannel ( String  channelName) throws Exception
abstract

Create a stream channel instance.

Parameters
channelNameThe Name of the channel.
Returns
If the method call succeeds, will return
StreamChannel
instance, if the method call fails, will throw an exception.
Exceptions
Iferror occurs