Options
All
  • Public
  • Public/Protected
  • All
Menu

Chatroom contains APIs for chatroom-related operations.

Index

Functions

  • createChatRoom(this: any, params: { description: string; maxusers: number; members?: string[]; name: string; token: string; error?: any; success?: any }): Promise<AsyncResult<CreateChatRoomResult>>
  • Creates a chat room.

    connection.createChatRoom({name: 'myChatRoom', description: 'this is my chatroom', maxusers: 200, members: ['user1'], token: 'your token'})
    

    Parameters

    • this: any
    • params: { description: string; maxusers: number; members?: string[]; name: string; token: string; error?: any; success?: any }
      • description: string

        The description of the chat room.

      • maxusers: number

        The maximum number of members in the chat room, including the chat room creator. The value is an integer in the range of [1,5000], with 200 as the default.

      • Optional members?: string[]

        (Optional) The members in the chat room. An array of user IDs of members. If you set this parameter, ensure that the array contains at least one user ID.

      • name: string

        The chat room name.

      • token: string

        The super admin token.

      • error?:function
      • success?:function

    Returns Promise<AsyncResult<CreateChatRoomResult>>

  • getChatRoomAllowlist(this: any, params: { chatRoomId: string; error: any; success: any }): Promise<AsyncResult<UserId[]>>
  • Gets the allow list of the chat room.

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

    connection.getChatRoomWhitelist({chatRoomId: 'chatRoomId'})
    

    Parameters

    • this: any
    • params: { chatRoomId: string; error: any; success: any }

    Returns Promise<AsyncResult<UserId[]>>

  • Gets all of the chat room custom attributes.

    connection.getChatRoomAttributes({chatRoomId: 'chatRoomId', attributes:["attributeKey1","attributeKey2"]})
    

    Parameters

    • this: any
    • params: { attributeKeys?: string[]; chatRoomId: string }
      • Optional attributeKeys?: string[]

        The custom attribute to get. If you pass the attribute key, the SDK returns the attribute value. If you set it as null, the SDK returns all the attributes value.

      • chatRoomId: string

        The chat room ID.

    Returns Promise<AsyncResult<GetChatroomAttributesResult>>

  • getChatRoomBlocklist(this: any, params: { chatRoomId: string; error?: any; success?: any }): Promise<AsyncResult<UserId[]>>
  • Gets the block list of the chat room.

    connection.getChatRoomBlocklist({chatRoomId: 'chatRoomId'})
    

    Parameters

    • this: any
    • params: { chatRoomId: string; error?: any; success?: any }

    Returns Promise<AsyncResult<UserId[]>>

  • Gets the chat room list with pagination.

    connection.getChatRooms({pagenum: 1, pagesize: 20})
    

    Parameters

    • this: any
    • params: { pagenum: number; pagesize: number; error?: any; success?: any }

    Returns Promise<AsyncResult<GetChatRoomsResult>>

  • isInChatRoomMutelist(this: any, params: { chatRoomId: string }): Promise<boolean>
  • Check whether you are on the chat room mute list.

    connection.isInChatRoomMutelist({chatRoomId: 'chatRoomId'})
    

    Parameters

    • this: any
    • params: { chatRoomId: string }
      • chatRoomId: string

        The chat room ID.

    Returns Promise<boolean>

  • leaveChatRoom(this: any, params: { roomId: string; error?: any; success?: any }): Promise<AsyncResult<{ result: boolean }>>
  • Exits the chat room.

    note

    When a member exits the chat room, other members will receive "operation: 'memberAbsence'" in the callback of onChatroomEvent.

    connection.leaveChatRoom({roomId: 'roomId'})
    

    Parameters

    • this: any
    • params: { roomId: string; error?: any; success?: any }

    Returns Promise<AsyncResult<{ result: boolean }>>

  • listChatRoomMembers(this: any, params: { chatRoomId: string; pageNum: number; pageSize: number; error?: any; success?: any }): Promise<AsyncResult<{ member: string }[]>>
  • Lists all chat room members with pagination.

    connection.listChatRoomMembers({pageNum: 1, pageSize: 20, chatRoomId: 'chatRoomId'})
    

    Parameters

    • this: any
    • params: { chatRoomId: string; pageNum: number; pageSize: number; error?: any; success?: any }
      • chatRoomId: string

        The chat room ID.

      • pageNum: number

        The page number, starting from 1.

      • pageSize: number

        The number of members that you expect to get on each page. The value range is [1,1000].

      • error?:function
      • success?:function
        • Parameters

          Returns void

    Returns Promise<AsyncResult<{ member: string }[]>>

  • modifyChatRoom(this: any, params: { chatRoomId: string; chatRoomName: string; description: string; maxusers: number; error?: any; success?: any }): Promise<AsyncResult<ModifyChatRoomResult>>
  • Modifies the specifications of the chat room.

    connection.modifyChatRoom({chatRoomId: 'chatRoomId', chatRoomName: 'chatRoomName', description: 'description', maxusers: 5000})
    

    Parameters

    • this: any
    • params: { chatRoomId: string; chatRoomName: string; description: string; maxusers: number; error?: any; success?: any }

    Returns Promise<AsyncResult<ModifyChatRoomResult>>

  • muteChatRoomMember(this: any, params: { chatRoomId: string; muteDuration: number; username: string; error?: any; success?: any }): Promise<AsyncResult<MuteChatRoomMemberResult>>
  • Mutes chat room member.

    note

    Only the chat room owner or admins can call this method. The muted member and other admins will receive "operation:'muteMember'" in the callback of onChatroomEvent.

    connection.muteChatRoomMember({username: 'user1', muteDuration: -1, chatRoomId: 'chatRoomId'})
    

    Parameters

    • this: any
    • params: { chatRoomId: string; muteDuration: number; username: string; error?: any; success?: any }

    Returns Promise<AsyncResult<MuteChatRoomMemberResult>>

  • Removes chat room admins.

    note

    Only the chat room owner can call this method. The users whose admin privileges are removed will receive "operation: 'removeAdmin'" in the callback of onChatroomEvent.

    connection.removeChatRoomAdmin({chatRoomId: 'chatRoomId', username: 'user1'})
    

    Parameters

    Returns Promise<AsyncResult<RemoveChatRoomAdminResult>>

  • Removes members from the allow list of the chat room. Only the chat room owner or admin can call this method. The users who are removed will receive "operation:'removeAllowlistMember'" in the callback of onChatroomEvent..

    connection.removeChatRoomAllowlistMember({chatRoomId: 'chatRoomId', userName: 'user1'})
    

    Parameters

    Returns Promise<AsyncResult<ChatRoomType.CommonRequestResult>>

  • removeChatRoomAttribute(this: any, params: { attributeKey: string; chatRoomId: string; isForced?: boolean }): Promise<void>
  • Removes a chat room attribute.

    connection.removeChatRoomAttributes({chatRoomId: 'chatRoomId', attributeKeys: ['string1','string2'], isForced: boolean })
    

    Parameters

    • this: any
    • params: { attributeKey: string; chatRoomId: string; isForced?: boolean }
      • attributeKey: string

        The key of the chat room attribute to delete.

      • chatRoomId: string

        The chat room ID.

      • Optional isForced?: boolean

        Whether to allow a member to overwrite any chat room attribute set by any member.

        • true: Yes;
        • (Default)false: No.

    Returns Promise<void>

  • removeChatRoomAttributes(this: any, params: { attributeKeys: string[]; chatRoomId: string; isForced?: boolean }): Promise<AsyncResult<ChatroomAttributes>>
  • Removes custom chat room attributes.

    connection.removeChatRoomAttributes({chatRoomId: 'chatRoomId', attributeKeys: ['attributeKey1','attributeKey2'], isForced: false })
    

    Parameters

    • this: any
    • params: { attributeKeys: string[]; chatRoomId: string; isForced?: boolean }
      • attributeKeys: string[]

        The array of keys of attributes to remove. The array can contain a maximum number of 10 attribute keys.

      • chatRoomId: string

        The chat room ID.

      • Optional isForced?: boolean

        Whether to allow chat room members to overwrite the chat room attributes set by others.

        • true: Yes;
        • (Default)false: No.

    Returns Promise<AsyncResult<ChatroomAttributes>>

  • Sets a member as the chat room admin.

    note

    Only the chat room owner can call this method. The new admin will receive "operation: 'setAdmin'" in the callback of onChatroomEvent.

    connection.setChatRoomAdmin({chatRoomId: 'chatRoomId', username: 'user1'})
    

    Parameters

    Returns Promise<AsyncResult<SetChatRoomAdminResult>>

  • setChatRoomAttribute(this: any, params: { attributeKey: string; attributeValue: string; autoDelete?: boolean; chatRoomId: string; isForced?: boolean }): Promise<void>
  • Sets a custom chat room attribute.

    connection.setChatroomAttribute({chatRoomId: 'chatRoomId', attributeKey: "attributeKey1", attributeValue: "attributeValue1", autoDelete: true, isForced: false})
    

    Parameters

    • this: any
    • params: { attributeKey: string; attributeValue: string; autoDelete?: boolean; chatRoomId: string; isForced?: boolean }
      • attributeKey: string

        The chat room attribute key. A single key cannot exceed 128 characters; the total number of keys in a chat room cannot exceed 100. The following character sets are supported:

        • 26 lowercase English letters (a-z)
        • 26 uppercase English letters (A-Z)
        • 10 numbers (0-9)
        • "_", "-", "."
      • attributeValue: string

        The chat room attribute value. The attribute value can contain a maximum of 4096 characters. The total length of custom chat room attributes cannot exceed 10 GB for each app.

      • Optional autoDelete?: boolean

        Whether to delete chat room attributes set by the member when he or she exits the chat room.

        • (Default)true: Yes;
        • false: No.
      • chatRoomId: string

        The chat room ID.

      • Optional isForced?: boolean

        Whether to delete chat room attributes set by the member when he or she exits the chat room.

        • (Default)true: Yes;
        • false: No.

    Returns Promise<void>

  • setChatRoomAttributes(this: any, params: { attributes: {}; autoDelete?: boolean; chatRoomId: string; isForced?: boolean }): Promise<AsyncResult<ChatroomAttributes>>
  • Sets the chat room attributes in batches.

    connection.setChatRoomAttributes({chatRoomId: 'chatRoomId', attributes: {"attributeKey1": "attributeValue1"}, autoDelete: true, isForced: false})
    

    Parameters

    • this: any
    • params: { attributes: {}; autoDelete?: boolean; chatRoomId: string; isForced?: boolean }
      • attributes: {}

        The map of custom chat room attributes.

        • [key: string]: string
      • Optional autoDelete?: boolean

        Whether to delete chat room attributes set by the member when he or she exits the chat room. - (Default)true: Yes. - false: No.

      • chatRoomId: string

        The chat room ID.

      • Optional isForced?: boolean

        Whether to allow a member to overwrite the chat room attribute set by another member. - true: Yes. -(Default)false: No.

    Returns Promise<AsyncResult<ChatroomAttributes>>

  • Unmutes the chat room member.

    note

    Only the chat room owner can call this method. The members who are unmuted and other admins will receive "operation: 'unmuteMember'" in the callback of onChatroomEvent.

    connection.unmuteChatRoomMember({chatRoomId: 'chatRoomId', username: 'user1'})
    

    Parameters

    Returns Promise<AsyncResult<UnmuteChatRoomMemberResult[]>>

  • uploadChatRoomSharedFile(this: any, params: { file: object; roomId: string; onFileUploadCanceled?: any; onFileUploadComplete?: any; onFileUploadError?: any; onFileUploadProgress?: any }): void
  • Uploads a shared file to the chat room.

    connection.uploadChatRoomSharedFile({roomId: 'roomId', file: 'file object', onFileUploadProgress: onFileUploadProgress, onFileUploadComplete: onFileUploadComplete,onFileUploadError:onFileUploadError,onFileUploadCanceled:onFileUploadCanceled})
    

    Parameters

    • this: any
    • params: { file: object; roomId: string; onFileUploadCanceled?: any; onFileUploadComplete?: any; onFileUploadError?: any; onFileUploadProgress?: any }
      • file: object

        The shared file object to upload.

      • roomId: string

        The chat room ID.

      • onFileUploadCanceled?:function
        • onFileUploadCanceled(data: any): void
        • The upload cancellation callback.

          Parameters

          • data: any

          Returns void

      • onFileUploadComplete?:function
        • onFileUploadComplete(data: any): void
        • The upload completion callback.

          Parameters

          • data: any

          Returns void

      • onFileUploadError?:function
        • onFileUploadError(data: any): void
        • The upload failure callback.

          Parameters

          • data: any

          Returns void

      • onFileUploadProgress?:function
        • onFileUploadProgress(data: any): void
        • The upload progress callback.

          Parameters

          • data: any

          Returns void

    Returns void

Generated using TypeDoc