@asteriskzuo/react-native-easemob
Version:
easemob chat sdk of react-native.
119 lines (118 loc) • 4.46 kB
TypeScript
export declare enum ChatContactGroupEvent {
CONTACT_REMOVE = 0,
CONTACT_ACCEPT = 1,
CONTACT_DECLINE = 2,
CONTACT_BAN = 3,
CONTACT_ALLOW = 4,
GROUP_CREATE = 5,
GROUP_DESTROY = 6,
GROUP_JOIN = 7,
GROUP_LEAVE = 8,
GROUP_APPLY = 9,
GROUP_APPLY_ACCEPT = 10,
GROUP_APPLY_DECLINE = 11,
GROUP_INVITE = 12,
GROUP_INVITE_ACCEPT = 13,
GROUP_INVITE_DECLINE = 14,
GROUP_KICK = 15,
GROUP_BAN = 16,
GROUP_ALLOW = 17,
GROUP_BLOCK = 18,
GROUP_UNBLOCK = 19,
GROUP_ASSIGN_OWNER = 20,
GROUP_ADD_ADMIN = 21,
GROUP_REMOVE_ADMIN = 22,
GROUP_ADD_MUTE = 23,
GROUP_REMOVE_MUTE = 24
}
export declare function ChatContactGroupEventFromNumber(params: number): ChatContactGroupEvent;
/**
* The chat connection listener.
*
* For the occasion of onDisconnected during unstable network condition, you
* don't need to reconnect manually, the chat SDK will handle it automatically.
*
* There are only two states: onConnected, onDisconnected.
*
* Note: We recommend not to update UI based on those methods, because this
* method is called on worker thread. If you update UI in those methods, other
* UI errors might be invoked. Also do not insert heavy computation work here,
* which might invoke other listeners to handle this connection event.
*
* Register:
* ```typescript
* let listener = new (class s implements ChatConnectionListener {
* onTokenWillExpire(): void {
* console.log('ConnectScreen.onTokenWillExpire');
* }
* onTokenDidExpire(): void {
* console.log('ConnectScreen.onTokenDidExpire');
* }
* onConnected(): void {
* console.log('ConnectScreen.onConnected');
* }
* onDisconnected(errorCode?: number): void {
* console.log('ConnectScreen.onDisconnected', errorCode);
* }
* })();
* ChatClient.getInstance().addConnectionListener(listener);
* ```
* Unregister:
* ```typescript
* ChatClient.getInstance().removeConnectionListener(listener);
* ```
*/
export interface ChatConnectionListener {
/**
* Occurs when the SDK connects to the chat server successfully.
*/
onConnected(): void;
/**
* Occurs when the SDK disconnect from the chat server.
*
* Note that the logout may not be performed at the bottom level when the SDK is disconnected.
*
* @param errorCode The Error code, see {@link ChatError}
*/
onDisconnected(errorCode?: number): void;
/**
* Occurs when the token has expired.
*/
onTokenWillExpire(): void;
/**
* Occurs when the token is about to expire.
*/
onTokenDidExpire(): void;
}
export interface ChatMultiDeviceListener {
onContactEvent(event?: ChatContactGroupEvent, target?: string, ext?: string): void;
onGroupEvent(event?: ChatContactGroupEvent, target?: string, usernames?: Array<string>): void;
}
export interface ChatCustomListener {
onDataReceived(map: Map<string, any>): void;
}
export interface ChatContactEventListener {
onContactAdded(userName?: string): void;
onContactDeleted(userName?: string): void;
onContactInvited(userName?: string, reason?: string): void;
onFriendRequestAccepted(userName?: string): void;
onFriendRequestDeclined(userName?: string): void;
}
export interface ChatConversationListener {
onConversationUpdate(): void;
}
export interface ChatRoomEventListener {
onChatRoomDestroyed(roomId: string, roomName?: string): void;
onMemberJoinedFromChatRoom(roomId: string, participant: string): void;
onMemberExitedFromChatRoom(roomId: string, roomName?: string, participant?: string): void;
onRemovedFromChatRoom(roomId: string, roomName?: string, participant?: string): void;
onMuteListAddedFromChatRoom(roomId: string, mutes: Array<string>, expireTime?: string): void;
onMuteListRemovedFromChatRoom(roomId: string, mutes: Array<string>): void;
onAdminAddedFromChatRoom(roomId: string, admin: string): void;
onAdminRemovedFromChatRoom(roomId: string, admin: string): void;
onOwnerChangedFromChatRoom(roomId: string, newOwner: string, oldOwner: string): void;
onAnnouncementChangedFromChatRoom(roomId: string, announcement: string): void;
onWhiteListAddedFromChatRoom(roomId: string, members: Array<string>): void;
onWhiteListRemovedFromChatRoom(roomId: string, members: Array<string>): void;
onAllChatRoomMemberMuteStateChanged(roomId: string, isAllMuted: boolean): void;
}