Options
All
  • Public
  • Public/Protected
  • All
Menu

export manager

Hierarchy

  • Native
    • ChatRoomManager

Index

Constructors

Properties

_roomListeners: Set<ChatRoomEventListener>
_roomSubscriptions: Map<string, EmitterSubscription>
TAG: string = 'ChatRoomManager'

Methods

  • addAttributes(params: { attributes: {}[]; deleteWhenLeft?: boolean; overwrite?: boolean; roomId: string }): Promise<Map<string, string>>
  • Sets custom chat room attributes.

    params

    params

    • roomId The chat room ID.
    • attributes The chat room attributes to add. The attributes are in key-value format. In a key-value pair, the key is the attribute name that can contain 128 characters at most; the value is the attribute value that cannot exceed 4096 characters. A chat room can have a maximum of 100 custom attributes and the total length of custom chat room attributes cannot exceed 10 GB for each app. Attribute keys support the following character sets:
      • 26 lowercase English letters (a-z)
      • 26 uppercase English letters (A-Z)
      • 10 numbers (0-9)
      • "_", "-", "."
    • deleteWhenLeft: Whether to delete the chat room attributes set by the member when he or she exits the chat room.
      • (Default)true: Yes.
      • false: No.
    • overwrite: Whether to overwrite the attributes with same key set by others.
      • true: Yes.
      • (Default)false: No.
    throws

    A description of the exception. See ChatError.

    Parameters

    • params: { attributes: {}[]; deleteWhenLeft?: boolean; overwrite?: boolean; roomId: string }
      • attributes: {}[]
      • Optional deleteWhenLeft?: boolean
      • Optional overwrite?: boolean
      • roomId: string

    Returns Promise<Map<string, string>>

    If certain attributes fail to be set, the SDK returns a map of the attributes in key-value format, where the key is the attribute key and the value is the reason for the failure.

  • addChatRoomAdmin(roomId: string, admin: string): Promise<void>
  • Adds a chat room admin.

    Only the chat room owner can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • admin: string

      The user ID of the chat room admin to be added.

    Returns Promise<void>

  • addMembersToChatRoomAllowList(roomId: string, members: string[]): Promise<void>
  • Adds members to the allow list of the chat room.

    Only the chat room owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • members: string[]

      The user IDs of members to be added to the allow list of the chat room.

    Returns Promise<void>

  • blockChatRoomMembers(roomId: string, members: string[]): Promise<void>
  • Adds the specified members to the block list of the chat room.

    Only the chat room owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • members: string[]

      The user IDs of members to be added to block list of the chat room.

    Returns Promise<void>

  • changeChatRoomDescription(roomId: string, description: string): Promise<void>
  • Modifies the chat room description.

    Only the chat room owner can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • description: string

      The new description of the chat room.

    Returns Promise<void>

  • changeChatRoomSubject(roomId: string, subject: string): Promise<void>
  • Changes the chat room name.

    Only the chat room owner can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • subject: string

      The new name of the chat room.

    Returns Promise<void>

  • changeOwner(roomId: string, newOwner: string): Promise<void>
  • Transfers the chat room ownership.

    Only the chat room owner can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • newOwner: string

      The user ID of the new chat room owner.

    Returns Promise<void>

  • createChatRoom(subject: string, description?: string, welcome?: string, members?: string[], maxCount?: number): Promise<ChatRoom>
  • Creates a chat room.

    throws

    A description of the exception. See ChatError.

    Parameters

    • subject: string

      The chat room name.

    • Optional description: string

      The chat room description.

    • Optional welcome: string

      A welcome message for new chat room members.

    • Optional members: string[]

      The list of members invited to join the chat room.

    • maxCount: number = 300

      The maximum number of members allowed to join the chat room.

    Returns Promise<ChatRoom>

    The chat room instance.

  • destroyChatRoom(roomId: string): Promise<void>
  • Destroys a chat room.

    Only the chat room owner can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<void>

  • fetchChatRoomAllowListFromServer(roomId: string): Promise<string[]>
  • Gets the allow list from the server.

    Only the chat room owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<string[]>

    The allow list of the chat room.

  • fetchChatRoomAnnouncement(roomId: string): Promise<undefined | string>
  • Gets the chat room announcement from the server.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<undefined | string>

    The chat room announcement.

  • fetchChatRoomAttributes(roomId: string, keys?: string[]): Promise<Map<string, string>>
  • Gets custom chat room attributes from the server.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • Optional keys: string[]

      The key list of custom attributes to get. If you set it as null or leave it empty, this method retrieves all custom attributes.

    Returns Promise<Map<string, string>>

    Custom chat room attributes in key-value format.

  • fetchChatRoomBlockList(roomId: string, pageNum?: number, pageSize?: number): Promise<string[]>
  • Gets the chat room block list with pagination.

    Only the chat room owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • pageNum: number = 1

      The page number, starting from 1.

    • pageSize: number = 200

      The number of users on the block list that you expect to get on each page.

    Returns Promise<string[]>

    The user IDs of the chat room members on the block list.

  • fetchChatRoomInfoFromServer(roomId: string): Promise<undefined | ChatRoom>
  • Gets the details of the chat room from the server.

    By default, the details do not include the chat room member list.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<undefined | ChatRoom>

    The chat room instance. The SDK returns undefined if the chat room does not exist.

  • fetchChatRoomMembers(roomId: string, cursor?: string, pageSize?: number): Promise<ChatCursorResult<string>>
  • Gets the chat room member list.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • cursor: string = ''

      The cursor position from which to start to get data. At the first method call, if you set cursor as null or an empty string, the SDK gets the data in the reverse chronological order of when users join the chat room.

    • pageSize: number = 200

      The number of members that you expect to get on each page.

    Returns Promise<ChatCursorResult<string>>

    The list of chat room members and the cursor for the next query. See ChatCursorResult.

  • fetchChatRoomMuteList(roomId: string, pageNum?: number, pageSize?: number): Promise<string[]>
  • Uses the pagination to get the list of members who are muted in the chat room.

    This method gets data from the server.

    Only the chat room owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • pageNum: number = 1

      The page number, starting from 1.

    • pageSize: number = 200

      The number of muted members that you expect to get on each page.

    Returns Promise<string[]>

    The user IDs of muted members.

  • Gets chat room data from the server with pagination.

    throws

    A description of the exception. See ChatError.

    Parameters

    • pageNum: number = 1

      The page number, starting from 1.

    • pageSize: number = 200

      The number of chat rooms that you expect to get on each page.

    Returns Promise<ChatPageResult<ChatRoom>>

    The list of obtained chat rooms. See ChatPageResult.

  • getChatRoomWithId(roomId: string): Promise<undefined | ChatRoom>
  • Gets the chat room by ID from the local database.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<undefined | ChatRoom>

    The chat room instance. The SDK returns undefined if the chat room does not exist.

  • invokeRoomListener(params: any): void
  • Parameters

    • params: any

    Returns void

  • isMemberInChatRoomAllowList(roomId: string): Promise<boolean>
  • Checks whether the member is on the allow list of the chat room.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<boolean>

    Whether the member is on the allow list of the chat room. - true: Yes. - false: No.

  • joinChatRoom(roomId: string): Promise<void>
  • Joins the chat room.

    To leave the chat room, you can call leaveChatRoom.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The ID of the chat room to join.

    Returns Promise<void>

  • leaveChatRoom(roomId: string): Promise<void>
  • Leaves the chat room.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The ID of the chat room to leave.

    Returns Promise<void>

  • muteAllChatRoomMembers(roomId: string): Promise<void>
  • Mutes all members.

    Only the chat room owner or admin can call this method.

    The chat room owner, admins, and members added to the allow list cannot be muted.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<void>

  • muteChatRoomMembers(roomId: string, muteMembers: string[], duration?: number): Promise<void>
  • Mutes the specified members in a chat room.

    Only the chat room owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • muteMembers: string[]

      The user IDs of members to be muted.

    • duration: number = -1

      The mute duration in milliseconds.

    Returns Promise<void>

  • removeAllRoomListener(): void
  • Removes all the chat room listeners.

    Returns void

  • removeAttributes(params: { forced?: boolean; keys: string[]; roomId: string }): Promise<Map<string, string>>
  • Removes custom chat room attributes.

    params

    params

    • roomId: The chat room ID.
    • keys: The keys of the chat room attributes to remove.
    • forced: Whether to remove the attributes with same key set by others.
      • true: Yes.
      • (Default)false: No.
    throws

    A description of the exception. See ChatError.

    Parameters

    • params: { forced?: boolean; keys: string[]; roomId: string }
      • Optional forced?: boolean
      • keys: string[]
      • roomId: string

    Returns Promise<Map<string, string>>

    If certain attributes fail to be removed, the SDK returns a map of the attributes in key-value format, where the key is the attribute key and the value is the reason for the failure.

  • removeChatRoomAdmin(roomId: string, admin: string): Promise<void>
  • Removes administrative privileges of a chat room admin.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • admin: string

      The user ID of the chat room admin whose administrative privileges are to be removed.

    Returns Promise<void>

  • removeChatRoomMembers(roomId: string, members: string[]): Promise<void>
  • Removes the specified members from a chat room.

    Only the chat room owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • members: string[]

      The user IDs of the members to be removed.

    Returns Promise<void>

  • removeMembersFromChatRoomAllowList(roomId: string, members: string[]): Promise<void>
  • Removes members from the allow list of the chat room.

    Only the chat room owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • members: string[]

      The user IDs of members to be removed from the allow list of the chat room.

    Returns Promise<void>

  • Removes the chat room listener.

    Parameters

    Returns void

  • setNativeListener(event: NativeEventEmitter): void
  • Parameters

    • event: NativeEventEmitter

    Returns void

  • unBlockChatRoomMembers(roomId: string, members: string[]): Promise<void>
  • Removes the specified members from the block list of the chat room.

    Only the chat room owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • members: string[]

      The user IDs of members to be removed from the block list of the chat room.

    Returns Promise<void>

  • unMuteAllChatRoomMembers(roomId: string): Promise<void>
  • Unmutes all members of the chat room.

    Only the chat room owner or admins can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<void>

  • unMuteChatRoomMembers(roomId: string, unMuteMembers: string[]): Promise<void>
  • Unmutes the specified members in a chat room.

    Only the chat room owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • unMuteMembers: string[]

      The user IDs of members to be unmuted.

    Returns Promise<void>

  • updateChatRoomAnnouncement(roomId: string, announcement: string): Promise<void>
  • Updates the chat room announcement.

    Only the chat room owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • roomId: string

      The chat room ID.

    • announcement: string

      The new chat room announcement.

    Returns Promise<void>

  • _callMethod<T>(method: string, args?: {}): Promise<T>
  • Type Parameters

    • T

    Parameters

    • method: string
    • Optional args: {}

      Returns Promise<T>

    • checkErrorFromResult(result: any): void
    • Parameters

      • result: any

      Returns void

    Generated using TypeDoc