Unity

Updated

API reference for the Agora Signaling Unity SDK.

The Signaling SDK API reference is divided into the following sections:

Setup

The API reference for the Signaling SDK documents interface descriptions, methods, basic usage, and return values of the Signaling APIs.

Before initializing the Signaling client instance, you need to import the Signaling SDK as follows:

  1. Download the latest Signaling Unity SDK.
  2. In Unity, click Assets > Import Package > Custom Package to import the SDK.
  3. In your script file, add the following to the list of namespace declarations:
  using Agora.Rtm;

CreateAgoraRtmClient

Description

Create and initialize the Signaling client instance. You need to provide appId and userId parameters, and you can get the App ID when you create an Agora project in the Agora Console.

Information


- Create and initialize the client instance before calling other Signaling APIs.
- To distinguish each user and device, you need to ensure that the userId parameter is globally unique, and remains the same for the lifetime of the user or device.

Method

Call the CreateAgoraRtmClient method as follows:

IRtmClient CreateAgoraRtmClient(RtmConfig config);
PropertiesTypeRequiredDefaultDescription
configRtmConfigRequired-Configuration parameters for initializing the Signaling client instance. See RtmConfig.

Basic usage

RtmConfig config = new RtmConfig();
// get the appId from your Agora console
config.appId = "my_appId";
// user ID to be used as a device identifier
config.userId ="Tony";
// set Presence Timeout
config.presenceTimeout = 30;
// it is recommended to use the Try-catch pattern to catch initialization errors
try
{
    rtmClient = RtmClient.CreateAgoraRtmClient(config);
}
catch (RTMException e)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode : {1}, due to: {2}", e.Status.Operation , e.Status.ErrorCode , e.Status.Reason));
}

Return value

The SDK returns the IRtmClient instance,for subsequent calls of other Signaling APIs.

RtmConfig

Description

Use the RtmConfig instance to set the configuration parameters of the Signaling client. These configuration parameters take effect throughout the lifecycle of the Signaling client and affect the behavior of the Signaling client.

Method

Create the RtmConfig instance as follows:

new RtmConfig()
PropertiesTypeRequiredDefaultDescription
appIdstringRequired-App ID obtained when creating a project in the Agora Console.
userIdstringRequired-User ID for identify a user or a device. To distinguish each user or device, you need to ensure that the userId parameter is globally unique and remains unchanged throughout the user or device's lifecycle.
areaCodeRTM_AREA_CODEOptionalGLOBService area code, you can choose according to the region where your business is deployed. See RTM_AREA_CODE.
presenceTimeoutUInt32Optional300Presence timeout in seconds, and the value range is [10,300].
useStringUserIdBoolOptionaltrueWhether to use string-type user IDs:
- true: Use string-type user IDs.
- false: Use number-type user IDs. The SDK automatically converts string-type user IDs to number-type ones. In this case, the userId parameter must be a numeric string (for example, "123456"), otherwise initialization fails.When using Agora RTC and Signaling products at the same time, it is necessary to ensure that the userId parameter is consistent.
logConfigRtmLogConfigOptional-Log configuration properties such as the log storage size, storage path, and level.
eventListenerRtmEventListenerRequired-Signaling event notification listener settings. See Event listeners.
proxyConfigRtmProxyConfigOptional-When using the Proxy feature of Signaling, you need to configure this parameter.
encryptionConfigRtmEncryptionConfigOptional-When using the client-side encryption feature of Signaling, you need to configure this parameter.
RtmLogConfig

Use the RtmLogConfig instance to configure and store local log files named agora.log. During the debugging phase, you can greatly improve efficiency by storing and tracking the running status of the app through logs. If you encounter complex problems and need Agora technical support to assist with the investigation, you need to provide the log information. The RtmLogConfig data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
filePathstringOptional-Log file storage paths.
fileSizeInKBuintOptional1024Log file size in KB, with a value range of [128,1024].
- If the value you enter is less than 128, the SDK sets the value to 128.
- If the value you enter is greater than 1024, the SDK sets the value to 1024.
levelRTM_LOG_LEVELOptionalINFOOutput level of log information. See RTM_LOG_LEVEL.
RtmProxyConfig

Use the RtmProxyConfig instance to set properties related to the client Proxy service. In some restricted network environments, you might need to use this feature.

Caution

You need to keep your Proxy username and password safe. The Signaling SDK does not parse, store, or forward your username and password in any way. In addition, if you modify the Proxy settings during the app running process, the settings will take effect only after restarting the Signaling client.

The RtmProxyConfig data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
proxyTypeRTM_PROXY_TYPEOptionalNONEProxy protocol type. See RTM_PROXY_TYPE.
serverstringOptional-Proxy server domain name or IP address.
portUInt16Optional-Proxy listening port.
accountstringOptional-Proxy login account.
passwordstringOptional-Proxy login password.
RtmEncryptionConfig

Use the RtmEncryptionConfig instance to set the properties required for the client-side encryption. After successfully setting encryption modes, encryption keys, and other related properties, the SDK automatically encrypts and decrypts all messages sent or all statuses set by the user on the client side.

Information

Once you set the encryption feature, all users must use the same encryption mode and key, otherwise users cannot communicate with each other.

The RtmEncryptionConfig data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
encryptionModeRTM_ENCRYPTION_MODEOptionalNONEEncryption mode. See RTM_ENCRYPTION_MODE.
encryptionKeystringOptional-User-defined encryption key, unlimited length. Agora recommends using a 32-byte key.
encryptionKdfSaltbyte[32]OptionalnullUser-defined encryption salt, length is 32 bytes. Agora recommends using OpenSSL to generate salt on the server side.

Basic usage

// Create an RtmConfig instance
RtmConfig config = new RtmConfig();
// get the appId from your Agora console
config.appId = "my_appId";
// user ID to be used as a device identifier
config.userId ="Tony";
// set Presence Timeout
config.presenceTimeout = 30;

// Create a LogConfig instance.
LogConfig logConfig = new LogConfig()
// set log file path.
logConfig.filePath = "./logfile/";
// set agore.log file size.
logConfig.fileSizeInKB = 512;
// set log report level.
logConfig.level = LOG_LEVEL.INFO;
// initialize logconfig
config.logConfig = logConfig;

// Create an RtmProxyConfig instance.
RtmProxyConfig proxyConfig = new RtmProxyConfig()
// set proxy type as HTTP.
proxyConfig.proxyType = RTM_PROXY_TYPE.HTTP;
// set your Proxy Server address.
proxyConfig.server = "192.168.11.101";
// set your listener port.
proxyConfig.port = 8080;
// set your proxy account
proxyConfig.account = "Tony";
// set your proxy password
proxyConfig.password = "my_password"
// initialize proxyConfig
config.proxy = proxyConfig;

// Create an RtmEncryptionConfig instance.
RtmEncryptionConfig encryptionConfig = new RtmEncryptionConfig()
// set encryption Mode as RTM_ENCRYPTION_MODE_AES_128_GCM.
encryptionConfig.encryptionMode = RTM_ENCRYPTION_MODE.AES_128_GCM;
// set your cipherKey, you must keep your cipherKey safety.
encryptionConfig.encryptionKey = "your_cerpherKey";
// set your Salt.
encryptionConfig.encryptionKdfSalt = "yourSalt";
// when you set the config.encryptionConfig  parameter. the end-to-end encryption will be turned on automatically
config.encryptionConfig = encryptionConfig;

// it is recommended to use the Try-catch pattern to catch initialization errors
try
{
    rtmClient = RtmClient.CreateAgoraRtmClient(config);
}
catch (RTMException e)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode : {1}, due to: {2}", e.Status.Operation , e.Status.ErrorCode , e.Status.Reason));
}

Return value

The SDK returns the RtmConfig instance.

Event Listeners

Description

IRtmClient Signaling client instance

Signaling has a total of 7 types of event notifications, as shown in the following table:

Event TypeDescription
OnMessageEventReceive message event notifications in subscribed message channels and subscribed topics.
OnPresenceEventReceive presence event notifications in subscribed message channels and joined stream channels.
OnTopicEventReceive all topic event notifications in joined stream channels.
OnStorageEventReceive channel metadata event notifications in subscribed message channels and joined stream channels, and the user metadata event notification of the subscribed users.
OnLockEventReceive lock event notifications in subscribed message channels and joined stream channels.
OnConnectionStateChangedReceive event notifications when client connection status changes. For details, see RTM_CONNECTION_STATE and RTM_CONNECTION_CHANGE_REASON.
OnTokenPrivilegeWillExpireReceive event notifications when the client tokens are about to expire.

Add event listeners

You can add event listeners as follows:

// add message event listener
rtmClient.OnMessageEvent += ( MessageEvent event ) =>
{
    var channelName = event.channelName;
    var channelType = event.channelType;
    var topic = event.channelTopic;
    var publisher = event.publiser;
    var messageType = event.messageType;
    var message = event.message;
    var customType = event.customType;
    Debug.Log(string.Format("Received Message {0} from userId:{1} at channel:{2} with channel type of {3}. ", message, publisher , channelName, channelType));
    if (message != null)
    {
        // your logic
    }
};

// add presence event listener
rtmClient.OnPresenceEvent += ( PresenceEvent event ) =>
{
    var channelName = event.channelName;
    var channelType = event.channelType;
    var eventType = event.type;
    var publisher = event.publiser;
    var stateItems = event.stateItems;
    var interval = event.interval;
    var snapshot = event.snapshot;
    Debug.Log(string.Format("Received presence Event {0} from userId:{1} at channel:{2} with channel type of {3}. ", eventType, publisher , channelName, channelType));
}

// add topic event listener
rtmClient.OnTopicEvent += ( TopicEvent event ) =>
{
    var channelName = event.channelName;
    var eventType = event.type;
    var publisher = event.publisher;
    var topicInfos = event.topicInfos;
    Debug.Log(string.Format("Received topic event {0} from userId:{1} at channel:{2} with channel type of {3}. ", eventType, publisher , channelName, channelType));
    if (topicInfos != null)
    {
        // your logic
    }
}

// add storage event listener
rtmClient.OnStorageEvent += ( StorageEvent event ) =>
{
    var channelName = event.channelName;
    var channelType = event.channelType;
    var eventType = event.eventType;
    var category = event.target;
    var data = event.data;
    Debug.Log(string.Format("Received storage event {0} at channel:{1} with channel type of {2}. ", category , channelName, channelType));
    if (data != null)
    {
        // your logic
    }
}

// add lock event listener
rtmClient.OnLockEvent += ( LockEvent event ) =>
{
    var channelName = event.channelName;
    var channelType = event.channelType;
    var eventType = event.type;
    var LockDetail = event.lockDetailList;
    Debug.Log(string.Format("Received lock event {0} at channel:{2} with channel type of {3}. ", eventType, publisher , channelName, channelType));
    if( LockDetail != null )
    {
        // your logic
    }
}

// add OnConnectionStateChanged event listener
rtmClient.OnConnectionStateChanged += ( string channelName, RTM_CONNECTION_STATE state, RTM_CONNECTION_CHANGE_REASON reason ) =>
{
    Debug.Log(string.Format("OnConnectionStateChanged channelName {0}: state:{1} reason:{2}", channelName, state, reason);
}

// add OnTokenPrivilegeWillExpire event listener
rtmClient.OnTokenPrivilegeWillExpire += ( string channelName ) =>
{
    Debug.Log(string.Format("OnTokenPrivilegeWillExpire channelName {0}", channelName));
}

Message event. MessageEvent contains the following properties:

PropertiesTypeDescription
channelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.
messageTypeRTM_MESSAGE_TYPEMessage types. See RTM_MESSAGE_TYPE.
channelNamestringChannel name.
channelTopicstringTopic name.
messageIRtmMessageMessage.
publisherstringUser ID of the message publisher.
customTypestringA user-defined field. Only supports string type.
PresenceEvent

User presence event. PresenceEvent contains the following properties:

PropertiesTypeDescription
typeRTM_PRESENCE_EVENT_TYPEPresence event type. See RTM_PRESENCE_EVENT_TYPE.
channelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.
channelNamestringChannel name.
publisherstringUser ID of the message publisher.
stateItemsStateItem[]Key-value pair that identifies the user's presence state.
intervalIntervalInfoIn the Interval state, the aggregated incremental information of event notifications such as user joining, leaving, timeout, and status change in the previous period of the current channel.
snapshotSnapshotInfoWhen the user first joins the channel, the server pushes the snapshot data of all users in the current channel and their statuses to the user.

IntervalInfo contains the following properties:

PropertiesTypeDescription
joinUserListstring[]List of users who joined the channel in the previous cycle.
leaveUserListstring[]List of users who left the channel in the previous cycle.
timeoutUserListstring[]List of users who timed out joining the channel in the previous cycle.
userStateListUserState[]List of users whose status has changed in the previous cycle. Contains user ID and status key-value pairs.

SnapshotInfo contains the following properties:

PropertiesTypeDescription
userStateListUserState[]Snapshot information of the user when first joining the channel, including user ID and key-value pairs of status.
TopicEvent

Topic event.TopicEvent contains the following properties:

PropertiesTypeDescription
typeRTM_TOPIC_EVENT_TYPETopic event type. See RTM_TOPIC_EVENT_TYPE.
channelNamestringChannel name.
publisherstringUser ID.
topicInfosTopicInfo[]Topic information.

TopicInfo data type contains the following properties:

PropertiesTypeDescription
topicstringTopic name.
publishersPublisherInfo[]Message publisher array.

PublisherInfo[] data type contains the following properties:

PropertiesTypeDescription
publisherUserIdstringUser ID of the message publisher.
publisherMetastringMetadata of the message publisher.
StorageEvent

Storage event.StorageEvent contains the following properties:

PropertiesTypeDescription
channelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.
storageTypeRTM_STORAGE_TYPEStorage type. See RTM_STORAGE_TYPE.
eventTypeRTM_STORAGE_EVENT_TYPEStorage event type. See RTM_STORAGE_EVENT_TYPE.
targetstringUser ID or channel name.
dataRtmMetadataMetadata item.
LockEvent

Lock event. LockEvent contains the following properties:

PropertiesTypeDescription
channelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.
eventTypeRTM_LOCK_EVENT_TYPELock event type. See RTM_LOCK_EVENT_TYPE.
channelNamestringChannel name.
lockDetailListLockDetail[]Details of lock.

The LockDetail data type contains the following properties:

PropertiesTypeDescription
lockNamestringLock name.
ownerstringThe ID of the user who has a lock.
ttluintThe expiration time of the lock. The value is in seconds, ranging from [10 to 300]. When the user who owns the lock goes offline, if the user returns to the channel within the time they can still use the lock; otherwise, the lock is released and the users who listen for the OnLockEvent event receives the RELEASED event.

Remove event listeners

If you no longer need to use event notifications, to avoid memory leaks, errors or anomalies, Agora recommends removing event listeners.

private void AddEventsListener()
{
    rtmClient.OnMessageEvent += OnMessageEvent;
    rtmClient.OnPresenceEvent += OnPresenceEvent;
    rtmClient.OnTopicEvent += OnTopicEvent;
    rtmClient.OnStorageEvent += OnStorageEvent;
    rtmClient.OnLockEvent += OnLockEvent;
    rtmClient.OnConnectionStateChanged += OnConnectionStateChanged;
    rtmClient.OnTokenPrivilegeWillExpire += OnTokenPrivilegeWillExpire;
}

private void RemoveEventsListener()
{
    rtmClient.OnMessageEvent -= OnMessageEvent;
    rtmClient.OnPresenceEvent -= OnPresenceEvent;
    rtmClient.OnTopicEvent -= OnTopicEvent;
    rtmClient.OnStorageEvent -= OnStorageEvent;
    rtmClient.OnLockEvent -= OnLockEvent;
    rtmClient.OnConnectionStateChanged -= OnConnectionStateChanged;
    rtmClient.OnTokenPrivilegeWillExpire -= OnTokenPrivilegeWillExpire;
}

private void OnMessageEvent( MessageEvent Event)
{
    // your logic
 };

private void OnPresenceEvent( PresenceEvent Event)
{
    // your logic
};

private void OnTopicEvent( TopicEvent Event)
{
    // your logic
};

...

LoginAsync

Description

After creating and initializing the Signaling instance, you need to perform the LoginAsync operation to log in to the Signaling service. After successful login, the client establishes a long connection with the Signaling server, and then the SDK allows the client to access Signaling resources.

Information

After the user successfully logs in to the Signaling service, the PCU of the application increases, which affects your billing data.

Method

You can log in to the Signaling system as follows:

RtmResult<LoginResult> LoginAsync(string token);
ParametersTypeRequiredDefaultDescription
tokenstringRequired-Dynamic keys are generally generated by the user's token server.

Basic usage

var ( status,response ) = await rtmClient.LoginAsync(token);
if (status.Error)
{
   Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation , status.ErrorCode , status.Reason));
}
else
{
   Debug.Log("Login Successfully")
}

Return value

This operation returns the RtmResult&lt;LoginResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseLoginResultAfter the operation succeeds, this property returns a LoginResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

LogoutAsync

Description

When you no longer need to operate, you can log out of the system. This operation affects the PCU item in your billing data.

Method

You can log out as follows:

RtmResult<LogoutResult> LogoutAsync();

Basic usage

var (status,response) = await rtmClient.LogoutAsync();

Return value

This operation returns the RtmStatus data type, including the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

ReleaseLockAsync

Description

Once you no longer need the Signaling service, it is best to destroy the IRtmClient instance. Doing so protects you from the performance degradation caused by memory leaks, errors, and exceptions.

Method

You can destroy the IRtmClient instance as follows:

RtmStatus Dispose();

Basic usage

var status = Dispose();

Return value

This operation returns the RtmStatus data type, including the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

Channels

Signaling provides a highly efficient channel management mechanism for data transmission. Any user who subscribes or joins a channel can receive messages and events transmitted within 100 milliseconds. Signaling allows clients to subscribe to hundreds or even thousands of channels. Most Signaling APIs perform actions such as sending, receiving, and encrypting based on channels.

Based on capabilities of Agora, Signaling channels are divided into two types to match different application use-cases:

  • Message Channel: Follows the industry-standard Pub/Sub (publish/subscribe) mode. You can send and receive messages within the channel by subscribing to a channel, and do not need to create the channel in advance. There is no limit to the number of publishers and subscribers in a channel.
  • Stream Channel: Follows a concept similar to the observer pattern in the industry, where users need to create and join a channel before sending and receiving messages. You can create different topics in the channel, and messages are organized and managed through topics.

IRtmClient Signaling client instance

SubscribeTopicAsync

Description

Signaling provides event notification capabilities for messages and states. By listening for callbacks, you can receive messages and events within subscribed channels. For information on how to add and set event listeners, see Event Listeners.

By calling the SubscribeTopicAsync method, the client can subscribe to a message channel and start receiving messages and event notifications within the channel. After successfully calling this method, users who subscribe to the channel and enable the presence event listener can receive a REMOTE_JOIN type of the OnPresenceEvent event. See Event Listeners.

Information

This method only applies to the message channel.

Method

You can call the SubscribeTopicAsync method as follows:

RtmResult<SubscribeResult> SubscribeAsync(string channelName, SubscribeOptions options);
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.
SubscribeOptionsSubscribeOptionsRequired-Options for subscribing to a channel.

SubscribeOptions contains the following properties:

PropertiesTypeRequiredDefaultDescription
withMessageboolOptionaltrueWhether to subscribe to message event notifications in the channel.
withPresenceboolOptionaltrueWhether to subscribe to presence event notifications in the channel.
withMetadataboolOptionalfalseWhether to subscribe to storage event notifications in the channel.
withLockboolOptionalfalseWhether to subscribe to lock event notifications in the channel.

Basic usage

var options = new SubscribeOptions();
options.withMessage = true;
options.withPresence = true;
var (status,response) = await rtmClient.SubscribeAsync("Chat_room", options);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode:{1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Subscribe channel success! at Channel:{0}", response.ChannelName));
}

Return value

The SubscribeTopicAsync operation returns a RtmResult&lt;SubscribeTopicResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, which contains the operation of the state.
ResponseSubscribeTopicResultAfter the operation succeeds, this property returns a SubscribeTopicResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The SubscribeTopicResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringThe name of a message channel.

UnsubscribeTopicAsync

Description

If you no longer need to subscribe to a channel, you can call the UnsubscribeTopicAsync method to unsubscribe from the channel. After successfully calling this method, users who subscribe to the channel and enable event listeners can receive the REMOTE_LEAVE type of the OnPresenceEvent event notification. See Event Listeners.

Information

This method only applies to the message channel.

Method

You can call the UnsubscribeTopicAsync method as follows:

RtmResult<UnsubscribeResult> UnsubscribeAsync(string channelName);
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.

Basic usage

var (status,response) = await rtmClient.UnsubscribeAsync(channelName);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}

Return value

The UnsubscribeTopicAsync operation returns a RtmResult&lt;UnsubscribeTopicResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, which contains the operation of the state.
ResponseUnsubscribeTopicResultAfter the operation succeeds, this property returns a UnsubscribeTopicResult data type. Currently, this data type does not contain any data, you can ignore this property.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

CreateAgoraRtmClient

Description

Before using a stream channel, you need to call the CreateAgoraRtmClient method to create an IStreamChannel instance. After successfully creating the instance, you can call its relevant methods to implement functions, such as joining the channel, leaving the channel, sending messages in a topic, and subscribing to messages in a topic.

Information

This method only applies to the stream channel.

Method

You can call the CreateAgoraRtmClient method as follows:

IStreamChannel CreateStreamChannel(string channelName);
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.

Basic usage

try
{
    IStreamChannel streamChannel = rtmClient.CreateStreamChannel("Chat_room");
}
catch(RTMException e)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode : {1}, due to: {2}", e.Status.Operation , e.Status.ErrorCode , e.Status.Reason));
}

Return value

Returns an IStreamChannel instance.

IStreamChannel Stream channel instance

JoinTopicAsync

Description

After successfully creating a stream channel, you can call the JoinTopicAsync method to join the stream channel. Once you join the channel, you can implement channel-related functions. At this point, users who subscribe to the channel and add event listeners can receive the following event notifications:

  • For the local user:
    • The SNAPSHOT type of the OnPresenceEvent event.
    • The SNAPSHOT type of the OnTopicEvent event.
  • For remote users: The REMOTE_JOIN type of the OnPresenceEvent event.

Information

This method only applies to the stream channel.

Method

You can call the JoinTopicAsync method as follows:

RtmResult<JoinResult> JoinAsync(JoinChannelOptions options);
ParametersTypeRequiredDefaultDescription
optionsJoinChannelOptionsRequired-Options for joining a channel.

The JoinChannelOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
tokenStringRequired-The token used for joining a stream channel, which is currently the same as the RTC token.
withMetadataboolOptionalfalseWhether to subscribe to storage event notifications in the channel.
withPresenceboolOptionaltrueWhether to subscribe to presence event notifications in the channel.
withLockboolOptionalfalseWhether to subscribe to lock event notifications in the channel.

Basic usage

var (status,response) = await streamChannel.JoinAsync(options);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("User:{0} Join stream channel success! at Channel:{1}", response.UserId, response.ChannelName));
}

Return value

The JoinTopicAsync operation returns a RtmResult&lt;JoinTopicResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseJoinTopicResultAfter the operation succeeds, this property returns a JoinTopicResult data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The JoinTopicResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringName of a message channel.
UserIdstringUser ID.

LeaveTopicAsync

Description

If you no longer need to stay in a channel, you can call the LeaveTopicAsync method to leave the channel. After leaving the channel, you can no longer receive any messages, states, or event notifications from this channel. At the same time, you can no loger be the topic publisher or subscriber of all topics. If you want to restore your previous publisher role and subscribing relationship, you need to call JoinTopicAsync, JoinTopicAsync and SubscribeTopicAsync methods in order.

After successfully leaving the channel, remote users in the channel can receive the REMOTE_LEAVE type of the OnPresenceEvent event notification. For details, see Event Listeners.

Information

This method only applies to the stream channel.

Method

You can call the LeaveTopicAsync method as follows:

RtmResult<LeaveResult> LeaveAsync();

Basic usage

var (status,response) = await streamChannel.LeaveAsync();
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode:{1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("User:{0} Join stream channel success! at Channel:{1}", response.UserId, response.ChannelName));
}

Return value

The LeaveTopicAsync operation returns a RtmResult&lt;LeaveTopicResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseLeaveTopicResultAfter the operation succeeds, this property returns a LeaveTopicResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The LeaveTopicResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringName of a message channel.
UserIdstringUser ID.

ReleaseLockAsync

Description

If you no longer need a channel, you can call the ReleaseLockAsync method to destroy the corresponding stream channel instance and release resources. Calling the ReleaseLockAsync method does not destroy the stream channel, and it can be re-joined later by calling CreateAgoraRtmClient and JoinTopicAsync again.

Information

This method only applies to the stream channel. If you don't call LeaveTopicAsync to leave the channel before directly calling ReleaseLockAsync to destroy the stream channel instance, the SDK automatically calls the LeaveTopicAsync and triggers the corresponding event.

Method

You can call the ReleaseLockAsync method as follows:

RtmStatus Dispose();

Basic usage

var status = streamChannel.Dispose();
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode:{1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log("Dispose Channel Success!");
}

Return value

This operation returns the RtmStatus data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

Topics

Topic is a data stream management mechanism in stream channels. Users can use topics to subscribe to and distribute data streams, as well as notify events in data streams in stream channels.

Information

Topics only exist in stream channels. Therefore, before using relevant features, you need to create the IStreamChannel instance.

IStreamChannel Stream channel instance

JoinTopicAsync

Description

The purpose of joining a topic is to register as one of the message publishers for the topic, so that the user can send messages in the topic. This operation does not affect whether or not the user becomes a subscriber to the topic.

Information

  • Currently, Signaling supports a single client joining up to 8 topics in the same stream channel at a time.
  • Before joining a topic, a user needs to create the IStreamChannel instance and call the JoinTopicAsync method to join the channel.

After successfully joining a topic, users who subscribe to that topic and add event listeners can receive the REMOTE_JOIN type of the OnTopicEvent event notification. For details, see Event Listeners.

Method

You can call the JoinTopicAsync method as follows:

RtmResult<JoinTopicResult> JoinTopicAsync(string topic, JoinTopicOptions options);
ParametersTypeRequiredDefaultDescription
topicstringRequired-Topic name.
optionsJoinTopicOptionsRequired-Options for joining a topic.

The JoinTopicOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
qosRTM_MESSAGE_QOSOptionalUNORDEREDWhether the data transmitted in the topic is ordered. See RTM_MESSAGE_QOS.
priorityRTM_MESSAGE_PRIORITYOptionalNORMALThe priority of data transmission in the topic compared to other topics in the same channel. See RTM_MESSAGE_PRIORITY.
metastringOptional-Adds additional metadata when joining the topic.
syncWithMediaboolOptionalfalseWhether the data sent in this topic is synchronized (timestamp-aligned) with the RTC audio and video data stream of the common channel.

Basic usage

var options = new JoinTopicOptions();
options.qos = RTM_MESSAGE_QOS.ORDERED;

var (status,response) = await streamChannel.JoinTopicAsync(topic, options);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, because of: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("User:{0} Join Topic:{1} success! at Channel:{2}", response.UserId, response.Topic, response.ChannelName));
}

Return value

The JoinTopicAsync operation returns a RtmResult&lt;JoinTopicResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, which contains the operation of the state.
ResponseJoinTopicResultAfter the operation succeeds, this property returns a JoinTopicResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The JoinTopicResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringChannel name.
UserIdstringUser ID.
TopicstringTopic name.
MetastringAdditional information of this operation.

PublishTopicMessageAsync

Description

Use the PublishTopicMessageAsync method to send messages to a topic. Users who have subscribed to the topic and the message publisher in the channel can receive the message within 100 milliseconds. Before calling the PublishTopicMessageAsync method, users need to join the stream channel, and then register as a message publisher for that topic by calling the JoinTopicAsync method.

The messages sent by users are encrypted with TLS during transmission, and data link encryption is enabled by default and cannot be disabled. To achieve a higher level of data security, users can also enable client encryption during initialization. For details, see Setup.

Method

You can call the PublishTopicMessageAsync[1/2] and PublishTopicMessageAsync[2/2] method as follows:

// PublishTopicMessageAsync[1/2]
RtmResult<PublishTopicMessageResult> PublishTopicMessageAsync(string topic, byte[] message, TopicMessageOptions option);
// PublishTopicMessageAsync[2/2]
RtmResult<PublishTopicMessageResult> PublishTopicMessageAsync(string topic, string message, TopicMessageOptions option);
ParametersTypeRequiredDefaultDescription
topicstringRequired-Topic name.
messagestring\byte[]Required-Message payload. You need to fill in string messages in the PublishTopicMessageAsync[1/2] method, and binary messages in the PublishTopicMessageAsync[2/2] method.
optionsTopicMessageOptionsOptional-Message options.

The TopicMessageOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
sendTsUInt64Optional0The timestamp when the SDK sends a message. This parameter is only valid when you set syncWithMedia = true in the JoinTopicAsync method. The SDK synchronizes data with RTC audio and video streams based on this timestamp.
customTypestringOptionalnullA user-defined field. Only supports string type.

Basic usage

var message = "Hello World";
var topic = "Motion";
var options = new TopicMessageOptions();
options.customType = "PlainText";
var (status,response) = await streamChannel.PublishTopicMessageAsync(topic, message, options);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}

Return value

The PublishTopicMessageAsync operation returns a RtmResult&lt;PublishTopicMessageResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, which contains the operation of the state.
ResponsePublishTopicMessageResultAfter the operation succeeds, this property returns a PublishTopicMessageResult data type. Currently, this data type does not contain any data, you can ignore this property.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

LeaveTopicAsync

Description

When you no longer need to publish messages to a topic, to release resources, you can call the LeaveTopicAsync method to unregister as a message publisher for that topic. This method does not affect whether or not you subscribe to that topic or any other operations performed by other users on that topic.

After successfully calling this method, users who subscribe to the channel and enable event listeners can receive the REMOTE_LEAVE type of the OnTopicEvent event notification. See Event Listeners.

Method

You can call the LeaveTopicAsync method as follows:

RtmResult<LeaveTopicResult> LeaveTopicAsync(string topic);
ParametersTypeRequiredDefaultDescription
topicstringRequired-Topic name.

Basic usage

var (status,response) = await streamChannel.LeaveTopicAsync("Motion");
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("User:{0} Join Topic:{1} success! at Channel:{2}", response.UserId, response.Topic, response.ChannelName));
}

Return value

The LeaveTopicAsync operation returns a RtmResult&lt;LeaveTopicResult&gt; data type, including the following properties:

ParametersTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, which contains the operation of the state.
ResponseLeaveTopicResultAfter the operation succeeds, this property returns a LeaveTopicResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The LeaveTopicResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringChannel name.
UserIdstringUser ID.
TopicstringTopic name.
MetastringAdditional information of this operation.

SubscribeTopicAsync

Description

After joining the channel, you can call the SubscribeTopicAsync method to subscribe to the message publisher of the topic in the channel.

SubscribeTopicAsync is an incremental method. For example, if you call this method for the first time with a subscribing list of [UserA, UserB], and then call it again with a subscribing list of [UserB, UserC], the final successful subscribing result is [UserA, UserB, UserC].

A user can subscribe to a maximum of 50 topics in each channel, and a maximum of 64 message publishers in each topic. See API usage restrictions.

Method

You can call the SubscribeTopicAsync method as follows:

RtmResult<SubscribeTopicResult> SubscribeTopicAsync(string topic, TopicOptions options);
ParametersTypeRequiredDefaultDescription
topicstringRequired-Topic name.
optionsTopicOptionsOptional-Options for subscribing to a topic.

The TopicOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
usersstring[]Optional-A list of UserId of message publishers that you want to subscribe to. If you do not set this property, you can randomly subscribe to up to 64 users by default.

Basic usage

List<string> userList = new List<string>();
userList.Add("Tony");
userList.Add("Marry");

var options = new TopicOptions();
options.users = userList.ToArray();

var (status,response) = await streamChannel.SubscribeTopicAsync(subtopic, options);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("User:{0} Join Topic:{1} success! at Channel:{2}", response.UserId, response.Topic, response.ChannelName));
}

Return value

The SubscribeTopicAsync operation returns a RtmResult&lt;SubscribeTopicResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, which contains the operation of the state.
ResponseSubscribeTopicResultAfter the operation succeeds, this property returns a SubscribeTopicResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The SubscribeTopicResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringChannel name.
UserIdstringUser ID.
TopicstringTopic name.
SucceedUsersstring[]A list of successfully subscribed users.
FailedUsersstring[]A list of users that the SDK fails to subscribe to.

UnsubscribeTopicAsync

Description

If you are no longer interested in a specified topic, or no longer need to subscribe to one or more message publishers in the topic, you can call the UnsubscribeTopicAsync method to unsubscribe from the topic or the specified message publishers in the topic.

Method

You can call the UnsubscribeTopicAsync method as follows:

RtmResult<UnsubscribeTopicResult> UnsubscribeTopicAsync(string topic, TopicOptions options);
ParametersTypeRequiredDefaultDescription
topicstringRequired-Topic name.
optionsTopicOptionsOptional-Options for unsubscribing from a topic.

The TopicOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
usersstring[]Optional-A list of UserId of message publishers that you want to unsubscribe from. If you do not set this property, you can randomly unsubscribe from up to 64 users by default.

Basic usage

List<string> userList = new List<string>();
userList.Add("Tony");
userList.Add("Marry");

var options = new TopicOptions();
topicOptions.users = userList.ToArray();

var (status,response) = await streamChannel.UnsubscribeTopicAsync(subtopic, options);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}

Return value

The UnsubscribeTopicAsync operation returns a RtmResult&lt;UnsubscribeTopicResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, which contains the operation of the state.
ResponseUnsubscribeTopicResultAfter the operation succeeds, this property returns a UnsubscribeTopicResult data type. Currently, this data type does not contain any data, you can ignore this property.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

Messages

Sending and receiving messages is the most basic function of the Signaling service. Any message sent by the Signaling server can be delivered to any online subscribing user within 100 ms. Depending on your business requirements, you can send messages to one user only or broadcast messages to multiple users.

Signaling offers two types of channels: message channels and stream channels. These channel types have the following differences in how messages are transmitted and methods are called:

  • Message Channel: The real-time channel. Messages are transmitted through the channel, and the channel is highly scalable. Local users can call the PublishTopicMessageAsync method to send messages in the channel, and remote users can call the SubscribeTopicAsync method to subscribe to the channel and receive messages.
  • Stream Channel: The streaming transmission channel. Messages are transmitted through the topic. Users need to join a channel first, and then join a topic. Local users can call the PublishTopicMessageAsync method to send messages in the topic, and remote users can call the SubscribeTopicAsync method to subscribe to the topic and receive messages.

This page introduces how to send and receive messages in a Message Channel.

IRtmClient Signaling client instance

PublishTopicMessageAsync

Description

You can directly call the PublishTopicMessageAsync method to send messages to all online users subscribed to this channel. Even if you do not subscribe to the channel, you can still send messages in the channel.

Information

The following practices can effectively improve the reliability of message transmission:
- The message payload should be within 32 KB; otherwise, the sending will fail.
- The upper limit of the rate at which messages are sent to a single channel is 60 QPS. If the sending rate exceeds the limit, some messages will be discarded. A lower rate is better, as long as the requirements are met.

After successfully calling this method, the SDK triggers a OnMessageEvent event notification. Users who subscribe to the channel and enabled the event listener can receive this event notification. For details, see Event Listeners.

Method

You can call the PublishTopicMessageAsync [1/2] and PublishTopicMessageAsync [2/2] methods as follows:

// PublishAsync[1/2]
RtmResult<PublishResult> PublishAsync(string channelName, byte[] message, PublishOptions option);
// PublishAsync[2/2]
RtmResult<PublishResult> PublishAsync(string channelName, string message, PublishOptions option);
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name. You can only send messages to one channel at a time.
messagestring\byte[]Required-Message payload. You need to fill in string messages in the PublishTopicMessageAsync[1/2] method, and binary messages in the PublishTopicMessageAsync[2/2] method.
optionsTopicMessageOptionsRequired-Message options.

The TopicMessageOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.
customTypestringOptional-A user-defined field. Only supports string type.

Basic usage

var message = "Hello World";
var channelName = "my_channel";
var options = new PublishOptions();
options.customType = "PlainText";

var (status,response) = await rtmClient.PublishAsync(channelName, message, options);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log("Publish Message Success!");
}

Return value

The PublishTopicMessageAsync operation returns a RtmResult&lt;PublishTopicMessageResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponsePublishTopicMessageResultAfter the operation succeeds, this property returns a PublishTopicMessageResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The PublishTopicMessageResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringChannel name.

Receive

Signaling provides event notifications for messages, states, and event changes. By listening for callbacks, you can receive messages and events within subscribed channels.

For information on how to add and set event listeners, see Event Listeners.

Presence

The presence feature provides the ability to monitor user online, offline, and user historical state change. With the Presence feature, you can get real-time access to the following information:

  • Real-time event notification when a user joins or leaves a specified channel.
  • Real-time event notification when the custom temporary user state changes.
  • Query which channels a specified user has joined or subscribed to.
  • Query which users have joined a specified channel and their temporary user state data.

Information

Presence applies to both message channels and stream channels.

IRtmClient Signaling client instance

WhoNowAsync

Description

By calling the WhoNowAsync method, you can query real-time information about the number of online users, the list of online users, and the temporary state of online users in a specified channel.

Method

You can call the WhoNowAsync method as follows:

RtmResult<GetOnlineUsersResult> rtmClient.GetPresence().GetOnlineUsersAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType,
    PresenceOptions options
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name. If you do not fill in the parameter, the WhoNowAsync method returns in all online users information in the channel which is accordance with the RTM_CHANNEL_TYPE conditions.
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.
optionsPresenceOptionsRequired-Query options.

The PresenceOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
includeUserIdboolOptionaltrueWhether the returned result includes the user ID of online members.
includeStateboolOptionalfalseWhether the returned result includes temporary state data of online users.
pagestringOptional-Page number of the returned result. If you do not provide this property, the SDK returns the first page by default. You can check whether there is next page in the returned result.

Basic usage

var options = new PresenceOptions();
options.withState = true;

var (status,response) = await rtmClient.GetPresence().GetOnlineUsersAsync("Chat_room", RTM_CHANNEL_TYPE.MESSAGE, options);
if (result.Status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("You have got {0} users information ", response.TotalOccupancy));
    if (response.NextPage != null)
    {
        Debug.Log("you have the next page information waiting for read!");
    }
}

Return value

The WhoNowAsync operation returns a RtmResult&lt;WhoNowResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseWhoNowResultAfter the operation succeeds, this property returns a WhoNowResult data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The WhoNowResult data type contains the following properties:

PropertiesTypeDescription
NextPagestringPage number of the next page. Confirm whether there is a next page:
- A null value indicates that next page does not exist.
- A non-null value indicates that there is a next page. You can fill this value in the page property of the WhoNowAsync method to query the next page results.
UserStateListUserState[]List of online users and their temporary state information in a specified channel.
TotalOccupancyintThe list length of UserStateList. When you set both includeUserId and includeState properties in the GetOnlineUsersOptions data type to false, this value represents the total number of current online users in the channel.

The UserState[] data type contains the following properties:

PropertiesTypeDescription
statesStateItem[]User temporary state information.
userIdstringUser ID.

StateItem data type contains the following properties:

PropertiesTypeDescription
keystringKey of the user state. If the specified key already exists, the SDK overwrites the value; if the specified key does not exist, the SDK creates the key-value pair.
valuestringValue of the user state.

WhereNowAsync

Description

In use-cases such as statistic analytics and debugging, you may need to know all the channels that a specified user has subscribed to or joined. Call the WhereNowAsync method to get the list of channels where the specified user is in real time.

Method

You can call the WhereNowAsync method as follows:

RtmResult<GetUserChannelsResult> rtmClient.GetPresence().GetUserChannelsAsync(string userId);
ParametersTypeRequiredDefaultDescription
userIdstringRequiredUser ID of the current userUser ID

Basic usage

var (status,respones) = await rtmClient.GetPresence().GetUserChannelsAsync("Tony");
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("User Tony is now in {0} channels ", response.Channels.Length));
    if (response.Channels.Length > 0)
    {
        for (int i = 0; i < response.Channels.Length; i++)
        {
            var channelInfo = response.Channels[i];
            string infor = string.Format("Tony is in channelName:{0}, channelType:{1}", channelInfo.channelName, channelInfo.channelType);
            Debug.Log(infor);
        }
    }
}

Return value

The WhereNowAsync operation returns a RtmResult&lt;WhereNowResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseWhereNowResultAfter the operation succeeds, this property returns a WhereNowResult data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The WhereNowResult data type contains the following properties:

PropertiesTypeDescription
ChannelsChannelInfo[]List of channel information, including channel name and channel type.

The ChannelInfo data type contains the following properties:

PropertiesTypeDescription
channelNamestringChannel name.
channelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.

SetStateAsync

Description

To meet different requirements in different business use-cases for setting user states, Signaling provides the SetStateAsync method to customize the temporary user state. Users can add custom states such as scores, game state, location, mood, and hosting state for themselves.

After successful setup, as long as the user keeps subscribing to the channel and stays online, the custom states can persist in the channel. SetStateAsync method sets the temporary user state, and the state disappears when the user leaves the channel or disconnects from Signaling. If you need to restore user states when rejoining a channel or reconnecting, you need to cache the data locally in real time. If you want to permanently save user states, Agora recommends you use the SetUserMetadataAsync method of the storage function instead.

If a user modifies the temporary user state, Signaling triggers the REMOTE_STATE_CHANGED type of the OnPresenceEvent event in real time. You can receive the event by subscribing to the channel and configuring the corresponding property.

Method

You can call the SetStateAsync method as follows:

RtmResult<SetStateResult> rtmClient.GetPresence().SetStateAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType,
    StateItem[] items
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.
itemsStateItem[]Required-User state, an array of StateItem.

StateItem data type contains the following properties:

PropertiesTypeDescription
keystringKey of the user state. If the specified key already exists, the SDK overwrites the value; if the specified key does not exist, the SDK creates the key-value pair.
valuestringValue of the user state.

Basic usage

var stateItems = new StateItem[1];
stateItems[0] = new StateItem("state", "Online");
var (status,response) = await rtmClient.GetPresence().SetStateAsync(channelName, RTM_CHANNEL_TYPE.MESSAGE, stateItems);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log("Set State Success!");
}

Return value

The SetStateAsync operation returns a RtmResult&lt;SetStateResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseSetStateResultAfter the operation succeeds, this property returns a SetStateResult data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

GetStateAsync

Description

To get the temporary user state of a specified user in the channel, you can use the GetStateAsync method.

Method

You can call the GetStateAsync method as follows:

RtmResult<GetStateResult> rtmClient.GetPresence().GetStateAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType,
    string userId
    );
ParametersTypeRequiredDefaultDescription
userIdstringRequiredUser ID of the current userUser ID.
channelNamestringRequired-Channel name. If you do not fill in the parameter, the WhoNowAsync method returns in all online users information in the channel which is accordance with the RTM_CHANNEL_TYPE conditions.
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.

Basic usage

var (status,response) = await rtmClient.GetPresence().GetStateAsync(channelName, RTM_CHANNEL_TYPE.MESSAGE, userId);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("User:{0}, have stateCount:{1} states",response.State.userId, response.State.states.Length));
}

Return value

The GetStateAsync operation returns a RtmResult&lt;GetStateResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseGetStateResultAfter the operation succeeds, this property returns a GetStateResult data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The GetStateResult data type contains the following properties:

PropertiesTypeDescription
StateUserStateUser temporary state.

The UserState data type contains the following properties:

PropertiesTypeDescription
statesStateItem[]User temporary state information.
userIdstringUser ID.

StateItem data type contains the following properties:

PropertiesTypeDescription
keystringKey of the user state. If the specified key already exists, the SDK overwrites the value; if the specified key does not exist, the SDK creates the key-value pair.
valuestringValue of the user state.

RemoveStateAsync

Description

When a temporary user state is no longer needed, you can call the RemoveStateAsync method to remove one or more of your temporary states. When the user state is removed, the user who has subscribed to the channel and enabled the presence event listener receives the REMOTE_STATE_CHANGED type of OnPresenceEvent event notification. See Event Listeners.

Method

You can call the RemoveStateAsync method as follows:

RtmResult<RemoveStateResult> rtmClient.GetPresence().RemoveStateAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType,
    string[] keys
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.
keysstring[]Required-List of keys to be deleted. If you do not provide this property, the SDK removes all states.

Basic usage

var channelName = "Chat_room";
string[] keys = new string[] { "mode" };
var (status,respones) = await rtmClient.GetPresence().RemoveStateAsync(channelName, RTM_CHANNEL_TYPE.MESSAGE, keys);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log("Remove State Success!");
}

Return value

The RemoveStateAsync operation returns a RtmResult&lt;RemoveStateResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseRemoveStateResultAfter the operation succeeds, this property returns a RemoveStateResult data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

Storage

The storage feature provides a dynamic database mechanism that allows developers to dynamically set, store, update, and delete data such as channel metadata and user metadata.

IRtmClient Signaling client instance

SetChannelMetadataAsync

Description

The SetChannelMetadataAsync method sets metadata for a message channel or stream channel. A channel can only have one set of metadata, but each set of metadata can have one or more metadata items. If you call this method multiple times, the SDK retrieves the key of the metadata items in turn and apply settings according to the following rules:

  • If you set metadata with different key, the SDK adds each set of metadata in sequence according to the order of the method calls.
  • If you set metadata with the same key, the value of the last setting overwrites the previous one.

After successfully setting channel metadata, users who subscribe to the channel and enable event listeners can receive the CHANNEL type of the OnStorageEvent event notification. See Event listeners.

Channel metadata also introduces the version control logic CAS (Compare And Set). This method provides two independent version control fields, and you can set one or more of them according to your actual business use-case:

  • Enable version number verification for the entire set of channel metadata by setting the majorRevision property in the RtmMetadata class.
  • Enable version number verification for a single metadata item by setting the revision property in the MetadataItem class within the RtmMetadata class.

When setting channel metadata or metadata items, you can control whether to enable version number verification by specifying the revision property:

  • The default value of the revision property is -1, indicating that this method call does not perform any CAS verification. If the channel metadata or metadata item already exists, the latest value overwrites the previous one. If the channel metadata or metadata item does not exist, the SDK creates it.
  • If the revision property is a positive integer, this method call performs the CAS verification. If the channel metadata or metadata item already exists, the SDK updates the corresponding value after the version number verification succeeds. If the channel metadata or metadata item does not exist, the SDK returns the error code.

Method

You can call the SetChannelMetadataAsync method as follows:

RtmResult<SetChannelMetadataResult> rtmClient.GetStorage().SetChannelMetadataAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType,
    RtmMetadata data,
    MetadataOptions options,
    string lockName
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.
dataRtmMetadataRequired-Metadata item.
optionsMetadataOptionsOptional-Options for setting the channel metadata.
lockNamestringOptional-Lock name. If set, only users who call the AcquireLockAsync method to acquire the lock can perform operations.

The RtmMetadata data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
majorRevisionInt64Optional-1Version control switch:
- -1: Disable the version verification.
- > 0: Enable the version verification. The operation can only be performed if the target version number matches this value.
metadataItemsMetadataItem[]Required-Metadata item array.
metadataItemsSizeUInt64Required-Length of the MetadataItem[] array.

The MetadataItem data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
keystringRequired-Key.
valuestringRequired-Value.
authorUserIdstringRequired-The user ID of the editor. This value is read-only and does not support writing.
revisionInt64Optional-1
- Returns the real version number in read operations.
- Serves as a version control switch in write operations:
- -1: Disable the version verification.
- > 0: Enable version verification, only perform the operation if the target version number matches this value.
updateTsInt64Optional0Update timestamp. This value is read-only and does not support writing.

The MetadataOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
recordTsBoolOptionalfalseWhether to record the timestamp of the edits.
recordUserIdBoolOptionalfalseWhether to record the user ID of the editor.

Basic usage

var metadata = new RtmMetadata();
metadata.majorRevision = 174298270;
var apple = new MetadataItem()
            {
                key = "Apple",
                value = "100",
                revision = 174298200,
            };
var banana = new MetadataItem()
            {
                key = "Banana",
                value = "200",
                revision = 174298100,
            };
metadata.metadataItems = new MetadataItem[] { apple, banana };
metadata.metadataItemsSize = 2;
var metadataOptions = new MetadataOptions()
            {
                recordUserId = true,
                recordTs = true
            };
var lockName = "lockName";

var (status,respones) = await rtmClient.GetStorage().SetChannelMetadataAsync("channel_name", RTM_CHANNEL_TYPE.MESSAGE, metadata, metadataOptions, lockName);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Set Channel :{0} metadata success! Channel Type is :{1}! ", response.ChannelName, response.ChannelType));
}

Return value

The SetChannelMetadataAsync operation returns a RtmResult&lt;SetChannelMetadataResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseSetChannelMetadataResultAfter the operation succeeds, this property returns a SetChannelMetadataResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The SetChannelMetadataResult data type contains the following properties:

PropertiesTypeDescription
channelNamestringChannel name.
channelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.

GetChannelMetadataAsync

Description

The GetChannelMetadataAsync method can get the metadata of the specified channel.

Method

You can call the GetChannelMetadataAsync method as follows:

RtmResult<GetChannelMetadataResult> rtmClient.GetStorage().GetChannelMetadataAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.

Basic usage

var (status,respones) = await rtmClient.GetStorage().GetChannelMetadataAsync("channel_name", RTM_CHANNEL_TYPE.MESSAGE);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Get Channel :{0} metadata success! Channel Type is :{1}! ", response.ChannelName, response.ChannelType));
    var data =  response.data;
    if (data.metadataItemsSize != 0)
    {
        Debug.Log(string.Format("Channel Metadata Major Revision is :{0} ! ", data.majorRevision));
        for ( int i =0; i < data.metadataItemsSize; i++)
        {
            Debug.Log(string.Format("The {0}'th iterms Key is:{1}, Value is {2} ! ", i, data.metadataItems[i].key, data.metadataItems[i].value));
        }
    }
}

Return value

The GetChannelMetadataAsync operation returns a RtmResult&lt;GetChannelMetadataResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseGetChannelMetadataResultAfter the operation succeeds, this property returns a GetChannelMetadataResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The GetChannelMetadataResult data type contains the following properties:

PropertiesTypeDescription
channelNamestringChannel name.
channelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.
DataRtmMetadataMetadata item array.

The RtmMetadata data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
majorRevisionInt64Optional-1Version control switch:
- -1: Disable the version verification.
- > 0: Enable the version verification. The operation can only be performed if the target version number matches this value.
metadataItemsMetadataItem[]Required-Metadata item array.
metadataItemsSizeUInt64Required-Length of the MetadataItem[] array.

The MetadataItem data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
keystringRequired-Key.
valuestringRequired-Value.
authorUserIdstringRequired-The user ID of the editor. This value is read-only and does not support writing.
revisionInt64Optional-1
- Returns the real version number in read operations.
- Serves as a version control switch in write operations:
- -1: Disable the version verification.
- > 0: Enable version verification, only perform the operation if the target version number matches this value.
updateTsInt64Optional0Update timestamp. This value is read-only and does not support writing.

The MetadataOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
recordTsBoolOptionalfalseWhether to record the timestamp of the edits.
recordUserIdBoolOptionalfalseWhether to record the user ID of the editor.

RemoveChannelMetadataAsync

Description

The RemoveChannelMetadataAsync method can remove channel metadata or metadata items.

When removing channel metadata or metadata items, you can control whether to enable version number verification by specifying the revision property:

  • The default value of the revision property is -1, indicating that this method call does not perform any CAS verification. If the channel metadata or metadata item already exists, the SDK removes it. If the channel metadata or metadata item does not exist, the SDK returns the error code.
  • If the revision property is a positive integer, this method call performs the CAS verification. If the channel metadata or metadata item already exists, the SDK removes the corresponding value after the version number verification succeeds. If the channel metadata or metadata item does not exist, the SDK returns the error code.

After successfully removing channel metadata or metadata items, users who subscribe to the channel and enable event listeners can receive the CHANNEL type of the OnStorageEvent event notification. See Event listeners.

Method

You can call the RemoveChannelMetadataAsync method as follows:

RtmResult<RemoveChannelMetadataResult> rtmClient.GetStorage().RemoveChannelMetadataAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType,
    RtmMetadata data,
    MetadataOptions options,
    string lockName
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.
dataRtmMetadataRequired-Metadata item.
optionsMetadataOptionsOptional-Options for setting the channel metadata.
lockNamestringOptional-Lock name. If set, only users who call the AcquireLockAsync method to acquire the lock can perform operations.

The RtmMetadata data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
majorRevisionInt64Optional-1Version control switch:
- -1: Disable the version verification.
- > 0: Enable the version verification. The operation can only be performed if the target version number matches this value.
metadataItemsMetadataItem[]Required-Metadata item array.
metadataItemsSizeUInt64Required-Length of the MetadataItem[] array.

The MetadataItem data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
keystringRequired-Key.
valuestringRequired-Value.
authorUserIdstringRequired-The user ID of the editor. This value is read-only and does not support writing.
revisionInt64Optional-1
- Returns the real version number in read operations.
- Serves as a version control switch in write operations:
- -1: Disable the version verification.
- > 0: Enable version verification, only perform the operation if the target version number matches this value.
updateTsInt64Optional0Update timestamp. This value is read-only and does not support writing.

The MetadataOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
recordTsBoolOptionalfalseWhether to record the timestamp of the edits.
recordUserIdBoolOptionalfalseWhether to record the user ID of the editor.

Basic usage

var metadata = new RtmMetadata();
metadata.majorRevision = 174298270;
var metadataItem = new MetadataItem()
            {
                key = "174298270",
                revision = 174298200,
            };
metadata.metadataItems = new MetadataItem[] { metadataItem };
metadata.metadataItemsSize = 1;
var options = new MetadataOptions() { };

var (status,response) = await rtmClient.GetStorage().RemoveChannelMetadataAsync("channel_name", RTM_CHANNEL_TYPE.MESSAGE, oOptions,"");
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Remove Channel :{0} metadata success! Channel Type is :{1}! ", response.ChannelName, response.ChannelType));
}

Return value

The RemoveChannelMetadataAsync operation returns a RtmResult&lt;RemoveChannelMetadataResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseRemoveChannelMetadataResultAfter the operation succeeds, this property returns a RemoveChannelMetadataResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The RemoveChannelMetadataResult data type contains the following properties:

PropertiesTypeDescription
channelNamestringChannel name.
channelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.

UpdateChannelMetadataAsync

Description

The UpdateChannelMetadataAsync method can update existing channel metadata. Each time you call this method, you can update one channel metadata or a channel metadata item.

After successfully updating channel metadata, users who subscribe to the channel and enable event listeners can receive the CHANNEL type of the OnStorageEvent event notification. See Event listeners.

Method

You can call the UpdateChannelMetadataAsync method as follows:

RtmResult<UpdateChannelMetadataResult> rtmClient.GetStorage().UpdateChannelMetadataAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType,
    RtmMetadata data,
    MetadataOptions options,
    string lockName
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.
dataRtmMetadataRequired-Metadata item.
optionsMetadataOptionsOptional-Options for setting the channel metadata.
lockNamestringOptional-Lock name. If set, only users who call the AcquireLockAsync method to acquire the lock can perform operations.

The RtmMetadata data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
majorRevisionInt64Optional-1Version control switch:
- -1: Disable the version verification.
- > 0: Enable the version verification. The operation can only be performed if the target version number matches this value.
metadataItemsMetadataItem[]Required-Metadata item array.
metadataItemsSizeUInt64Required-Length of the MetadataItem[] array.

The MetadataItem data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
keystringRequired-Key.
valuestringRequired-Value.
authorUserIdstringRequired-The user ID of the editor. This value is read-only and does not support writing.
revisionInt64Optional-1
- Returns the real version number in read operations.
- Serves as a version control switch in write operations:
- -1: Disable the version verification.
- > 0: Enable version verification, only perform the operation if the target version number matches this value.
updateTsInt64Optional0Update timestamp. This value is read-only and does not support writing.

The MetadataOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
recordTsBoolOptionalfalseWhether to record the timestamp of the edits.
recordUserIdBoolOptionalfalseWhether to record the user ID of the editor.

Basic usage

var metadata = new RtmMetadata();
metadata.majorRevision = 174298270 ;
var apple = new MetadataItem()
            {
                key = "Apple",
                value = "120",
                revision = 174298200,
            };
var banana = new MetadataItem()
            {
                key = "Banana",
                value = "220",
                revision = 174298100,
            };
metadata.metadataItems = new MetadataItem[] { apple, banana };
metadata.metadataItemsSize = 2;
var options = new MetadataOptions()
            {
                recordUserId = true,
                recordTs = true
            };

var lockName = "lockName";

var (status,response) = await rtmClient.GetStorage().UpdateChannelMetadataAsync("channel_name", RTM_CHANNEL_TYPE.MESSAGE, data, options, lockName);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Remove Channel :{0} metadata success! Channel Type is :{1}! ", response.ChannelName, response.ChannelType));
}

Return value

The UpdateChannelMetadataAsync operation returns a RtmResult&lt;UpdateChannelMetadataResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseUpdateChannelMetadataResultAfter the operation succeeds, this property returns a UpdateChannelMetadataResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The UpdateChannelMetadataResult data type contains the following properties:

PropertiesTypeDescription
channelNamestringChannel name.
channelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.

SetUserMetadataAsync

Description

The SetUserMetadataAsync method can set metadata for a user. If you call this method multiple times, the SDK retrieves the key of the metadata items in turn and apply settings according to the following rules:

  • If you set metadata with different key, the SDK adds each set of metadata in sequence according to the order of the method calls.
  • If you set metadata with the same key, the value of the last setting overwrites the previous one.

After successfully setting user metadata, users who subscribe to the user and enable event listeners can receive the USER type of the OnStorageEvent event notification. See Event listeners.

User metadata also introduces the version control logic CAS (Compare And Set). This method provides two independent version control fields, and you can set one or more of them according to your actual business use-case:

  • Enable version number verification for the entire set of user metadata by setting the majorRevision property in the RtmMetadata class.
  • Enable version number verification for a single metadata item by setting the revision property in the MetadataItem class within the RtmMetadata class.

When setting user metadata or metadata items, you can control whether to enable version number verification by specifying the revision property:

  • The default value of the revision property is -1, indicating that this method call does not perform any CAS verification. If the user metadata or metadata item already exists, the latest value overwrites the previous one. If the user metadata or metadata item does not exist, the SDK creates it.
  • If the revision property is a positive integer, this method call performs the CAS verification. If the user metadata or metadata item already exists, the SDK updates the corresponding value after the version number verification succeeds. If the user metadata or metadata item does not exist, the SDK returns the error code.

Method

You can call the SetUserMetadataAsync method as follows:

RtmResult<SetUserMetadataResult> rtmClient.GetStorage().SetUserMetadataAsync(
    string userId,
    RtmMetadata data,
    MetadataOptions options
    );
ParametersTypeRequiredDefaultDescription
userIdstringOptionalUser ID of the current userUser ID.
dataRtmMetadataRequired-Metadata item.
optionsMetadataOptionsRequired-Options for setting the channel metadata.

The RtmMetadata data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
majorRevisionInt64Optional-1Version control switch:
- -1: Disable the version verification.
- > 0: Enable the version verification. The operation can only be performed if the target version number matches this value.
metadataItemsMetadataItem[]Required-Metadata item array.
metadataItemsSizeUInt64Required-Length of the MetadataItem[] array.

The MetadataItem data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
keystringRequired-Key.
valuestringRequired-Value.
authorUserIdstringRequired-The user ID of the editor. This value is read-only and does not support writing.
revisionInt64Optional-1
- Returns the real version number in read operations.
- Serves as a version control switch in write operations:
- -1: Disable the version verification.
- > 0: Enable version verification, only perform the operation if the target version number matches this value.
updateTsInt64Optional0Update timestamp. This value is read-only and does not support writing.

The MetadataOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
recordTsBoolOptionalfalseWhether to record the timestamp of the edits.
recordUserIdBoolOptionalfalseWhether to record the user ID of the editor.

Basic usage

var metadata = new RtmMetadata();
metadata.majorRevision = 174298270;
var name = new MetadataItem()
            {
                key = "Name",
                value = "Tony",
                revision = 174298200,
            };
var mute = new MetadataItem()
            {
                key = "Mute",
                value = "true",
                revision = 174298100,
            };
metadata.metadataItems = new MetadataItem[] { name, mute };
metadata.metadataItemsSize = 2;
var options = new MetadataOptions()
            {
                recordUserId = true,
                recordTs = true
            };

var (status,response) = await rtmClient.GetStorage().SetUserMetadataAsync("Tony",  rtmMetadata, options);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Set user :{0} metadata success! ", response.UserId));
}

Return value

The SetUserMetadataAsync operation returns a RtmResult&lt;SetUserMetadataResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseSetUserMetadataResultAfter the operation succeeds, this property returns a SetUserMetadataResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The SetUserMetadataResult data type contains the following properties:

PropertiesTypeDescription
UserIdstringUser ID.

GetUserMetadataAsync

Description

The GetUserMetadataAsync method can get the metadata and metadata item for the specified user.

Method

You can call the GetUserMetadataAsync method as follows:

RtmResult<GetUserMetadataResult> GetUserMetadataAsync(string userId);
ParametersTypeRequiredDefaultDescription
userIdstringOptionalUser ID of the current userUser ID.

Basic usage

var result = await rtmClient.GetStorage().GetUserMetadataAsync("Tony");
if (result.Status.Error)
{
    Debug.Log(string.Format("{0} is failed, The error code is {1}, because of: {2}", result.Status.Operation, result.Status.ErrorCode, result.Status.Reason));
}
else
{
    Debug.Log(string.Format("Get User :{0} metadata success!  ", result.Response.UserId));
    var data =  result.Response.data;
    if (data.metadataItemsSize != 0)
    {
        Debug.Log(string.Format("Channel Metadata Major Revision is :{0} ! ", data.majorRevision));
        for ( int i =0; i < data.metadataItemsSize; i++)
        {
            Debug.Log(string.Format("The {0}'th iterms Key is:{1}, Value is {2} ! ", i, data.metadataItems[i].key, data.metadataItems[i].value));
        }
    }
}

Return value

The GetUserMetadataAsync operation returns a RtmResult&lt;GetUserMetadataResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseGetUserMetadataResultAfter the operation succeeds, this property returns a GetUserMetadataResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The GetUserMetadataResult data type contains the following properties:

ParametersTypeDescription
UserIdstringUser ID.
DataRtmMetadataMetadata item.

The RtmMetadata data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
majorRevisionInt64Optional-1Version control switch:
- -1: Disable the version verification.
- > 0: Enable the version verification. The operation can only be performed if the target version number matches this value.
metadataItemsMetadataItem[]Required-Metadata item array.
metadataItemsSizeUInt64Required-Length of the MetadataItem[] array.

The MetadataItem data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
keystringRequired-Key.
valuestringRequired-Value.
authorUserIdstringRequired-The user ID of the editor. This value is read-only and does not support writing.
revisionInt64Optional-1
- Returns the real version number in read operations.
- Serves as a version control switch in write operations:
- -1: Disable the version verification.
- > 0: Enable version verification, only perform the operation if the target version number matches this value.
updateTsInt64Optional0Update timestamp. This value is read-only and does not support writing.

The MetadataOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
recordTsBoolOptionalfalseWhether to record the timestamp of the edits.
recordUserIdBoolOptionalfalseWhether to record the user ID of the editor.

RemoveUserMetadataAsync

Description

The RemoveUserMetadataAsync method can remove user metadata or metadata items.

After successfully removing user metadata, users who subscribe to the user and enable event listeners can receive the USER type of the OnStorageEvent event notification. See Event listeners.

Method

You can call the RemoveUserMetadataAsync method as follows:

RtmResult<RemoveUserMetadataResult>rtmClient.GetStorage().RemoveUserMetadataAsync(string userId, RtmMetadata data, MetadataOptions options);
ParametersTypeRequiredDefaultDescription
userIdstringOptionalUser ID of the current userUser ID.
dataRtmMetadataRequired-Metadata item.
optionsMetadataOptionsRequired-Options for setting the channel metadata.

The RtmMetadata data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
majorRevisionInt64Optional-1Version control switch:
- -1: Disable the version verification.
- > 0: Enable the version verification. The operation can only be performed if the target version number matches this value.
metadataItemsMetadataItem[]Required-Metadata item array.
metadataItemsSizeUInt64Required-Length of the MetadataItem[] array.

The MetadataItem data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
keystringRequired-Key.
valuestringRequired-Value.
authorUserIdstringRequired-The user ID of the editor. This value is read-only and does not support writing.
revisionInt64Optional-1
- Returns the real version number in read operations.
- Serves as a version control switch in write operations:
- -1: Disable the version verification.
- > 0: Enable version verification, only perform the operation if the target version number matches this value.
updateTsInt64Optional0Update timestamp. This value is read-only and does not support writing.

The MetadataOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
recordTsBoolOptionalfalseWhether to record the timestamp of the edits.
recordUserIdBoolOptionalfalseWhether to record the user ID of the editor.

Basic usage

var metadata = new RtmMetadata();
metadata.majorRevision = 174298270;
var metadataItem = new MetadataItem()
            {
                key = "Mute",
                revision = 174298100,
            };
var options = new MetadataOptions() {};

var (status,response) = await rtmClient.GetStorage().RemoveUserMetadataAsync("channel_name", RTM_CHANNEL_TYPE.MESSAGE, options);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Remove Channel :{0} metadata success! Channel Type is :{1}! ", response.ChannelName, response.ChannelType));
}

Return value

The RemoveUserMetadataAsync operation returns a RtmResult&lt;RemoveUserMetadataResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseRemoveUserMetadataResultAfter the operation succeeds, this property returns a RemoveUserMetadataResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The RemoveUserMetadataResult data type contains the following properties:

ParametersTypeDescription
UserIdstringUser ID.

UpdateUserMetadataAsync

Description

The UpdateUserMetadataAsync method can update existing user metadata. After successfully updating channel metadata, users who subscribe to the user and enable event listeners can receive the USER type of the OnStorageEvent event notification. See Event listeners.

Information

You cannot use this method to update metadata items which do not exist.

Method

You can call the UpdateUserMetadataAsync method as follows:

RtmResult<UpdateUserMetadataResult> rtmClient.GetStorage().UpdateUserMetadataAsync(
    string userId,
    RtmMetadata data,
    MetadataOptions options
    );
ParametersTypeRequiredDefaultDescription
userIdstringOptionalUser ID of the current userUser ID.
dataRtmMetadataRequired-Metadata item.
optionsMetadataOptionsRequired-Options for setting the channel metadata.

The RtmMetadata data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
majorRevisionInt64Optional-1Version control switch:
- -1: Disable the version verification.
- > 0: Enable the version verification. The operation can only be performed if the target version number matches this value.
metadataItemsMetadataItem[]Required-Metadata item array.
metadataItemsSizeUInt64Required-Length of the MetadataItem[] array.

The MetadataItem data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
keystringRequired-Key.
valuestringRequired-Value.
authorUserIdstringRequired-The user ID of the editor. This value is read-only and does not support writing.
revisionInt64Optional-1
- Returns the real version number in read operations.
- Serves as a version control switch in write operations:
- -1: Disable the version verification.
- > 0: Enable version verification, only perform the operation if the target version number matches this value.
updateTsInt64Optional0Update timestamp. This value is read-only and does not support writing.

The MetadataOptions data type contains the following properties:

PropertiesTypeRequiredDefaultDescription
recordTsBoolOptionalfalseWhether to record the timestamp of the edits.
recordUserIdBoolOptionalfalseWhether to record the user ID of the editor.

Basic usage

var metadata = new RtmMetadata();
metadata.majorRevision = 174298270;
 var metadataItem = new MetadataItem()
            {
                key = "Mute",
                value = "false",
                revision = 174298100,
            };
metadata.metadataItems = new MetadataItem[] { metadataItem };
metadata.metadataItemsSize = 1;
var options = new MetadataOptions()
            {
                recordUserId = true,
                recordTs = true
            };

var (status,response) = await rtmClient.GetStorage().UpdateUserMetadataAsync("Tony", data, metadataOptions);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Update User :{0} metadata success! ", response.UserId));
}

Return value

The UpdateUserMetadataAsync operation returns a RtmResult&lt;UpdateUserMetadataResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseUpdateUserMetadataResultAfter the operation succeeds, this property returns a UpdateUserMetadataResult data type, which contains the execution result of this operation.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The UpdateUserMetadataResult data type contains the following properties:

ParametersTypeDescription
userIdstringUser ID.

Lock

A critical resource can only be used by one process at a time. If a critical resource is shared between different processes, each process needs to adopt a mutually exclusive method to prevent mutual interference. Signaling provides a full set of lock solutions. By controlling different processes in a distributed system, you can solve the competition problem when users access shared resources.

Information

The client is able to set, remove, and revoke locks. We recommend that you control the permissions of these operations on the client side based on your business needs.

IRtmClient Signaling client instance

SetLockAsync

Description

You need to configure the lock name, time to live (TTL) and other parameters by calling the SetLockAsync method. If the configuration succeeds, all users in the channel receives the OnLockEvent event notifications of the SET type. For details, see Event Listeners.

Method

You can call the SetLockAsync method as follows:

RtmResult<SetLockResult> rtmClient.GetLock().SetLockAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType,
    string lockName,
    int ttl
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.
lockNamestringRequired-Lock name.
ttlNumberRequired-The expiration time of the lock. The value is in seconds, ranging from [10 to 300]. When the user who owns the lock goes offline, if the user returns to the channel within the time they can still use the lock; otherwise, the lock is released and the users who listen for the OnLockEvent event receives the RELEASED event.

Basic usage

var (status,response) = await rtmClient.GetLock().SetLockAsync("Chat_room", RTM_CHANNEL_TYPE.MESSAGE, "lock1", 30);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode {1}, because of: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Set Lock at Channel:{0} with Channel Type {1} success! Lock name is {2}", response.ChannelName, response.ChannelType, response.LockName));
}

Return value

The SetLockAsync operation returns a RtmResult&lt;SetLockResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseSetLockResultAfter the operation succeeds, this property returns a SetLockResult data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The SetLockResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringChannel name.
ChannelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.
LockNamestringLock name.

AcquireLockAsync

Description

After successfully configuring a lock, you can call the AcquireLockAsync method on the client to acquire the right to own the lock. When you acquire the lock, other users in the channel receives the ACQUIRED type of the OnLockEvent event. For details, see Event Listeners.

Method

You can call the AcquireLockAsync method as follows:

RtmResult<AcquireLockResult> rtmClient.GetLock().AcquireLockAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType,
    string lockName,
    bool retry
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.
lockNamestringRequired-Lock name.
retryboolRequired-If the lock acquisition fails, whether to retry until the acquisition succeeds or the user leaves the channel.

Basic usage

var (status,response) = await rtmClient.GetLock().AcquireLockAsync("Chat_room", RTM_CHANNEL_TYPE.MESSAGE, "lock1", false);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Acquire Lock at Channel:{0} with Channel Type {1} success! Lock name is {2}", response.ChannelName, response.ChannelType, response.LockName));
}

Return value

The AcquireLockAsync operation returns a RtmResult&lt;AcquireLockResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseAcquireLockResultAfter the operation succeeds, this property returns a AcquireLockResult data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The AcquireLockResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringChannel name.
ChannelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.
LockNamestringLock name.

ReleaseLockAsync

Description

When a user no longer needs to own a lock, the user can call the ReleaseLockAsync method on the client side to release the lock. After successful release the lock, other users in the channel receives the RELEASED type of the OnLockEvent event. See Event Listeners.

At this time, if other users want to acquire the lock, they can call the AcquireLockAsync method on the client side to compete. New users acquiring locks have the same contention priority as the users who set the retry property to automatically retry to acquire locks.

Method

You can call the ReleaseLockAsync method as follows:

RtmResult<ReleaseLockResult> rtmClient.GetLock().ReleaseLockAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType,
    string lockName
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.
lockNamestringRequired-Lock name.

Basic usage

var (status,response) = await rtmClient.GetLock().ReleaseLockAsync("Chat_room", RTM_CHANNEL_TYPE.MESSAGE, "lock1");
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Release Lock at Channel:{0} with Channel Type {1} success! Lock name is {2}", response.ChannelName, response.ChannelType, response.LockName));
}

Return value

The ReleaseLockAsync operation returns a RtmResult&lt;ReleaseLockResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseReleaseLockResultAfter the operation succeeds, this property returns a ReleaseLockResult data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The ReleaseLockResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringChannel name.
ChannelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.
LockNamestringLock name.

RevokeLockAsync

Description

When the lock is occupied, to ensure that your business is not affected, you may need to revoke the lock and give other users a chance to obtain it. Revoke the occupied lock by calling RevokeLockAsync. When the lock is revoked, all users in the channel receives the RELEASED type of the OnLockEvent event. See Event Listeners.

At this time, if other users want to acquire the lock, they can call the AcquireLockAsync method on the client side to compete. New users acquiring locks have the same contention priority as the users who set the retry property to automatically retry to acquire locks.

Method

You can call the RevokeLockAsync method as follows:

RtmResult<RevokeLockResult> rtmClient.GetLock().RevokeLockAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType,
    string lockName,
    string owner
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.
lockNamestringRequired-Lock name.
ownerstringRequired-The ID of the user who has a lock.

Basic usage

var (status,response) = await rtmClient.GetLock().RevokeLockAsync("Chat_room", RTM_CHANNEL_TYPE.MESSAGE, "lock1","Tony");
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, ErrorCode: {1}, due to: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("RevokeLock at Channel:{0} with Channel Type {1} success! Lock name is {2}", response.ChannelName, response.ChannelType, response.LockName));
}

Return value

The RevokeLockAsync operation returns a RtmResult&lt;RevokeLockResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseRevokeLockResultAfter the operation succeeds, this property returns a RevokeLockResult data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The RevokeLockResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringChannel name.
ChannelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.
LockNamestringLock name.

Description

If you want to query the lock information such as lock total number, lock name, and lock user, time to live, you can call the `` method on the client.

Method

You can call the `` method as follows:

RtmResult<GetLocksResult> rtmClient.GetLock().GetLocksAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.

Basic usage

var (status,response) = await rtmClient.GetLock().GetLockAsync("Chat_room", RTM_CHANNEL_TYPE.MESSAGE);
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, The error code is {1}, because of: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Get Lock at Channel:{0} with Channel Type {1} success! ", response.ChannelName, response.ChannelType));
}

Return value

The `` operation returns a RtmResult&lt;GetLockResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseGetLockResultAfter the operation succeeds, this property returns a GetLockResult data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The GetLockResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringChannel name.
ChannelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.
LockDetailListLockDetail[]Detailed information of locks.

The LockDetail data type contains the following properties:

PropertiesTypeDescription
LockNamestringLock name.
ownerstringThe ID of the user who has a lock.
ttlnumberThe expiration time of the lock. The value is in seconds, ranging from [10 to 300]. When the user who owns the lock goes offline, if the user returns to the channel within the time they can still use the lock; otherwise, the lock is released and the users who listen for the OnLockEvent event receives the RELEASED event.

RemoveLockAsync

Description

If you no longer need a lock, you can call the RemoveLockAsync method to remove the lock. After successfully removing the lock, all users in the channel receives the REMOVED type of OnLockEvent event notification. See Event Listeners.

Method

You can call the RemoveLockAsync method as follows:

RtmResult<RemoveLockResult> rtmClient.GetLock().RemoveLockAsync(
    string channelName,
    RTM_CHANNEL_TYPE channelType,
    string lockName
    );
ParametersTypeRequiredDefaultDescription
channelNamestringRequired-Channel name.
channelTypeRTM_CHANNEL_TYPERequired-Channel types. See RTM_CHANNEL_TYPE.
lockNamestringRequired-Lock name.

Basic usage

var (status,response) = await rtmClient.GetLock().RemoveLockAsync("Chat_room", RTM_CHANNEL_TYPE.MESSAGE, "lock1");
if (status.Error)
{
    Debug.Log(string.Format("{0} is failed, The error code is {1}, because of: {2}", status.Operation, status.ErrorCode, status.Reason));
}
else
{
    Debug.Log(string.Format("Remove Lock{0} at Channel:{1} with Channel Type {2} success! ",response.LocklName, response.ChannelName, response.ChannelType));
}

Return value

The RemoveLockAsync operation returns a RtmResult&lt;RemoveLockResult&gt; data type, including the following properties:

PropertiesTypeDescription
StatusRtmStatusNo matter whether the operation is successful, this property returns a RtmStatus data type, including the operation of the state.
ResponseRemoveLockResultAfter the operation succeeds, this property returns a RemoveLockResult data type.

The RtmStatus data type contains the following properties:

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

The RemoveLockResult data type contains the following properties:

PropertiesTypeDescription
ChannelNamestringChannel name.
ChannelTypeRTM_CHANNEL_TYPEChannel types. See RTM_CHANNEL_TYPE.
LockNamestringLock name.

Enumerated types

Enum

RTM_AREA_CODE

The region for connection, which is the region where the server the SDK connects to is located.

ValueDescription
CN0x00000001: Mainland China.
NA0x00000002: North America.
EU0x00000004: Europe.
AS0x00000008: Asia, excluding Mainland China.
JP0x00000010: Japan.
IN0x00000020: India.
GLOB0xFFFFFFFF: Global.

RTM_CHANNEL_TYPE

Channel types.

ValueDescription
MESSAGE1: Message channel.
STREAM2: Stream channel.

RTM_CONNECTION_CHANGE_REASON

Reasons causing the change of the connection state.

ValueDescription
CONNECTING0: The SDK is connecting with the server.
JOIN_SUCCESS1: The SDK has joined the channel successfully.
INTERRUPTED2: The connection between the SDK and the server is interrupted.
BANNED_BY_SERVER3: The connection between the SDK and the server is banned by the server.
JOIN_FAILED4: The SDK fails to join the channel. When the SDK fails to join the channel for more than 20 minutes, this error occurs and the SDK stops reconnecting to the channel.
LEAVE_CHANNEL5: The SDK has left the channel.
INVALID_APP_ID6: The connection failed because the App ID is not valid.
INVALID_CHANNEL_NAME7: The connection failed because the channel name is not valid.
INVALID_TOKEN8: The connection failed because the token is not valid.
TOKEN_EXPIRED9: The connection failed because the token is expired.
REJECTED_BY_SERVER10: The connection is rejected by server.
SETTING_PROXY_SERVER11: The connection state changed to reconnecting because the SDK has set a proxy server.
RENEW_TOKEN12: The connection state changed because the token is renewed.
CLIENT_IP_ADDRESS_CHANGED13: The IP address of the client has changed, possibly because the network type, IP address, or port has been changed.
KEEP_ALIVE_TIMEOUT14: Timeout for the keep-alive of the connection between the SDK and the server. The connection state changes to reconnecting.
REJOIN_SUCCESS15: The user has rejoined the channel successfully.
LOST16: The connection between the SDK and the server is lost.
ECHO_TEST17: The connection state changes due to the echo test.
CLIENT_IP_ADDRESS_CHANGED_BY_USER18: The local IP address was changed by the user. The connection state changes to reconnecting.
SAME_UID_LOGIN19: The user joined the same channel from different devices with the same UID.
TOO_MANY_BROADCASTERS20: The number of hosts in the channel has reached the upper limit.
/22: The stream channel does not exist.
INCONSISTENT_APPID23: The App ID does not match the token.
/10001: The SDK logs in to the Signaling system.
LOGOUT10002: The SDK logs out from the Signaling system.
PRESENCE_NOT_READY10003: Presence service is not ready. You need to call the LoginAsync method again to log in to the Signaling system and re-execute all operations on the SDK.

RTM_CONNECTION_STATE

SDK connection states.

ValueDescription
DISCONNECTED1: The SDK has disconnected with the server.
CONNECTING2: The SDK is connecting with the server.
CONNECTED3: The SDK has connected with the server.
RECONNECTING4: The connection is lost. The SDK is reconnecting with the server.
FAILED5: The SDK failed to connect with the server.

RTM_ENCRYPTION_MODE

Encryption mode.

ValueDescription
NONE0: No encryption.
AES_128_GCM1: AES-128-GCM mode.
AES_256_GCM2: AES-256-GCM mode.

RTM_LOCK_EVENT_TYPE

Lock event type.

ValueDescription
SNAPSHOT1: The snapshot of the lock when the user joined the channel.
SET2: The lock is set.
REMOVED3: The lock is removed.
ACQUIRED4: The lock is acquired.
RELEASED5: The lock is released.
EXPIRED6: The lock expired.

RTM_LOG_LEVEL

Log output levels.

ValueDescription
NONE0x0000: No log.
INFO0x0001: Output the log at the FATAL, ERROR, WARN, or INFO level. We recommend you set to this value.
WARN0x0002: Output the log at the FATAL, ERROR, WARN level.
ERROR0x0004: Output the log at the FATAL, ERROR level.
FATAL0x0008: Output the log at the FATAL level.

RTM_MESSAGE_PRIORITY

Message priority.

ValueDescription
HIGHEST0: Highest.
HIGH1: High.
NORMAL4: Normal.
LOW8: Low.

RTM_MESSAGE_QOS

QoS guarantee when sending topic messages.

ValueDescription
UNORDERED0: Message data is not guaranteed to arrive in order.
ORDERED1: Message data arrives in order.

RTM_MESSAGE_TYPE

Message type.

ValueDescription
BINARY0: Binary type.
STRING1: String type.

RTM_PRESENCE_EVENT_TYPE

Presence event type.

ValueDescription
SNAPSHOT1: The snapshot of the presence when the user joined the channel.
INTERVAL2: When users in the channel reach the setting value, the event notifications are sent at intervals rather than in real time.
REMOTE_JOIN3: A remote user joined the channel.
REMOTE_LEAVE4: A remote user left the channel.
REMOTE_TIMEOUT5: A remote user's connection timed out.
REMOTE_STATE_CHANGED6: A remote user's temporary state changed.
ERROR_OUT_OF_SERVICE7: The user did not enable presence when joining the channel.

RTM_PROXY_TYPE

Proxy type.

ValueDescription
NONE0: Do not enable the proxy.
HTTP1: Enable the proxy for the HTTP protocol.

RTM_STORAGE_EVENT_TYPE

Storage event type.

ValueDescription
SNAPSHOT1: When a user subscribes to channel metadata or user etadata for the first time, or joins a channel, the local user receives notifications of this type of event.
SET2: Occurs when calling SetChannelMetadataAsync or SetUserMetadataAsync. Caution: This event only occurs in incremental data update mode.
UPDATE3: Occurs when calling methods to set, update, or delete the channel metadata or user metadata.
REMOVE4: Occurs when calling RemoveChannelMetadataAsync or RemoveUserMetadataAsync. Caution: This event only occurs in incremental data update mode.

RTM_STORAGE_TYPE

Storage type.

ValueDescription
USER1: User metadata event.
CHANNEL2: Channel metadata event.

RTM_TOPIC_EVENT_TYPE

Topic event type.

ValueDescription
SNAPSHOT1: The snapshot of the topic when the user joined the channel.
REMOTE_JOIN2: A remote user joined the channel.
REMOTE_LEAVE3: A remote user left the channel.

Troubleshooting

Refer to the following information for troubleshooting API calls.

ErrorInfo

PropertyTypeDescription
ErrorboolWhether this operation is an error.
ErrorCodestringError code for this operation.
OperationstringOperation type for this operation.
ReasonstringError reason for this operation.

To find out the cause of the error and get the corresponding solution, use the errorCode field with the error codes table.

Error codes table

Refer to the following error codes table to identify and troubleshoot the problem:

Error codeError descriptionCause and solution
0OKCorrect call
-10001NOT_INITIALIZEDThe SDK is not initialized. Please initialize the RtmClient instance by calling the CreateAgoraRtmClient method before performing other operations.
-10002NOT_LOGINThe user called the API without logging in to Signaling, disconnected due to timeout, or actively logged out. Please log in to Signaling first.
-10003INVALID_APP_IDInvalid App ID:
- Check that the App ID is correct.
- Ensure that Signaling has been activated for the App ID.
-10005INVALID_TOKENInvalid Token:
- The token is invalid, check whether the Token Provider generates a valid Signaling Token.
-10006INVALID_USER_IDInvalid User ID:
- Check if user ID is empty.
- Check if the user ID contains illegal characters.
-10007INIT_SERVICE_FAILEDSDK initialization failed. Please reinitialize by calling the CreateAgoraRtmClient method.
-10008INVALID_CHANNEL_NAMEInvalid channel name:
- Check if the channel name is empty.
- Check if the channel name contains illegal characters.
-10009TOKEN_EXPIREDToken expired. Call renewToken to reacquire the Token.
-10010LOGIN_NO_SERVER_RESOURCESServer resources are limited. It is recommended to log in again.
-10011LOGIN_TIMEOUTLogin timeout. Check whether the current network is stable and switch to a stable network environment.
-10012LOGIN_REJECTEDSDK login rejected by the server:
- Check tha Signaling is activated on your App ID.
- Check if the token or userId is banned.
-10013LOGIN_ABORTEDSDK login interrupted due to unknown problem:
- Check that the current network is stable and switch to a stable network environment.
- The current userId is logged in.
-10014INVALID_PARAMETERInvalid parameter. Please check if the parameters you provided are correct.
-10015LOGIN_NOT_AUTHORIZEDNo RTM service permissions. Check that the console opens Signaling services.
-10016INCONSISTENT_APPIDInconsistent App ID. Please check whether the App ID used for initialization, login, and joining a channel are consistent.
-10017DUPLICATE_OPERATIONDuplicate operation.
-10018INSTANCE_ALREADY_RELEASEDRepeat rtm instantiation or RTMStreamChannel instantiation.
-10019INVALID_CHANNEL_TYPEInvalid channel type. The SDK only supports the following channel types. Please use the correct value:
- MESSAGE: Message Channel
- STREAM: Stream Channel
-10020INVALID_ENCRYPTION_PARAMETERMessage encryption parameters are invalid.
- Check that the encryption key generated is a String.
- Check that the generated encryption salt is Uint8Array type and that the length is 32 bytes.
- Check that the encryption method matches the encryption key and the encryption salt.
-10021OPERATION_RATE_EXCEED_LIMITATIONChannel metadata or User Metadata -related API call frequency is exceeding the limit. Please control the call frequency within 10/second.
-11001CHANNEL_NOT_JOINEDThe user has not joined the channel:
- The user is not online, offline or has not joined the channel
- Check for typos in userId.
-11002CHANNEL_NOT_SUBSCRIBEDThe user has not subscribed to the channel:
- The user is not online, offline or has not joined the channel
- Check for typos in userId.
-11003CHANNEL_EXCEED_TOPIC_USER_LIMITATIONThe number of subscribers to this topic exceeds the limit.
-11004CHANNEL_IN_REUSEIn co-channel mode, RTM released the Stream Channel.
-11005CHANNEL_INSTANCE_EXCEED_LIMITATIONThe number of created or subscribed channels exceeds the limit. See API usage limits for details.
-11006CHANNEL_IN_ERROR_STATEChannel is not available. Please recreate the Stream Channel or resubscribe to the Message Channel.
-11007CHANNEL_JOIN_FAILEDFailed to join this channel:
- Check if the number of joined channels exceeds the limit.
- Check if the channel name is illegal.
- Check if the network is disconnected.
-11008CHANNEL_INVALID_TOPIC_NAMEInvalid topic name:
- Check whether the topic name contains illegal characters.
- Check if the topic name is empty.
-11009CHANNEL_INVALID_MESSAGEInvalid message. Check whether the message type is legal, Signaling only supports string, Uint8Array type messages.
-11010CHANNEL_MESSAGE_LENGTH_EXCEED_LIMITATIONMessage length exceeded limit. Check if the message payload size exceeds the limit:
- Message Channel single message package limit is 32 KB.
- Stream Channel single message package limit is 1 KB.
-11011CHANNEL_INVALID_USER_LISTInvalid user list:
- Check if the user list is empty.
- Check if the user list contains invalid entries.
-11012CHANNEL_NOT_AVAILABLEInvalid user list:
- Check if the user list is empty
- Check if the user list contains illegal items.
-11013CHANNEL_TOPIC_NOT_SUBSCRIBEDThe topic is not subscribed.
-11014CHANNEL_EXCEED_TOPIC_LIMITATIONThe number of topics exceeds the limit.
-11015CHANNEL_JOIN_TOPIC_FAILEDFailed to join this topic. Check whether the number of added topics exceeds the limit.
-11016CHANNEL_TOPIC_NOT_JOINEDThe topic has not been joined. To send a message, you need to join the Topic first.
-11017CHANNEL_TOPIC_NOT_EXISTThe topic does not exist. Check that the topic name is correct.
-11018CHANNEL_INVALID_TOPIC_METAThe meta parameters in the topic are invalid. Check if the meta parameter exceeds 256 bytes.
-11019CHANNEL_SUBSCRIBE_TIMEOUTChannel subscription timed out. Check for broken connections.
-11020CHANNEL_SUBSCRIBE_TOO_FREQUENTThe channel subscription operation is too frequent. Make sure that the subscription operation of the same channel within a 5 seconds interval does not exceed 2 attempts.
-11021CHANNEL_SUBSCRIBE_FAILEDChannel subscription failed. Check if the number of subscribed channels exceeds the limit.
-11022CHANNEL_UNSUBSCRIBE_FAILEDFailed to unsubscribe from the channel. Check if the connection is disconnected.
-11023CHANNEL_ENCRYPT_MESSAGE_FAILEDMessage encryption failed:
- Check that the cipherKey is valid.
- Check that the salt is valid.
- Check if encryptionMode mode matches the cipherKey and salt.
-11024CHANNEL_PUBLISH_MESSAGE_FAILEDMessage publishing failed. Check for broken connections.
-11026CHANNEL_PUBLISH_MESSAGE_TIMEOUTMessage publishing timed out. Check for broken connections.
-11027CHANNEL_NOT_CONNECTEDThe SDK is disconnected from the Signaling server. Please log in again.
-11028CHANNEL_LEAVE_FAILEDFailed to leave the channel. Check for broken connections.
-11029CHANNEL_CUSTOM_TYPE_LENGTH_OVERFLOWCustom type length overflow. The length of the customType field must to be within 32 characters.
-11030CHANNEL_INVALID_CUSTOM_TYPEcustomType field is invalid. Check the customType field for illegal characters.
-11031CHANNEL_UNSUPPORTED_MESSAGE_TYPEMessage type is not supported.
-11032CHANNEL_PRESENCE_NOT_READYPresence service is not ready. Please rejoin the Stream Channel or resubscribe to the Message Channel.
-11033CHANNEL_RECEIVER_OFFLINEWhen sending a user message, the remote user is offline:
- Check if the user ID set when calling the method is correct.
- Check if the remote user is logged in and online.
-12001STORAGE_OPERATION_FAILEDStorage operation failed.
-12002STORAGE_METADATA_ITEM_EXCEED_LIMITATIONThe number of Storage Metadata Items exceeds the limit.
-12003STORAGE_INVALID_METADATA_ITEMInvalid Metadata Item.
-12004STORAGE_INVALID_ARGUMENTInvalid argument.
-12005STORAGE_INVALID_REVISIONInvalid Revision parameter.
-12006STORAGE_METADATA_LENGTH_OVERFLOWMetadata overflows.
-12007STORAGE_INVALID_LOCK_NAMEInvalid Lock name.
-12008STORAGE_LOCK_NOT_ACQUIREDThe Lock was not acquired.
-12009STORAGE_INVALID_KEYInvalid Metadata key.
-12010STORAGE_INVALID_VALUEInvalid metadata value.
-12011STORAGE_KEY_LENGTH_OVERFLOWMetadata key length overflow.
-12012STORAGE_VALUE_LENGTH_OVERFLOWMetadata value length overflow.
-12013STORAGE_DUPLICATE_KEYDuplicate Metadata Item key.
-12014STORAGE_OUTDATED_REVISIONOutdated Revision parameter.
-12015STORAGE_NOT_SUBSCRIBEThis channel is not subscribed.
-12016STORAGE_INVALID_METADATA_INSTANCEMetadata instance does not exist. Please create a Metadata instance.
-12017STORAGE_SUBSCRIBE_USER_EXCEED_LIMITATIONThe number of subscribers exceeds the limit.
-12018STORAGE_OPERATION_TIMEOUTStorage operation timed out.
-12019STORAGE_NOT_AVAILABLEThe Storage service is not available.
-13001PRESENCE_NOT_CONNECTEDThe user is not connected to the system.
-13002PRESENCE_NOT_WRITABLEPresence service is unavailable.
-13003PRESENCE_INVALID_ARGUMENTInvalid argument.
-13004PRESENCE_CACHED_TOO_MANY_STATESThe temporary user state cached before joining the channel exceeds the limit. See API usage limits for details.
-13005PRESENCE_STATE_COUNT_OVERFLOWThe number of temporary user state key/value pairs exceeds the limit. See API usage limits for details.
-13006PRESENCE_INVALID_STATE_KEYInvalid state key.
-13007PRESENCE_INVALID_STATE_VALUEInvalid state value.
-13008PRESENCE_STATE_KEY_SIZE_OVERFLOWPresence key length overflow.
-13009PRESENCE_STATE_VALUE_SIZE_OVERFLOWPresence value overflow
-13010PRESENCE_STATE_DUPLICATE_KEYRepeated state key.
-13011PRESENCE_USER_NOT_EXISTThe user does not exist.
-13012PRESENCE_OPERATION_TIMEOUTPresence operation timed out.
-13013PRESENCE_OPERATION_FAILEDPresence operation failed.
-14001LOCK_OPERATION_FAILEDLock operation failed.
-14002LOCK_OPERATION_TIMEOUTLock operation timed out.
-14003LOCK_OPERATION_PERFORMINGLock operation in progress.
-14004LOCK_ALREADY_EXISTLock already exists.
-14005LOCK_INVALID_NAMEInvalid Lock name.
-14006LOCK_NOT_ACQUIREDThe Lock was not acquired.
-14007LOCK_ACQUIRE_FAILEDFailed to acquire the Lock.
-14008LOCK_NOT_EXISTThe Lock does not exist.
-14009LOCK_NOT_AVAILABLELock service is not available.