agora-react-native-rtm
Version:
React Native around the Agora RTM SDKs for Android and iOS agora
448 lines • 19.7 kB
TypeScript
import { EmitterSubscription } from 'react-native';
import { AgoraPeerMessage, Callback, ChannelAttributeOptions, ConnectionChangeReason, ConnectionState, ListPeerStatus, LocalInvitation, LocalInvitationError, LocalInvitationProps, LogLevel, Members, PeersOnlineStatus, PeerSubscriptionOption, RemoteInvitation, RemoteInvitationError, RemoteInvitationProps, RtmAttribute, RtmChannelAttribute, RtmChannelMember, RTMChannelMessage, RtmConnectionState, RTMLocalInvitationErrorMessage, RTMLocalInvitationMessage, RTMMemberInfo, RtmMessage, RTMPeerMessage, RTMRemoteInvitationErrorMessage, RTMRemoteInvitationMessage, SendMessageOptions, UserAttribute, UserInfo, UserProfile } from './types';
/**
* @deprecated
*/
export interface RtmEngineEvents {
/**
* @deprecated
* @event error
* @param evt The received event object
* error | occurs when wrapper emit error | on("error") |
*/
error: (evt: any) => void;
/**
* @deprecated {@link ConnectionStateChanged}
* @event connectionStateChanged
* @param evt The received event object {@link ConnectionState}
* connectionStateChanged | occurs when connection state changed |
*/
connectionStateChanged: (evt: ConnectionState) => void;
/**
* @deprecated {@link MessageReceived}
* @event messageReceived
* @param evt The received event object {@link RTMPeerMessage}
* messageReceived | occurs when message received |
*/
messageReceived: (evt: RTMPeerMessage) => void;
/**
* @deprecated {@link TokenExpired}
* @event tokenExpired
* @param evt The received event object
* tokenExpired | occurs when token has expired |
*/
tokenExpired: (evt: any) => void;
/**
* @deprecated {@link ChannelMessageReceived}
* @event channelMessageReceived
* @param evt The received event object {@link RTMChannelMessage}
* channelMessageReceived | occurs when received channel message |
*/
channelMessageReceived: (evt: RTMChannelMessage) => void;
/**
* @deprecated {@link ChannelMemberJoined}
* @event channelMemberJoined
* @param evt The received event object {@link RTMMemberInfo}
* channelMemberJoined | occurs when some one joined in the subscribed channel
*/
channelMemberJoined: (evt: RTMMemberInfo) => void;
/**
* @deprecated {@link ChannelMemberLeft}
* @event channelMemberLeft
* @param evt The received event object {@link RTMMemberInfo}
* channelMemberLeft | occurs when sone one left from u subscribed channel
*/
channelMemberLeft: (evt: RTMMemberInfo) => void;
/**
* @deprecated {@link LocalInvitationReceivedByPeer}
* @event localInvitationReceivedByPeer
* @param evt The received event object {@link RTMLocalInvitationMessage}
* localInvitationReceivedByPeer | occurs when local inviation received by peer |
*/
localInvitationReceivedByPeer: (evt: RTMLocalInvitationMessage) => void;
/**
* @deprecated {@link LocalInvitationAccepted}
* @event localInvitationAccepted
* @param evt The received event object {@link RTMLocalInvitationMessage}
* localInvitationAccepted | occurs when local invitation accepted |
*/
localInvitationAccepted: (evt: RTMLocalInvitationMessage) => void;
/**
* @deprecated {@link LocalInvitationRefused}
* @event localInvitationRefused
* @param evt The received event object {@link RTMLocalInvitationMessage}
* localInvitationRefused | occurs when local invitation refused |
*/
localInvitationRefused: (evt: RTMLocalInvitationMessage) => void;
/**
* @deprecated {@link LocalInvitationCanceled}
* @event localInvitationCanceled
* @param evt The received event object {@link RTMLocalInvitationMessage}
* localInvitationCanceled | occurs when local invitation canceled |
*/
localInvitationCanceled: (evt: RTMLocalInvitationMessage) => void;
/**
* @deprecated {@link LocalInvitationFailure}
* @event localInvitationFailure
* @param evt The received event object {@link RTMLocalInvitationErrorMessage}
* localInvitationFailure | occurs when local invitation failure |
*/
localInvitationFailure: (evt: RTMLocalInvitationErrorMessage) => void;
/**
* @deprecated {@link RemoteInvitationReceived}
* @event remoteInvitationReceived
* @param evt The received event object {@link RTMRemoteInvitationMessage}
* remoteInvitationReceived | occurs when remote invitation received |
*/
remoteInvitationReceived: (evt: RTMRemoteInvitationMessage) => void;
/**
* @deprecated {@link RemoteInvitationAccepted}
* @event remoteInvitationAccepted
* @param evt The received event object {@link RTMRemoteInvitationMessage}
* remoteInvitationAccepted | occurs when remote invitation accepted |
*/
remoteInvitationAccepted: (evt: RTMRemoteInvitationMessage) => void;
/**
* @deprecated {@link RemoteInvitationRefused}
* @event remoteInvitationRefused
* @param evt The received event object {@link RTMRemoteInvitationMessage}
* remoteInvitationRefused | occurs when remote invitation refused |
*/
remoteInvitationRefused: (evt: RTMRemoteInvitationMessage) => void;
/**
* @deprecated {@link RemoteInvitationCanceled}
* @event remoteInvitationCanceled
* @param evt The received event object {@link RTMRemoteInvitationMessage}
* remoteInvitationCanceled | occurs when remote invitation canceled |
*/
remoteInvitationCanceled: (evt: RTMRemoteInvitationMessage) => void;
/**
* @deprecated {@link RemoteInvitationFailure}
* @event remoteInvitationFailure
* @param evt The received event object {@link RTMRemoteInvitationErrorMessage}
* remoteInvitationFailure | occurs when remote invitation failure |
*/
remoteInvitationFailure: (evt: RTMRemoteInvitationErrorMessage) => void;
}
export interface RtmClientEvents {
ConnectionStateChanged: (state: RtmConnectionState, reason: ConnectionChangeReason) => void;
MessageReceived: (message: RtmMessage, peerId: string) => void;
TokenExpired: () => void;
PeersOnlineStatusChanged: (peersStatus: PeersOnlineStatus) => void;
MemberCountUpdated: (memberCount: number) => void;
ChannelAttributesUpdated: (attributeList: RtmChannelAttribute[]) => void;
ChannelMessageReceived: (message: RtmMessage, fromMember: RtmChannelMember) => void;
ChannelMemberJoined: (member: RtmChannelMember) => void;
ChannelMemberLeft: (member: RtmChannelMember) => void;
LocalInvitationReceivedByPeer: (localInvitation: LocalInvitation) => void;
LocalInvitationAccepted: (localInvitation: LocalInvitation, response?: string) => void;
LocalInvitationRefused: (localInvitation: LocalInvitation, response?: string) => void;
LocalInvitationCanceled: (localInvitation: LocalInvitation) => void;
LocalInvitationFailure: (localInvitation: LocalInvitation, errorCode: LocalInvitationError) => void;
RemoteInvitationReceived: (remoteInvitation: RemoteInvitation) => void;
RemoteInvitationAccepted: (remoteInvitation: RemoteInvitation) => void;
RemoteInvitationRefused: (remoteInvitation: RemoteInvitation) => void;
RemoteInvitationCanceled: (remoteInvitation: RemoteInvitation) => void;
RemoteInvitationFailure: (remoteInvitation: RemoteInvitation, errorCode: RemoteInvitationError) => void;
}
/**
* `RtmEngine` is the entry point of the react native agora rtm sdk. You can call the {@link createClient} method of {@link RtmEngine} to create an `RtmEngine` instance.
* @noInheritDoc
*/
export default class RtmEngine {
/**
* @ignore
*/
private _listeners;
/**
* @deprecated {@link addListener}
* supports platform: ios, android
* @events {@link RtmEngineEvents}
* @param eventName string required
* @param callback (evt) => {} required
*/
on<EventName extends keyof RtmEngineEvents>(eventName: EventName, callback: RtmEngineEvents[EventName]): void;
/**
* @deprecated {@link removeAllListeners}
*/
removeEvents(): void;
addListener<EventType extends keyof RtmClientEvents>(event: EventType, listener: RtmClientEvents[EventType]): EmitterSubscription;
removeListener<EventType extends keyof RtmClientEvents>(event: EventType, listener: RtmClientEvents[EventType]): void;
removeAllListeners<EventType extends keyof RtmClientEvents>(event?: EventType): void;
/**
* @deprecated {@link release}
* supports platform: ios, android
* This method destroy AgoraRTM instance, stop event observing, release all both remote and local invitaitons and channels resources.
* @return void
*/
destroyClient(): Promise<void>;
release(): Promise<void>;
/**
* @deprecated {@link loginV2}
* supports platform: ios, android
* This method do login with UserInfo
* @param params {@link UserInfo}
* ---
* token | string | optional |
* uid | string | required |
* ---
* @return Promise<void>
*/
login(params: UserInfo): Promise<void>;
loginV2(userId: string, token?: string): Promise<void>;
/**
* supports platform: ios, android
* This method do logout.
* @return Promise<void>
*/
logout(): Promise<void>;
/**
* @deprecated {@link sendMessageToPeerV2}
* supports platform: ios, android
* This method do send p2p message with {@link AgoraPeerMessage}
* @param params AgoraPeerMessage
* ---
* peerId | string | required |
* offline | boolean | requried |
* text | string | required |
* ---
* @return Promise<void>
*/
sendMessageToPeer(params: AgoraPeerMessage): Promise<void>;
sendMessageToPeerV2(peerId: string, message: RtmMessage, options: SendMessageOptions): Promise<void>;
/**
* @deprecated {@link queryPeersOnlineStatusV2}
* supports platform: ios, android
* This method enables query peer online user by id array.
* @param ids string array
* @return Promise<ListPeerStatus> {@link ListPeerStatus}
* ---
* items | {@link MemberStatus} |
* ---
*
* MemberStatus
* ---
* uid | string | user id|
* online | boolean | online state|
* ---
*/
queryPeersOnlineStatus(ids: string[]): Promise<ListPeerStatus>;
queryPeersOnlineStatusV2(peerIds: string[]): Promise<PeersOnlineStatus>;
subscribePeersOnlineStatus(peerIds: string[]): Promise<void>;
unsubscribePeersOnlineStatus(peerIds: string[]): Promise<void>;
queryPeersBySubscriptionOption(option: PeerSubscriptionOption): Promise<string[]>;
/**
* supports platform: ios, android
* This method do renewToken when got `tokenExpired` event.
* @param token string
* @return Promise<void>
*/
renewToken(token: string): Promise<void>;
/**
* @deprecated {@link setLocalUserAttributesV2}
* supports platform: ios, android
* This method enables set local user attributes with attributes {@link UserAttribute}
* @param attributes {@link UserAttribute []}
* @return Promise<void>
*
* UserAttribute
* ---
* key | string | required |
* value | string | required |
* ---
*/
setLocalUserAttributes(attributes: UserAttribute[]): Promise<void>;
setLocalUserAttributesV2(attributes: RtmAttribute[]): Promise<void>;
/**
* @deprecated {@link addOrUpdateLocalUserAttributes}
* supports platform: ios, android
* This method enables you to replace attribute already exists or add attribute wasn't set for local user attributes;
* @param attributes {@link UserAttribute []}
* @return Promise<void>
*/
replaceLocalUserAttributes(attributes: UserAttribute[]): Promise<void>;
addOrUpdateLocalUserAttributes(attributes: RtmAttribute[]): Promise<void>;
/**
* @deprecated {@link deleteLocalUserAttributesByKeys}
* supports platform: ios, android
* This method enables you to remove exists attribute for local user.
* @param keys string []
* @return Promise<void>
*/
removeLocalUserAttributesByKeys(keys: string[]): Promise<void>;
deleteLocalUserAttributesByKeys(attributeKeys: string[]): Promise<void>;
/**
* @deprecated {@link clearLocalUserAttributes}
* supports platform: ios, android
* This method enables you to remove all of local user attributes;
* @return Promise<void>
*/
removeAllLocalUserAttributes(): Promise<void>;
clearLocalUserAttributes(): Promise<void>;
/**
* @deprecated {@link getUserAttributes}
* supports platform: ios, android
* This method enables you get user attributes by uid.
* @param uid string. user id
* @return Promise<UserProfile> {@link UserProfile}
*/
getUserAttributesByUid(uid: string): Promise<UserProfile>;
getUserAttributes(userId: string): Promise<RtmAttribute[]>;
getUserAttributesByKeys(userId: string, attributeKeys: string[]): Promise<RtmAttribute[]>;
setChannelAttributes(channelId: string, attributes: RtmChannelAttribute[], option: ChannelAttributeOptions): Promise<void>;
addOrUpdateChannelAttributes(channelId: string, attributes: RtmChannelAttribute[], option: ChannelAttributeOptions): Promise<void>;
deleteChannelAttributesByKeys(channelId: string, attributeKeys: string[], option: ChannelAttributeOptions): Promise<void>;
clearChannelAttributes(channelId: string, option: ChannelAttributeOptions): Promise<void>;
getChannelAttributes(channelId: string): Promise<RtmChannelAttribute[]>;
getChannelAttributesByKeys(channelId: string, attributeKeys: string[]): Promise<RtmChannelAttribute[]>;
setParameters(parameters: string): Promise<void>;
/**
* @deprecated {@link setLogFile} {@link setLogFilter} {@link setLogFileSize}
* set sdk log file
* @param path string: specified the generated log path
* @param level {@link LogLevel}: sdk log level (0: "OFF", 0b1111: "INFO", 0b1110: "WARN", 0b1100: "ERROR", 0b1000: "CRITICAL")
* @param size number: file size in kbytes
* Note File size settings of less than 512 KB or greater than 10 MB will not take effect.
* @return Promise<void> This method will return {path: boolean, level: boolean, size: boolean}
*/
setSdkLog(path: string, level: LogLevel, size: number): Promise<void>;
setLogFile(filePath: string): Promise<void>;
setLogFilter(filter: LogLevel): Promise<void>;
setLogFileSize(fileSizeInKBytes: number): Promise<void>;
/**
* @deprecated {@link createInstance}
* supports platform: ios, android
* This method creates AgoraRTM instance and begin event observing, collect all both remote and local invitations and channels resources.
* method: createClient
* @param appId string
* @return void
*/
createClient(appId: string): Promise<void>;
createInstance(appId: string): Promise<void>;
/**
* @deprecated
* get the version of rtm sdk
* @param callback (version) => {} required
*/
getSdkVersion(callback: Callback): void;
static getSdkVersion(): Promise<string>;
/**
* supports platform: ios, android
* This method do join channel with channelId
* @param channelId string
* @return Promise<void>
*/
joinChannel(channelId: string): Promise<void>;
/**
* supports platform: ios, android
* This method do leave channel with channelId
* @param channelId string
* @return Promise<void>
*/
leaveChannel(channelId: string): Promise<void>;
/**
* @deprecated {@link sendMessage}
* supports platform: ios, android
* This method enables send message by channel id.
* NOTICE: text bytelength has MAX_SIZE 32kb limit.
* @param channelId string.
* @param text string (bytesize shouldn't >= 32kb)
* @return Promise<void>
*/
sendMessageByChannelId(channelId: string, text: string): Promise<void>;
sendMessage(channelId: string, message: RtmMessage, options: SendMessageOptions): Promise<void>;
/**
* @deprecated {@link getMembers}
* supports platform: ios, android
* This method enables you get members by channel id.
* @param channelId string.
* @return Promise<Members> {@link Members}}
*
* ---
* members | {@link MemberInfo} |
* ---
*
* MemberInfo
* ---
* uid | string | user id|
* channelId | string | channel id|
* ---
*/
getChannelMembersBychannelId(channelId: string): Promise<Members>;
getMembers(channelId: string): Promise<RtmChannelMember[]>;
releaseChannel(channelId: string): Promise<void>;
createLocalInvitation(calleeId: string, content?: string, channelId?: string): Promise<LocalInvitation>;
/**
* @deprecated {@link sendLocalInvitationV2}
* supports platform: ios, android
* This method enables send local invitation with invitationProps.
* NOTICE: content bytelength has MAX_SIZE 32kb limit.
* @param invitationProps {@link LocalInvitationProps}
*
* LocalInvitationProps
* ---
* uid | string | required |
* channelId | string | required |
* content | string | optional | 32kb limit |
* ---
*
* @return Promise<void>
*/
sendLocalInvitation(invitationProps: LocalInvitationProps): Promise<void>;
sendLocalInvitationV2(localInvitation: LocalInvitation): Promise<void>;
/**
* @deprecated {@link acceptRemoteInvitationV2}
* supports platform: ios, android
* This method enables accept remote invitation with RemoteInvitationProps.
* NOTICE: content bytelength has MAX_SIZE 32kb limit.
* @param remoteInvitationProps {@link RemoteInvitationProps}
*
* RemoteInvitationProps
* ---
* uid | string | required |
* channelId | string | required |
* response | string | optional | 32kb limit |
* ---
*
* @return Promise<void>
*/
acceptRemoteInvitation(remoteInvitationProps: RemoteInvitationProps): Promise<void>;
acceptRemoteInvitationV2(remoteInvitation: RemoteInvitation): Promise<void>;
/**
* @deprecated {@link refuseRemoteInvitationV2}
* supports platform: ios, android
* This method enables refuse remote invitation with RemoteInvitationProps.
* NOTICE: content bytelength has MAX_SIZE 32kb limit.
* @param remoteInvitationProps {@link RemoteInvitationProps}
*
* RemoteInvitationProps
* ---
* uid | string | required |
* channelId | string | required |
* response | string | optional | 32kb limit |
* ---
*
* @return Promise<void>
*/
refuseRemoteInvitation(remoteInvitationProps: RemoteInvitationProps): Promise<void>;
refuseRemoteInvitationV2(remoteInvitation: RemoteInvitation): Promise<void>;
/**
* @deprecated {@link cancelLocalInvitationV2}
* supports platform: ios, android
* This method enables cancel local invitation with invitationProps.
* NOTICE: content bytelength has MAX_SIZE 32kb limit.
* @param invitationProps {@link LocalInvitationProps}
*
* LocalInvitationProps
* ---
* uid | string | required |
* channelId | string | required |
* content | string | optional | 32kb limit |
* ---
*
* @return Promies<any>
*/
cancelLocalInvitation(invitationProps: LocalInvitationProps): Promise<void>;
cancelLocalInvitationV2(localInvitation: LocalInvitation): Promise<void>;
}
//# sourceMappingURL=RtmEngine.d.ts.map