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>>
  • 创建聊天室。

    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

        聊天室描述。

      • maxusers: number

        聊天室最大成员数(包括聊天室创建者),值为数值类型,默认值 200,最大值 5,000。

      • Optional members?: string[]

        (可选)聊天室成员,由用户 ID 组成的数组。如果设置了该参数,请确保数组内至少包含一个用户。

      • name: string

        聊天室名称。

      • token: string

        超级管理员 token。

      • error?:function
      • success?:function

    Returns Promise<AsyncResult<CreateChatRoomResult>>

  • getChatRoomAllowlist(this: any, params: { chatRoomId: string; error: any; success: any }): Promise<AsyncResult<UserId[]>>
  • 获取聊天室白名单列表。

    仅聊天室所有者和管理员有权调用该方法。

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

    Parameters

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

    Returns Promise<AsyncResult<UserId[]>>

  • 获取聊天室全部的自定义属性。

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

    Parameters

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

        要获取的自定义属性。传对应的属性 key 会返回属性 value;不传值:返回全部属性。

      • chatRoomId: string

        聊天室 ID。

    Returns Promise<AsyncResult<GetChatroomAttributesResult>>

  • getChatRoomBlocklist(this: any, params: { chatRoomId: string; error?: any; success?: any }): Promise<AsyncResult<UserId[]>>
  • 获取聊天室黑名单。

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

    Parameters

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

    Returns Promise<AsyncResult<UserId[]>>

  • 查询聊天室成员是否是在白名单中。

    普通成员可查询自己是否在聊天室白名单中;聊天室所有者和管理员可查询其他成员是否在白名单中。

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

    Parameters

    Returns Promise<AsyncResult<IsChatRoomWhiteUserResult>>

  • leaveChatRoom(this: any, params: { roomId: string; error?: any; success?: any }): Promise<AsyncResult<{ result: boolean }>>
  • 退出聊天室。

    note

    若某成员退出聊天室,其他成员会在 onChatroomEvent 回调里收到 "operation: 'memberAbsence'"。

    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 }[]>>
  • 分页列出聊天室的所有成员。

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

    Parameters

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

        聊天室 ID。

      • pageNum: number

        当前页码,从 1 开始。

      • pageSize: number

        每页期望返回的成员数,最大值为 1,000。

      • 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>>
  • 修改聊天室详情。

    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>>
  • 禁止聊天室用户发言。

    note

    该方法只有聊天室所有者和管理员才有权限调用。被禁言成员和其他未操作的群主和管理员会在 onChatroomEvent 的回调里收到 "operation:'muteMember'"。

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

    Parameters

    Returns Promise<AsyncResult<MuteChatRoomMemberResult>>

  • 移除聊天室管理员。

    note

    该方法只有聊天室所有者才有权限调用。被移除管理员权限的用户会在 onChatroomEvent 的回调里收到 operation: 'removeAdmin'。

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

    Parameters

    Returns Promise<AsyncResult<RemoveChatRoomAdminResult>>

  • 移除聊天室白名单成员。仅聊天室所有者和管理员有权限调用该方法。被移出白名单的成员会在 onChatroomEvent 的回调里收到 "operation:'removeAllowlistMember'" 回调。

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

    Parameters

    Returns Promise<AsyncResult<ChatRoomType.CommonRequestResult>>

  • removeChatRoomAttribute(this: any, params: { attributeKey: string; chatRoomId: string; isForced?: boolean }): Promise<void>
  • 移除单个聊天室自定义属性。

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

    Parameters

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

        删除的属性 key。

      • chatRoomId: string

        聊天室 ID。

      • Optional isForced?: boolean

        是否允许一个成员更新其他成员设置的聊天室属性。

        • true:是;
        • (默认)false:否。

    Returns Promise<void>

  • removeChatRoomAttributes(this: any, params: { attributeKeys: string[]; chatRoomId: string; isForced?: boolean }): Promise<AsyncResult<ChatroomAttributes>>
  • 批量移除聊天室自定义属性。

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

    Parameters

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

        要删除的属性 key 列表。一次删除数量不能超过 10 个。

      • chatRoomId: string

        聊天室 ID。

      • Optional isForced?: boolean

        是否允许成员更新其他成员设置的聊天室自定义属性。

        • true:是;
        • (默认)false:否。

    Returns Promise<AsyncResult<ChatroomAttributes>>

  • 设置聊天室管理员。

    note

    该方法只有聊天室所有者才有权限调用。被设置成管理员的成员会在 onChatroomEvent 的回调里收到 "operation: 'setAdmin'"。

    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>
  • 设置单个聊天室自定义属性。

    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

        聊天室自定义属性 key,指定属性名。属性名不能超过 128 字符。每个聊天室最多可有 100 个属性。Key 支持以下字符集: • 26 个小写英文字母 a-z; • 26 个大写英文字母 A-Z; • 10 个数字 0-9; • “_”, “-”, “.”。

      • attributeValue: string

        聊天室自定义属性值。每个属性值不超过 4096 字符,每个应用的聊天室属性总大小不能超过 10 GB。

      • Optional autoDelete?: boolean

        成员退出时是否删除该聊天室中其设置的所有聊天室自定义属性。

        • (默认)true:是;
        • false:否。
      • chatRoomId: string

        聊天室 ID。

      • Optional isForced?: boolean

        是否允许成员更新其他成员设置的聊天室自定义属性。

        • true:是;
        • (默认)false:否。

    Returns Promise<void>

  • setChatRoomAttributes(this: any, params: { attributes: {}; autoDelete?: boolean; chatRoomId: string; isForced?: boolean }): Promise<AsyncResult<ChatroomAttributes>>
  • 批量设置聊天室属性。

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

    Parameters

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

        自定义属性集合。

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

        成员退出时是否删除该聊天室中其设定的所有聊天室自定义属性。- (默认)true: 是。- false:否。

      • chatRoomId: string

        聊天室 ID。

      • Optional isForced?: boolean

        是否允许成员更新其他成员设置的聊天室自定义属性。- true: 是。- (默认)false:否。

    Returns Promise<AsyncResult<ChatroomAttributes>>

  • 解除对聊天室用户的禁言。

    该方法只有聊天室所有者和管理员才有权限调用。该成员和其他未做操作的群管理员或者群主会在 onChatroomEvent 的回调里收到 "operation: 'unmuteMember'"。

    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
  • 上传一个聊天室共享文件。

    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

        上传的文件对象。

      • roomId: string

        聊天室 ID。

      • onFileUploadCanceled?:function
        • onFileUploadCanceled(data: any): void
        • 上传取消的回调。

          Parameters

          • data: any

          Returns void

      • onFileUploadComplete?:function
        • onFileUploadComplete(data: any): void
        • 上传完成的回调。

          Parameters

          • data: any

          Returns void

      • onFileUploadError?:function
        • onFileUploadError(data: any): void
        • 上传失败的回调。

          Parameters

          • data: any

          Returns void

      • onFileUploadProgress?:function
        • onFileUploadProgress(data: any): void
        • 上传进度的回调。

          Parameters

          • data: any

          Returns void

    Returns void

Generated using TypeDoc