聊天室信息
获取聊天室资料与在线成员列表;成员数不设上限。
平台调用风格
双语言同契约:Swift 用 async -> RcResult<T>(错误码在 RcResult.code,返回 null 的 op 用 RcResult<Void>);Objective-C 用 - (void)opWithParam:... completion:(void (^)(RcResult *))completion,回调在主线程投递。
接口一览
| 操作 | 语义 | 传输 | 返回 |
|---|---|---|---|
getChatroomInfo | 聊天室信息(含在线数)。 | REST(客户端) | Chatroom |
getChatroomMembers | 聊天室在线成员列表。 | REST(客户端) | {members:ChatroomMember[], total:uint32} |
本页 2 个操作,其中 2 个在本平台绑定中声明了方法签名。
跨端方法名
| 操作 | Android | Web | Electron | macOS | Flutter | Native (C ABI) | iOS |
|---|---|---|---|---|---|---|---|
getChatroomInfo | getChatroomInfo | getChatroomInfo | getChatroomInfo | getChatroomInfo | getChatroomInfo | im_client_chatroom_info | func |
getChatroomMembers | getChatroomMembers | getChatroomMembers | getChatroomMembers | getChatroomMembers | getChatroomMembers | — | func |
方法名在 GA 平台之间保持一致(规则 A);Native C ABI 只覆盖部分操作,其余操作以 — 标注。
getChatroomInfo
聊天室信息(含在线数)。
func getChatroomInfo(chatroomId: String) async -> RcResult<IMPChatroom>参数
| 参数 | 类型 | 说明 |
|---|---|---|
chatroomId | string | 必填;聊天室 ID |
返回
Chatroom 聊天室资料
示例(Swift / Objective-C)
let res = await client.getChatroomInfo(chatroomId: "cr_2001")
if res.code != 0 { print("IM 调用失败:\(res.msg ?? "")") }[client getChatroomInfoWithChatroomId:@"cr_2001" completion:^(IMPOSResult *result) {
if (result.code != 0) { NSLog(@"IM 调用失败:%ld %@", (long)result.code, result.msg); }
}];错误码
| 错误码 | 名称 | 分类 | HTTP | 可重试 | 说明 |
|---|---|---|---|---|---|
1001 | INVALID_PARAMETER | 客户端 / 参数 / 权限 | 400 | 否 | 参数错误 |
1012 | CHATROOM_NOT_FOUND | 客户端 / 参数 / 权限 | 404 | 否 | 聊天室不存在 |
getChatroomMembers
聊天室在线成员列表。
func getChatroomMembers(chatroomId: String, options: IMPPageOptions?) async -> RcResult<IMPChatroomMembersPage>参数
| 参数 | 类型 | 说明 |
|---|---|---|
chatroomId | string | 必填;聊天室 ID |
options | {offset?:uint32,limit?:uint32} | 可选;选项对象(字段见类型列):{ offset?:uint32, limit?:uint32 } |
返回
{members:ChatroomMember[], total:uint32} 在线成员页与总数
示例(Swift / Objective-C)
let res = await client.getChatroomMembers(chatroomId: "cr_2001", options: nil)
if res.code != 0 { print("IM 调用失败:\(res.msg ?? "")") }[client getChatroomMembersWithChatroomId:@"cr_2001" options:nil completion:^(IMPOSResult *result) {
if (result.code != 0) { NSLog(@"IM 调用失败:%ld %@", (long)result.code, result.msg); }
}];错误码
| 错误码 | 名称 | 分类 | HTTP | 可重试 | 说明 |
|---|---|---|---|---|---|
1001 | INVALID_PARAMETER | 客户端 / 参数 / 权限 | 400 | 否 | 参数错误 |
1012 | CHATROOM_NOT_FOUND | 客户端 / 参数 / 权限 | 404 | 否 | 聊天室不存在 |
相关文档
- 功能列表:103 个操作与签名
- 状态码:错误码与重试策略
- API 参考:类与成员
- IMLib 集成指南