在线状态
查询单用户/批量用户的在线状态;支持多端在线聚合。
平台调用风格
异步风格:Future<RcResult<T>>;错误码在 res.code,不使用异常表达业务失败。
接口一览
| 操作 | 语义 | 传输 | 返回 |
|---|---|---|---|
getOnlineStatus | 查询单个用户在线状态。 | REST(客户端) | {userId:string, online:bool, sessionCount:uint32} |
getOnlineStatusBatch | 批量在线状态(<=100)。 | REST(客户端) | {items:[{userId:string,online:bool,sessionCount:uint32}]} |
本页 2 个操作,其中 2 个在本平台绑定中声明了方法签名。
跨端方法名
| 操作 | Android | Web | Electron | macOS | Flutter | Native (C ABI) | iOS |
|---|---|---|---|---|---|---|---|
getOnlineStatus | getOnlineStatus | getOnlineStatus | getOnlineStatus | getOnlineStatus | getOnlineStatus | — | func |
getOnlineStatusBatch | getOnlineStatusBatch | getOnlineStatusBatch | getOnlineStatusBatch | getOnlineStatusBatch | getOnlineStatusBatch | — | func |
方法名在 GA 平台之间保持一致(规则 A);Native C ABI 只覆盖部分操作,其余操作以 — 标注。
getOnlineStatus
查询单个用户在线状态。
getOnlineStatus(String userId)参数
| 参数 | 类型 | 说明 |
|---|---|---|
userId | string | 必填;用户 ID |
返回
{userId:string, online:bool, sessionCount:uint32} 单用户在线状态
示例
Dart
final res = await engine.getOnlineStatus('user2');
if (res.code != 0) throw Exception(res.msg);错误码
| 错误码 | 名称 | 分类 | HTTP | 可重试 | 说明 |
|---|---|---|---|---|---|
1001 | INVALID_PARAMETER | 客户端 / 参数 / 权限 | 400 | 否 | 参数错误 |
1004 | USER_NOT_FOUND | 客户端 / 参数 / 权限 | 404 | 否 | 用户不存在 |
getOnlineStatusBatch
批量在线状态(<=100)。
getOnlineStatusBatch(List<String> userIds)参数
| 参数 | 类型 | 说明 |
|---|---|---|
userIds | string[] | 必填;用户 ID 列表(批量接口通常有上限) |
返回
{items:[{userId:string,online:bool,sessionCount:uint32}]} 批量在线状态
示例
Dart
final res = await engine.getOnlineStatusBatch(['user2']);
if (res.code != 0) throw Exception(res.msg);错误码
| 错误码 | 名称 | 分类 | HTTP | 可重试 | 说明 |
|---|---|---|---|---|---|
1001 | INVALID_PARAMETER | 客户端 / 参数 / 权限 | 400 | 否 | 参数错误 |
相关文档
- 功能列表:103 个操作与签名
- 状态码:错误码与重试策略
- API 参考:类与成员
- IMLib 集成指南