在线状态
查询单用户/批量用户的在线状态;支持多端在线聚合。
平台调用风格
进程模型:main(客户端 + 本地库,单写者)/ preload(contextBridge 具名方法)/ renderer(薄代理)。renderer 不直连网络与数据库。
接口一览
| 操作 | 语义 | 传输 | 返回 |
|---|---|---|---|
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(userId: string): Promise<RcResult<{userId: string; online: boolean; sessionCount: number}>>参数
| 参数 | 类型 | 说明 |
|---|---|---|
userId | string | 必填;用户 ID |
返回
{userId:string, online:bool, sessionCount:uint32} 单用户在线状态
示例
JavaScript
const res = await client.getOnlineStatus('user2');
if (res.code !== 0) throw new Error(res.msg);
const data = res.data;错误码
| 错误码 | 名称 | 分类 | HTTP | 可重试 | 说明 |
|---|---|---|---|---|---|
1001 | INVALID_PARAMETER | 客户端 / 参数 / 权限 | 400 | 否 | 参数错误 |
1004 | USER_NOT_FOUND | 客户端 / 参数 / 权限 | 404 | 否 | 用户不存在 |
getOnlineStatusBatch
批量在线状态(<=100)。
getOnlineStatusBatch(userIds: string[]): Promise<RcResult<{items: Array<{userId: string; online: boolean; sessionCount: number}>}>>参数
| 参数 | 类型 | 说明 |
|---|---|---|
userIds | string[] | 必填;用户 ID 列表(批量接口通常有上限) |
返回
{items:[{userId:string,online:bool,sessionCount:uint32}]} 批量在线状态
示例
JavaScript
const res = await client.getOnlineStatusBatch(['user2']);
if (res.code !== 0) throw new Error(res.msg);
const data = res.data;错误码
| 错误码 | 名称 | 分类 | HTTP | 可重试 | 说明 |
|---|---|---|---|---|---|
1001 | INVALID_PARAMETER | 客户端 / 参数 / 权限 | 400 | 否 | 参数错误 |
相关文档
- 功能列表:103 个操作与签名
- 状态码:错误码与重试策略
- API 参考:类与成员
- IMLib 集成指南