agora-react-native-rtm
Version:
React Native around the Agora RTM SDKs for Android and iOS agora
1,257 lines (1,243 loc) • 32.7 kB
text/typescript
import {
AffectedResources,
ChannelInfo,
ErrorCode,
HistoryMessage,
LockDetail,
PublishOptions,
RtmAreaCode,
RtmChannelType,
RtmConnectionChangeReason,
RtmConnectionState,
RtmEncryptionConfig,
RtmLinkOperation,
RtmLinkState,
RtmLinkStateChangeReason,
RtmLockEventType,
RtmLogConfig,
RtmMessageType,
RtmPresenceEventType,
RtmPrivateConfig,
RtmProtocolType,
RtmProxyConfig,
RtmServiceType,
RtmStorageEventType,
RtmStorageType,
RtmTokenEventType,
RtmTopicEventType,
StateItem,
SubscribeOptions,
TopicInfo,
UserList,
UserState,
} from './AgoraRtmBase';
import { IRtmHistory } from './IAgoraRtmHistory';
import { IRtmLock } from './IAgoraRtmLock';
import { IRtmPresence } from './IAgoraRtmPresence';
import { IRtmStorage, Metadata } from './IAgoraRtmStorage';
import { IStreamChannel } from './IAgoraStreamChannel';
/// Generated by terra, DO NOT MODIFY BY HAND.
/**
* Configurations for RTM Client.
*/
export class RtmConfig {
/**
* The App ID of your project.
*/
appId?: string;
/**
* The ID of the user.
*/
userId?: string;
/**
* The region for connection. This advanced feature applies to scenarios that
* have regional restrictions.
*
* For the regions that Agora supports, see #AREA_CODE.
*
* After specifying the region, the SDK connects to the Agora servers within
* that region.
*/
areaCode?: RtmAreaCode = RtmAreaCode.glob;
/**
* The protocol used for connecting to the Agora RTM service.
*/
protocolType?: RtmProtocolType = RtmProtocolType.tcpUdp;
/**
* Presence timeout in seconds, specify the timeout value when you lost connection between sdk
* and rtm service.
*/
presenceTimeout?: number;
/**
* Heartbeat interval in seconds, specify the interval value of sending heartbeat between sdk
* and rtm service.
*/
heartbeatInterval?: number;
/**
* Reconnection timeout in seconds, specify the timeout value for login and reconnection operations.
*
* Timeout behavior and callbacks:
* - Login timeout: Triggers onLoginResult and onLinkStateChanged
* - Reconnection timeout: Triggers onLinkStateChanged
*
* Default: 0 seconds, never timeout, keep retrying.
* Range: [15, 3600]
*/
reconnectTimeout?: number;
/**
* - For Android, it is the context of Activity or Application.
* - For Windows, it is the window handle of app. Once set, this parameter enables you to plug
* or unplug the video devices while they are powered.
*/
context?: any;
/**
* Whether to use String user IDs, if you are using RTC products with Int user IDs,
* set this value as 'false'. Otherwise errors might occur.
*/
useStringUserId?: boolean = true;
/**
* Whether to enable multipath, introduced from 2.2.0, for now , only effect on stream channel.
*/
multipath?: boolean = false;
/**
* iot devices may be restricted by isp, need to enable this feature to connect to server by domain.
* -true: connect to servers restricted by isp
* -false: (Default) connect to servers with no limit
*/
ispPolicyEnabled?: boolean = false;
/**
* The callbacks handler
*/
eventHandler?: IRtmEventHandler;
/**
* The config for customer set log path, log size and log level.
*/
logConfig?: RtmLogConfig;
/**
* The config for proxy setting
*/
proxyConfig?: RtmProxyConfig;
/**
* The config for encryption setting
*/
encryptionConfig?: RtmEncryptionConfig;
/**
* The config for private setting
*/
privateConfig?: RtmPrivateConfig;
constructor(
props?: Partial<{
appId?: string;
userId?: string;
areaCode?: RtmAreaCode;
protocolType?: RtmProtocolType;
presenceTimeout?: number;
heartbeatInterval?: number;
reconnectTimeout?: number;
context?: any;
useStringUserId?: boolean;
multipath?: boolean;
ispPolicyEnabled?: boolean;
eventHandler?: IRtmEventHandler;
logConfig?: RtmLogConfig;
proxyConfig?: RtmProxyConfig;
encryptionConfig?: RtmEncryptionConfig;
privateConfig?: RtmPrivateConfig;
}>
) {
Object.assign(this, props);
}
}
export class LinkStateEvent {
/**
* The current link state
*/
currentState?: RtmLinkState;
/**
* The previous link state
*/
previousState?: RtmLinkState;
/**
* The service type
*/
serviceType?: RtmServiceType;
/**
* The operation which trigger this event
*/
operation?: RtmLinkOperation;
/**
* The reason code of this state change event
*/
reasonCode?: RtmLinkStateChangeReason;
/**
* The reason of this state change event
*/
reason?: string;
/**
* The affected channels
*/
affectedChannels?: string[];
/**
* The affected channel count
*/
affectedChannelCount?: number;
/**
* The unrestored channels
*/
unrestoredChannels?: string[];
/**
* The unrestored channel count
*/
unrestoredChannelCount?: number;
/**
* Is resumed from disconnected state
*/
isResumed?: boolean;
/**
* RTM server UTC time
*/
timestamp?: number;
constructor(
props?: Partial<{
currentState?: RtmLinkState;
previousState?: RtmLinkState;
serviceType?: RtmServiceType;
operation?: RtmLinkOperation;
reasonCode?: RtmLinkStateChangeReason;
reason?: string;
affectedChannels?: string[];
affectedChannelCount?: number;
unrestoredChannels?: string[];
unrestoredChannelCount?: number;
isResumed?: boolean;
timestamp?: number;
}>
) {
Object.assign(this, props);
}
}
export class MessageEvent {
/**
* Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE
*/
channelType?: RtmChannelType;
/**
* Message type
*/
messageType?: RtmMessageType;
/**
* The channel which the message was published
*/
channelName?: string;
/**
* If the channelType is RTM_CHANNEL_TYPE_STREAM, which topic the message came from. only for RTM_CHANNEL_TYPE_STREAM
*/
channelTopic?: string;
/**
* The payload
*/
message?: string;
/**
* The payload length
*/
messageLength?: number;
/**
* The publisher
*/
publisher?: string;
/**
* The custom type of the message
*/
customType?: string;
/**
* RTM server UTC time
*/
timestamp?: number;
constructor(
props?: Partial<{
channelType?: RtmChannelType;
messageType?: RtmMessageType;
channelName?: string;
channelTopic?: string;
message?: string;
messageLength?: number;
publisher?: string;
customType?: string;
timestamp?: number;
}>
) {
Object.assign(this, props);
}
}
export class IntervalInfo {
/**
* Joined users during this interval
*/
joinUserList?: UserList;
/**
* Left users during this interval
*/
leaveUserList?: UserList;
/**
* Timeout users during this interval
*/
timeoutUserList?: UserList;
/**
* The user state changed during this interval
*/
userStateList?: UserState[];
/**
* The user count
*/
userStateCount?: number;
constructor(
props?: Partial<{
joinUserList?: UserList;
leaveUserList?: UserList;
timeoutUserList?: UserList;
userStateList?: UserState[];
userStateCount?: number;
}>
) {
Object.assign(this, props);
}
}
export class TopicEvent {
/**
* Indicate topic event type
*/
type?: RtmTopicEventType;
/**
* The channel which the topic event was triggered
*/
channelName?: string;
/**
* The user who triggered this event.
*/
publisher?: string;
/**
* Topic information array.
*/
topicInfos?: TopicInfo[];
/**
* The count of topicInfos.
*/
topicInfoCount?: number;
/**
* RTM server UTC time
*/
timestamp?: number;
constructor(
props?: Partial<{
type?: RtmTopicEventType;
channelName?: string;
publisher?: string;
topicInfos?: TopicInfo[];
topicInfoCount?: number;
timestamp?: number;
}>
) {
Object.assign(this, props);
}
}
export class SnapshotInfo {
/**
* The user state in this snapshot event
*/
userStateList?: UserState[];
/**
* The user count
*/
userCount?: number;
constructor(
props?: Partial<{
userStateList?: UserState[];
userCount?: number;
}>
) {
Object.assign(this, props);
}
}
export class PresenceEvent {
/**
* Indicate presence event type
*/
type?: RtmPresenceEventType;
/**
* Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE
*/
channelType?: RtmChannelType;
/**
* The channel which the presence event was triggered
*/
channelName?: string;
/**
* The user who triggered this event.
*/
publisher?: string;
/**
* The user states
*/
stateItems?: StateItem[];
/**
* The states count
*/
stateItemCount?: number;
/**
* Only valid when in interval mode
*/
interval?: IntervalInfo;
/**
* Only valid when receive snapshot event
*/
snapshot?: SnapshotInfo;
/**
* RTM server UTC time
*/
timestamp?: number;
constructor(
props?: Partial<{
type?: RtmPresenceEventType;
channelType?: RtmChannelType;
channelName?: string;
publisher?: string;
stateItems?: StateItem[];
stateItemCount?: number;
interval?: IntervalInfo;
snapshot?: SnapshotInfo;
timestamp?: number;
}>
) {
Object.assign(this, props);
}
}
export class LockEvent {
/**
* Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE
*/
channelType?: RtmChannelType;
/**
* Lock event type, indicate lock states
*/
eventType?: RtmLockEventType;
/**
* The channel which the lock event was triggered
*/
channelName?: string;
/**
* The detail information of locks
*/
lockDetailList?: LockDetail[];
/**
* The count of locks
*/
count?: number;
/**
* RTM server UTC time
*/
timestamp?: number;
constructor(
props?: Partial<{
channelType?: RtmChannelType;
eventType?: RtmLockEventType;
channelName?: string;
lockDetailList?: LockDetail[];
count?: number;
timestamp?: number;
}>
) {
Object.assign(this, props);
}
}
export class StorageEvent {
/**
* Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE
*/
channelType?: RtmChannelType;
/**
* Storage type, RTM_STORAGE_TYPE_USER or RTM_STORAGE_TYPE_CHANNEL
*/
storageType?: RtmStorageType;
/**
* Indicate storage event type
*/
eventType?: RtmStorageEventType;
/**
* The target name of user or channel, depends on the RTM_STORAGE_TYPE
*/
target?: string;
/**
* The metadata information
*/
data?: Metadata;
/**
* RTM server UTC time
*/
timestamp?: number;
constructor(
props?: Partial<{
channelType?: RtmChannelType;
storageType?: RtmStorageType;
eventType?: RtmStorageEventType;
target?: string;
data?: Metadata;
timestamp?: number;
}>
) {
Object.assign(this, props);
}
}
export class TokenEvent {
/**
* The type of token event
*/
eventType?: RtmTokenEventType;
/**
* The reason of the token event, description of token event type
*/
reason?: string;
/**
* The affected resources
*/
affectedResources?: AffectedResources;
/**
* RTM server UTC time
*/
timestamp?: number;
constructor(
props?: Partial<{
eventType?: RtmTokenEventType;
reason?: string;
affectedResources?: AffectedResources;
timestamp?: number;
}>
) {
Object.assign(this, props);
}
}
/**
* The IRtmEventHandler class.
*
* The SDK uses this class to send callback event notifications to the app, and the app inherits
* the methods in this class to retrieve these event notifications.
*
* All methods in this class have their default (empty) implementations, and the app can inherit
* only some of the required events instead of all. In the callback methods, the app should avoid
* time-consuming tasks or calling blocking APIs, otherwise the SDK may not work properly.
*/
export interface IRtmEventHandler {
/**
* Occurs when link state change
*
* @param event details of link state event
*/
onLinkStateEvent?(event: LinkStateEvent): void;
/**
* Occurs when receive a message.
*
* @param event details of message event.
*/
onMessageEvent?(event: MessageEvent): void;
/**
* Occurs when remote user presence changed
*
* @param event details of presence event.
*/
onPresenceEvent?(event: PresenceEvent): void;
/**
* Occurs when remote user join/leave topic or when user first join this channel,
* got snapshot of topics in this channel
*
* @param event details of topic event.
*/
onTopicEvent?(event: TopicEvent): void;
/**
* Occurs when lock state changed
*
* @param event details of lock event.
*/
onLockEvent?(event: LockEvent): void;
/**
* Occurs when receive storage event
*
* @param event details of storage event.
*/
onStorageEvent?(event: StorageEvent): void;
/**
* Occurs when receive token event
*
* @param event details of token event.
*/
onTokenEvent?(event: TokenEvent): void;
/**
* Occurs when user join a stream channel.
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param userId The id of the user.
* @param errorCode The error code.
*/
onJoinResult?(
requestId: number,
channelName: string,
userId: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user leave a stream channel.
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param userId The id of the user.
* @param errorCode The error code.
*/
onLeaveResult?(
requestId: number,
channelName: string,
userId: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user publish topic message.
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param topic The name of the topic.
* @param errorCode The error code.
*/
onPublishTopicMessageResult?(
requestId: number,
channelName: string,
topic: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user join topic.
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param userId The id of the user.
* @param topic The name of the topic.
* @param meta The meta of the topic.
* @param errorCode The error code.
*/
onJoinTopicResult?(
requestId: number,
channelName: string,
userId: string,
topic: string,
meta: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user leave topic.
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param userId The id of the user.
* @param topic The name of the topic.
* @param meta The meta of the topic.
* @param errorCode The error code.
*/
onLeaveTopicResult?(
requestId: number,
channelName: string,
userId: string,
topic: string,
meta: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user subscribe topic.
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param userId The id of the user.
* @param topic The name of the topic.
* @param succeedUsers The subscribed users.
* @param failedUser The failed to subscribe users.
* @param errorCode The error code.
*/
onSubscribeTopicResult?(
requestId: number,
channelName: string,
userId: string,
topic: string,
succeedUsers: UserList,
failedUsers: UserList,
errorCode: ErrorCode
): void;
/**
* Occurs when user call unsubscribe topic.
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param topic The name of the topic.
* @param errorCode The error code.
*/
onUnsubscribeTopicResult?(
requestId: number,
channelName: string,
topic: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user call get subscribe user list.
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param topic The name of the topic.
* @param users The subscribed user list.
* @param errorCode The error code.
*/
onGetSubscribedUserListResult?(
requestId: number,
channelName: string,
topic: string,
users: UserList,
errorCode: ErrorCode
): void;
/**
* @deprecated This callback is deprecated. Use LinkStateEvent instead.
* Occurs when the connection state changes between rtm sdk and agora service.
*
* @param channelName The name of the channel.
* @param state The new connection state.
* @param reason The reason for the connection state change.
*/
onConnectionStateChanged?(
channelName: string,
state: RtmConnectionState,
reason: RtmConnectionChangeReason
): void;
/**
* Occurs when token will expire in 30 seconds.
*
* @param channelName The name of the channel.
*/
onTokenPrivilegeWillExpire?(channelName: string): void;
/**
* Occurs when subscribe a channel
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param errorCode The error code.
*/
onSubscribeResult?(
requestId: number,
channelName: string,
errorCode: ErrorCode
): void;
/**
* Occurs when unsubscribe a channel
*
* @param requestId The related request id when user unsubscribe.
* @param channelName The name of the channel.
* @param errorCode The error code.
*/
onUnsubscribeResult?(
requestId: number,
channelName: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user publish message.
*
* @param requestId The related request id when user publish message
* @param errorCode The error code.
*/
onPublishResult?(requestId: number, errorCode: ErrorCode): void;
/**
* Occurs when user login.
*
* @param requestId The related request id when user perform this operation
* @param errorCode The error code.
*/
onLoginResult?(requestId: number, errorCode: ErrorCode): void;
/**
* Occurs when user logout.
*
* @param requestId The related request id when user perform this operation.
* @param errorCode The error code.
*/
onLogoutResult?(requestId: number, errorCode: ErrorCode): void;
/**
* Occurs when user renew token.
*
* @param requestId The related request id when user renew token.
* @param serverType The type of server.
* @param channelName The name of the channel.
* @param errorCode The error code.
*/
onRenewTokenResult?(
requestId: number,
serverType: RtmServiceType,
channelName: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user setting the channel metadata
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param channelType The type of the channel.
* @param errorCode The error code.
*/
onSetChannelMetadataResult?(
requestId: number,
channelName: string,
channelType: RtmChannelType,
errorCode: ErrorCode
): void;
/**
* Occurs when user updating the channel metadata
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param channelType The type of the channel.
* @param errorCode The error code.
*/
onUpdateChannelMetadataResult?(
requestId: number,
channelName: string,
channelType: RtmChannelType,
errorCode: ErrorCode
): void;
/**
* Occurs when user removing the channel metadata
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param channelType The type of the channel.
* @param errorCode The error code.
*/
onRemoveChannelMetadataResult?(
requestId: number,
channelName: string,
channelType: RtmChannelType,
errorCode: ErrorCode
): void;
/**
* Occurs when user try to get the channel metadata
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param channelType The type of the channel.
* @param data The result metadata of getting operation.
* @param errorCode The error code.
*/
onGetChannelMetadataResult?(
requestId: number,
channelName: string,
channelType: RtmChannelType,
data: Metadata,
errorCode: ErrorCode
): void;
/**
* Occurs when user setting the user metadata
*
* @param requestId The related request id when user perform this operation
* @param userId The id of the user.
* @param errorCode The error code.
*/
onSetUserMetadataResult?(
requestId: number,
userId: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user updating the user metadata
*
* @param requestId The related request id when user perform this operation
* @param userId The id of the user.
* @param errorCode The error code.
*/
onUpdateUserMetadataResult?(
requestId: number,
userId: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user removing the user metadata
*
* @param requestId The related request id when user perform this operation
* @param userId The id of the user.
* @param errorCode The error code.
*/
onRemoveUserMetadataResult?(
requestId: number,
userId: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user try to get the user metadata
*
* @param requestId The related request id when user perform this operation
* @param userId The id of the user.
* @param data The result metadata of getting operation.
* @param errorCode The error code.
*/
onGetUserMetadataResult?(
requestId: number,
userId: string,
data: Metadata,
errorCode: ErrorCode
): void;
/**
* Occurs when user subscribe a user metadata
*
* @param requestId The related request id when user perform this operation
* @param userId The id of the user.
* @param errorCode The error code.
*/
onSubscribeUserMetadataResult?(
requestId: number,
userId: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user unsubscribe a user metadata
*
* @param requestId The related request id when user perform this operation
* @param userId The id of the user.
* @param errorCode The error code.
*/
onUnsubscribeUserMetadataResult?(
requestId: number,
userId: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user set a lock
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param channelType The type of the channel.
* @param lockName The name of the lock.
* @param errorCode The error code.
*/
onSetLockResult?(
requestId: number,
channelName: string,
channelType: RtmChannelType,
lockName: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user delete a lock
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param channelType The type of the channel.
* @param lockName The name of the lock.
* @param errorCode The error code.
*/
onRemoveLockResult?(
requestId: number,
channelName: string,
channelType: RtmChannelType,
lockName: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user release a lock
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param channelType The type of the channel.
* @param lockName The name of the lock.
* @param errorCode The error code.
*/
onReleaseLockResult?(
requestId: number,
channelName: string,
channelType: RtmChannelType,
lockName: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user acquire a lock
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param channelType The type of the channel.
* @param lockName The name of the lock.
* @param errorCode The error code.
* @param errorDetails The details of error.
*/
onAcquireLockResult?(
requestId: number,
channelName: string,
channelType: RtmChannelType,
lockName: string,
errorCode: ErrorCode,
errorDetails: string
): void;
/**
* Occurs when user revoke a lock
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param channelType The type of the channel.
* @param lockName The name of the lock.
* @param errorCode The error code.
*/
onRevokeLockResult?(
requestId: number,
channelName: string,
channelType: RtmChannelType,
lockName: string,
errorCode: ErrorCode
): void;
/**
* Occurs when user try to get locks from the channel
*
* @param requestId The related request id when user perform this operation
* @param channelName The name of the channel.
* @param channelType The type of the channel.
* @param lockDetailList The details of the locks.
* @param count The count of the locks.
* @param errorCode The error code.
*/
onGetLocksResult?(
requestId: number,
channelName: string,
channelType: RtmChannelType,
lockDetailList: LockDetail[],
count: number,
errorCode: ErrorCode
): void;
/**
* Occurs when query who joined this channel
*
* @param requestId The related request id when user perform this operation
* @param userStatesList The states the users.
* @param count The user count.
* @param nextPage The next page.
* @param errorCode The error code.
*/
onWhoNowResult?(
requestId: number,
userStateList: UserState[],
count: number,
nextPage: string,
errorCode: ErrorCode
): void;
/**
* Occurs when query who joined this channel
*
* @param requestId The related request id when user perform this operation
* @param userStatesList The states the users.
* @param count The user count.
* @param nextPage The next page.
* @param errorCode The error code.
*/
onGetOnlineUsersResult?(
requestId: number,
userStateList: UserState[],
count: number,
nextPage: string,
errorCode: ErrorCode
): void;
/**
* Occurs when query which channels the user joined
*
* @param requestId The related request id when user perform this operation
* @param channels The channel informations.
* @param count The channel count.
* @param errorCode The error code.
*/
onWhereNowResult?(
requestId: number,
channels: ChannelInfo[],
count: number,
errorCode: ErrorCode
): void;
/**
* Occurs when query which channels the user joined
*
* @param requestId The related request id when user perform this operation
* @param channels The channel informations.
* @param count The channel count.
* @param errorCode The error code.
*/
onGetUserChannelsResult?(
requestId: number,
channels: ChannelInfo[],
count: number,
errorCode: ErrorCode
): void;
/**
* Occurs when set user presence
*
* @param requestId The related request id when user perform this operation
* @param errorCode The error code.
*/
onPresenceSetStateResult?(requestId: number, errorCode: ErrorCode): void;
/**
* Occurs when delete user presence
*
* @param requestId The related request id when user perform this operation
* @param errorCode The error code.
*/
onPresenceRemoveStateResult?(requestId: number, errorCode: ErrorCode): void;
/**
* Occurs when get user presence
*
* @param requestId The related request id when user perform this operation
* @param states The user states
* @param errorCode The error code.
*/
onPresenceGetStateResult?(
requestId: number,
state: UserState,
errorCode: ErrorCode
): void;
/**
* Occurs when get history messages
*
* @param requestId The related request id when user perform this operation
* @param messageList The history message list.
* @param count The message count.
* @param newStart The timestamp of next history message. If newStart is 0, means there are no more history messages
* @param errorCode The error code.
*/
onGetHistoryMessagesResult?(
requestId: number,
messageList: HistoryMessage[],
count: number,
newStart: number,
errorCode: ErrorCode
): void;
}
/**
* The IRtmClient class.
*
* This class provides the main methods that can be invoked by your app.
*
* IRtmClient is the basic interface class of the Agora RTM SDK.
* Creating an IRtmClient object and then calling the methods of
* this object enables you to use Agora RTM SDK's functionality.
*/
export abstract class IRtmClient {
/**
* Release the rtm client instance.
*
* @return
* - 0: Success.
* - < 0: Failure.
*/
abstract release(): number;
/**
* Login the Agora RTM service. The operation result will be notified by \ref agora::rtm::IRtmEventHandler::onLoginResult callback.
*
* @param [in] token Token used to login RTM service.
* @return
* - 0: Success.
* - < 0: Failure.
*/
abstract login(token: string): number;
/**
* Logout the Agora RTM service. Be noticed that this method will break the rtm service including storage/lock/presence.
*
* @return
* - 0: Success.
* - < 0: Failure.
*/
abstract logout(): number;
/**
* Get the storage instance.
*
* @return
* - return NULL if error occurred
*/
abstract getStorage(): IRtmStorage;
/**
* Get the lock instance.
*
* @return
* - return NULL if error occurred
*/
abstract getLock(): IRtmLock;
/**
* Get the presence instance.
*
* @return
* - return NULL if error occurred
*/
abstract getPresence(): IRtmPresence;
/**
* Get the history instance.
*
* @return
* - return NULL if error occurred
*/
abstract getHistory(): IRtmHistory;
/**
* Renews the token. Once a token is enabled and used, it expires after a certain period of time.
* You should generate a new token on your server, call this method to renew it.
*
* @param [in] token Token used renew.
* - 0: Success.
* - < 0: Failure.
*/
abstract renewToken(token: string): number;
/**
* Publish a message in the channel.
*
* @param [in] channelName The name of the channel.
* @param [in] message The content of the message.
* @param [in] length The length of the message.
* @param [in] option The option of the message.
* @param [out] requestId The related request id of this operation.
* @return
* - 0: Success.
* - < 0: Failure.
*/
abstract publish(
channelName: string,
message: any,
length: number,
option: PublishOptions
): number;
/**
* Subscribe a channel.
*
* @param [in] channelName The name of the channel.
* @param [in] options The options of subscribe the channel.
* @return
* - 0: Success.
* - < 0: Failure.
*/
abstract subscribe(channelName: string, options: SubscribeOptions): number;
/**
* Unsubscribe a channel.
*
* @param [in] channelName The name of the channel.
* @return
* - 0: Success.
* - < 0: Failure.
*/
abstract unsubscribe(channelName: string): number;
/**
* Create a stream channel instance.
*
* @param [in] channelName The Name of the channel.
* @param [out] errorCode The error code.
* @return
* - return NULL if error occurred
*/
abstract createStreamChannel(channelName: string): {
errorCode: number;
result: IStreamChannel;
};
/**
* Set parameters of the sdk or engine
*
* @param [in] parameters The parameters in json format
* @return
* - 0: Success.
* - < 0: Failure.
*/
abstract setParameters(parameters: string): number;
}