UNPKG

agora-react-native-rtm

Version:

React Native around the Agora RTM SDKs for Android and iOS agora

254 lines (246 loc) 5.34 kB
import { TopicMessageOptions, UserList } from './AgoraRtmBase'; /// Generated by terra, DO NOT MODIFY BY HAND. /** * The qos of rtm message. */ export enum RtmMessageQos { /** * Will not ensure that messages arrive in order. */ unordered = 0, /** * Will ensure that messages arrive in order. */ ordered = 1, } /** * The priority of rtm message. */ export enum RtmMessagePriority { /** * The highest priority */ highest = 0, /** * The high priority */ high = 1, /** * The normal priority (Default) */ normal = 4, /** * The low priority */ low = 8, } /** * Join channel options. */ export class JoinChannelOptions { /** * Token used to join channel. */ token?: string; /** * Whether to subscribe channel metadata information */ withMetadata?: boolean = false; /** * Whether to subscribe channel with user presence */ withPresence?: boolean = true; /** * Whether to subscribe channel with lock */ withLock?: boolean = false; /** * Whether to join channel in quiet mode * Quiet mode means remote user will not receive any notification when we join or * leave or change our presence state */ beQuiet?: boolean = false; constructor( props?: Partial<{ token?: string; withMetadata?: boolean; withPresence?: boolean; withLock?: boolean; beQuiet?: boolean; }> ) { Object.assign(this, props); } } /** * Join topic options. */ export class JoinTopicOptions { /** * The qos of rtm message. */ qos?: RtmMessageQos = RtmMessageQos.unordered; /** * The priority of rtm message. */ priority?: RtmMessagePriority = RtmMessagePriority.normal; /** * The metaData of topic. */ meta?: string; /** * The rtm data will sync with media */ syncWithMedia?: boolean = false; constructor( props?: Partial<{ qos?: RtmMessageQos; priority?: RtmMessagePriority; meta?: string; syncWithMedia?: boolean; }> ) { Object.assign(this, props); } } /** * Topic options. */ export class TopicOptions { /** * The list of users to subscribe. */ users?: string[]; /** * The number of users. */ userCount?: number = 0; constructor( props?: Partial<{ users?: string[]; userCount?: number; }> ) { Object.assign(this, props); } } /** * The IStreamChannel class. * * This class provides the stream channel methods that can be invoked by your app. */ export abstract class IStreamChannel { /** * Join the channel. * * @param [in] options join channel options. * @return * - 0: Success. * - < 0: Failure. */ abstract join(options: JoinChannelOptions): number; /** * 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; /** * Leave the channel. * * @return * - 0: Success. * - < 0: Failure. */ abstract leave(): number; /** * Return the channel name of this stream channel. * * @return The channel name. */ abstract getChannelName(): string; /** * Join a topic. * * @param [in] topic The name of the topic. * @param [in] options The options of the topic. * @return * - 0: Success. * - < 0: Failure. */ abstract joinTopic(topic: string, options: JoinTopicOptions): number; /** * Publish a message in the topic. * * @param [in] topic The name of the topic. * @param [in] message The content of the message. * @param [in] length The length of the message. * @param [in] option The option of the message. * @return * - 0: Success. * - < 0: Failure. */ abstract publishTopicMessage( topic: string, message: any, option: TopicMessageOptions ): number; /** * Leave the topic. * * @param [in] topic The name of the topic. * @return * - 0: Success. * - < 0: Failure. */ abstract leaveTopic(topic: string): number; /** * Subscribe a topic. * * @param [in] topic The name of the topic. * @param [in] options The options of subscribe the topic. * @return * - 0: Success. * - < 0: Failure. */ abstract subscribeTopic(topic: string, options: TopicOptions): number; /** * Unsubscribe a topic. * * @param [in] topic The name of the topic. * @return * - 0: Success. * - < 0: Failure. */ abstract unsubscribeTopic(topic: string, options: TopicOptions): number; /** * Get subscribed user list * * @param [in] topic The name of the topic. * @param [out] users The list of subscribed users. * @return * - 0: Success. * - < 0: Failure. */ abstract getSubscribedUserList(topic: string, requestId: number): UserList[]; /** * Set parameters of the stream channel * * @param [in] parameters The parameters in json format * @return * - 0: Success. * - < 0: Failure. */ abstract setParameters(parameters: string): number; /** * Release the stream channel instance. * * @return * - 0: Success. * - < 0: Failure. */ abstract release(): number; }