聊天室信息

获取聊天室资料与在线成员列表;成员数不设上限。

契约预留

本平台为 reserved:以下签名来自已冻结绑定,示例为契约样例,不承诺可运行。

平台调用风格

异步风格:Promise<RcResult<T>>(不 reject;错误码在 RcResult.code);uint64/int64 映射为 number,超出安全整数时由实现改用 string。

接口一览​

操作语义传输返回
getChatroomInfo聊天室信息(含在线数)。REST(客户端)Chatroom
getChatroomMembers聊天室在线成员列表。REST(客户端){members:ChatroomMember[], total:uint32}

本页 2 个操作,其中 2 个在本平台绑定中声明了方法签名。

跨端方法名​

操作AndroidWebElectronmacOSFlutterNative (C ABI)iOS
getChatroomInfogetChatroomInfogetChatroomInfogetChatroomInfogetChatroomInfogetChatroomInfoim_client_chatroom_infofunc
getChatroomMembersgetChatroomMembersgetChatroomMembersgetChatroomMembersgetChatroomMembersgetChatroomMembers—func

方法名在 GA 平台之间保持一致(规则 A);Native C ABI 只覆盖部分操作,其余操作以 — 标注。

getChatroomInfo​

聊天室信息(含在线数)。

getChatroomInfo(chatroomId: string): Promise<RcResult<Chatroom>>
REST(客户端)since 1.0.0
参数
参数类型说明
chatroomIdstring必填;聊天室 ID
返回

Chatroom 聊天室资料

示例
TypeScript
// HarmonyOS 绑定为契约预留,以下为声明样例
const res = await client.getChatroomInfo('cr_2001');
if (res.code !== 0) { console.error(res.msg); }
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误
1012CHATROOM_NOT_FOUND客户端 / 参数 / 权限404否聊天室不存在

getChatroomMembers​

聊天室在线成员列表。

getChatroomMembers(chatroomId: string, options?: PageOptions): Promise<RcResult<ChatroomMembersPage>>
REST(客户端)since 1.0.0
参数
参数类型说明
chatroomIdstring必填;聊天室 ID
options{offset?:uint32,limit?:uint32}可选;选项对象(字段见类型列):{ offset?:uint32, limit?:uint32 }
返回

{members:ChatroomMember[], total:uint32} 在线成员页与总数

示例
TypeScript
// HarmonyOS 绑定为契约预留,以下为声明样例
const res = await client.getChatroomMembers('cr_2001', {  });
if (res.code !== 0) { console.error(res.msg); }
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误
1012CHATROOM_NOT_FOUND客户端 / 参数 / 权限404否聊天室不存在

相关文档​