聊天室信息

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

平台调用风格

双语言同契约: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 个在本平台绑定中声明了方法签名。

跨端方法名​

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

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

getChatroomInfo​

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

func getChatroomInfo(chatroomId: String) async -> RcResult<IMPChatroom>
REST(客户端)since 1.0.0
参数
参数类型说明
chatroomIdstring必填;聊天室 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可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误
1012CHATROOM_NOT_FOUND客户端 / 参数 / 权限404否聊天室不存在

getChatroomMembers​

聊天室在线成员列表。

func getChatroomMembers(chatroomId: String, options: IMPPageOptions?) async -> RcResult<IMPChatroomMembersPage>
REST(客户端)since 1.0.0
参数
参数类型说明
chatroomIdstring必填;聊天室 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可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误
1012CHATROOM_NOT_FOUND客户端 / 参数 / 权限404否聊天室不存在

相关文档​