@cg-devcenter/rtc-fpnn-webjs-sdk 1.0.0-cg.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ export interface RTMSDKVitePlugin {
2
+ name: string;
3
+ enforce: 'pre';
4
+ config(config: Record<string, any>): { optimizeDeps: Record<string, any> };
5
+ }
6
+
7
+ export function rtmSdkVitePlugin(): RTMSDKVitePlugin;
8
+ export default rtmSdkVitePlugin;
@@ -0,0 +1,23 @@
1
+ const packageName = '@cg-devcenter/rtc-fpnn-webjs-sdk';
2
+ const viteCompatibilityEntry = packageName + '/vite';
3
+
4
+ /** Keep both SDK ESM entries in Vite's transform pipeline so Worker URLs stay valid. */
5
+ export function rtmSdkVitePlugin() {
6
+ return {
7
+ name: 'rtc-fpnn-webjs-sdk',
8
+ enforce: 'pre',
9
+ config(config) {
10
+ const optimizeDeps = config.optimizeDeps || {};
11
+ const exclude = new Set(optimizeDeps.exclude || []);
12
+ exclude.add(packageName);
13
+ exclude.add(viteCompatibilityEntry);
14
+ return {
15
+ optimizeDeps: Object.assign({}, optimizeDeps, {
16
+ exclude: Array.from(exclude),
17
+ }),
18
+ };
19
+ },
20
+ };
21
+ }
22
+
23
+ export default rtmSdkVitePlugin;
@@ -0,0 +1,59 @@
1
+ import rtm = require('./rtm');
2
+
3
+ declare const sdk: typeof rtm;
4
+
5
+ export default sdk;
6
+ export type RTMProtocol = rtm.RTMProtocol;
7
+ export type RTMCompatibility = rtm.RTMCompatibility;
8
+ export type RTMCompatibilityError = rtm.RTMCompatibilityError;
9
+ export type RTMId = rtm.RTMId;
10
+ export type RTMLegacyMessagePayload = rtm.RTMLegacyMessagePayload;
11
+ export type RTMLegacyTlvMessagePayload = rtm.RTMLegacyTlvMessagePayload;
12
+ export type RTMLegacySendResult = rtm.RTMLegacySendResult;
13
+ export type RTMLegacySendError = rtm.RTMLegacySendError;
14
+ export type RTMLegacyHistoryMessage = rtm.RTMLegacyHistoryMessage;
15
+ export type RTMLegacyHistoryResponse = rtm.RTMLegacyHistoryResponse;
16
+ export type RTMLegacyPushMessage = rtm.RTMLegacyPushMessage;
17
+ export type RTMLoginPromiseResult = rtm.RTMLoginPromiseResult;
18
+ export type RTMPromiseApi = rtm.RTMPromiseApi;
19
+ export type RTMSharedWorkerPromiseApi = rtm.RTMSharedWorkerPromiseApi;
20
+ export type RTMDefaultPromiseApi = rtm.RTMDefaultPromiseApi;
21
+ export type RTMRegressiveStrategy = rtm.RTMRegressiveStrategy;
22
+ export type RTMClientBaseOptions = rtm.RTMClientBaseOptions;
23
+ export type RTMClientOptions = rtm.RTMClientOptions;
24
+ export type RTMSharedWorkerBaseClientOptions = rtm.RTMSharedWorkerBaseClientOptions;
25
+ export type RTMSharedWorkerClientOptions = rtm.RTMSharedWorkerClientOptions;
26
+ export type RTMConversationType = rtm.RTMConversationType;
27
+ export type RTMConversation = rtm.RTMConversation;
28
+ export type RTMSharedWorkerOptions = rtm.RTMSharedWorkerOptions;
29
+ export type RTMSharedCreateClientOptions = rtm.RTMSharedCreateClientOptions;
30
+ export type RTMIndependentCreateClientOptions = rtm.RTMIndependentCreateClientOptions;
31
+ export type RTMCreateClientOptions = rtm.RTMCreateClientOptions;
32
+ export type RTMFactoryCompatibilityOptions = rtm.RTMFactoryCompatibilityOptions;
33
+ export type RTMConnectionInfo = rtm.RTMConnectionInfo;
34
+ export type RTMConnectionInfoProvider = rtm.RTMConnectionInfoProvider;
35
+ export type RTMDefaultClient = rtm.RTMDefaultClient;
36
+ export type RTMLegacyPromiseApi = rtm.RTMLegacyPromiseApi;
37
+ export type RTMLegacyFpnnPromiseApi = rtm.RTMLegacyFpnnPromiseApi;
38
+ export type RTMLegacyProcessor = rtm.RTMLegacyProcessor;
39
+ export type RTMLegacyTlvProcessor = rtm.RTMLegacyTlvProcessor;
40
+ export type RTMLegacyFpnnProcessor = rtm.RTMLegacyFpnnProcessor;
41
+ export type RTMLegacyDefaultClient = rtm.RTMLegacyDefaultClient;
42
+ export type RTMLegacyFpnnDefaultClient = rtm.RTMLegacyFpnnDefaultClient;
43
+ export type RTMSharedSessionSnapshot = rtm.RTMSharedSessionSnapshot;
44
+ export type RTMSharedLoginResult = rtm.RTMSharedLoginResult;
45
+ export type RTMSharedWorkerIdentity = rtm.RTMSharedWorkerIdentity;
46
+ export type RTMClient = rtm.RTMClient;
47
+ export type RTMSharedWorkerClient = rtm.RTMSharedWorkerClient;
48
+ export type RTMConfig = rtm.RTMConfig;
49
+ export type RTMProcessor = rtm.RTMProcessor;
50
+ export type TLVCodec = rtm.TLVCodec;
51
+ export type TLVWebSocketClient = rtm.TLVWebSocketClient;
52
+ export const RTMClient: typeof rtm.RTMClient;
53
+ export const createClient: typeof rtm.createClient;
54
+ export const RTMSharedWorkerClient: typeof rtm.RTMSharedWorkerClient;
55
+ export const RTMConfig: typeof rtm.RTMConfig;
56
+ export const RTMProcessor: typeof rtm.RTMProcessor;
57
+ export const TLVCodec: typeof rtm.TLVCodec;
58
+ export const TLVWebSocketClient: typeof rtm.TLVWebSocketClient;
59
+ export const createSharedWorkerName: typeof rtm.createSharedWorkerName;
@@ -0,0 +1,33 @@
1
+ // Source for the legacy `/vite` export. build-modern.mjs rewrites the Worker
2
+ // asset path when placing this file beside the generated dist assets.
3
+ import rtmModule from '@cg-devcenter/rtc-fpnn-webjs-sdk/dist/rtm.min.js';
4
+ import workerUrl from './rtm.shared-worker.js?url';
5
+
6
+ const rtm = rtmModule.default || rtmModule;
7
+
8
+ class RTMSharedWorkerClient extends rtm.RTMSharedWorkerClient {
9
+ constructor(options) {
10
+ const config = options || {};
11
+ super(Object.assign({}, config, {
12
+ workerUrl: config.workerUrl || workerUrl,
13
+ }));
14
+ }
15
+ }
16
+
17
+ function createClient(options) {
18
+ const config = options || {};
19
+ return rtm.createClient(Object.assign({}, config, {
20
+ workerUrl: config.workerUrl || workerUrl,
21
+ }));
22
+ }
23
+
24
+ const sdk = Object.assign({}, rtm, { RTMSharedWorkerClient, createClient });
25
+
26
+ export const RTMClient = sdk.RTMClient;
27
+ export { createClient, RTMSharedWorkerClient };
28
+ export const RTMConfig = sdk.RTMConfig;
29
+ export const RTMProcessor = sdk.RTMProcessor;
30
+ export const TLVCodec = sdk.TLVCodec;
31
+ export const TLVWebSocketClient = sdk.TLVWebSocketClient;
32
+ export const createSharedWorkerName = sdk.createSharedWorkerName;
33
+ export default sdk;
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const rtm = require('./rtm.min.js');
4
+
5
+ function workerUrl() {
6
+ const publicPath = typeof __webpack_public_path__ === 'string'
7
+ ? __webpack_public_path__
8
+ : '/';
9
+ return publicPath + 'rtm.shared-worker.js';
10
+ }
11
+
12
+ function withWorkerUrl(options) {
13
+ const config = options || {};
14
+ return Object.assign({}, config, {
15
+ workerUrl: config.workerUrl || workerUrl(),
16
+ });
17
+ }
18
+
19
+ class RTMSharedWorkerClient extends rtm.RTMSharedWorkerClient {
20
+ constructor(options) {
21
+ super(withWorkerUrl(options));
22
+ }
23
+ }
24
+
25
+ function createClient(options) {
26
+ return rtm.createClient(withWorkerUrl(options));
27
+ }
28
+
29
+ module.exports = Object.assign({}, rtm, { RTMSharedWorkerClient, createClient });
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const packageName = '@cg-devcenter/rtc-fpnn-webjs-sdk';
7
+ const workerFilename = 'rtm.shared-worker.js';
8
+
9
+ class RTMSDKWebpack4Plugin {
10
+ apply(compiler) {
11
+ const pluginName = 'RTMSDKWebpack4Plugin';
12
+ const distDirectory = __dirname;
13
+ const adapterPath = path.join(distDirectory, 'rtm.webpack4-adapter.cjs');
14
+ const workerPath = path.join(distDirectory, workerFilename);
15
+ const aliases = compiler.options.resolve && compiler.options.resolve.alias;
16
+
17
+ if (!compiler.options.resolve) compiler.options.resolve = {};
18
+ if (Array.isArray(aliases)) {
19
+ compiler.options.resolve.alias = aliases.concat({
20
+ name: packageName,
21
+ alias: adapterPath,
22
+ onlyModule: true,
23
+ });
24
+ } else {
25
+ compiler.options.resolve.alias = Object.assign({}, aliases || {}, {
26
+ [packageName + '$']: adapterPath,
27
+ });
28
+ }
29
+
30
+ compiler.hooks.emit.tapAsync(pluginName, (compilation, callback) => {
31
+ if (!fs.existsSync(workerPath)) {
32
+ callback(new Error(pluginName + ': SDK Worker file is missing: ' + workerPath));
33
+ return;
34
+ }
35
+ if (compilation.assets[workerFilename]) {
36
+ callback(new Error(pluginName + ': output already contains ' + workerFilename));
37
+ return;
38
+ }
39
+
40
+ const worker = fs.readFileSync(workerPath);
41
+ compilation.assets[workerFilename] = {
42
+ source: () => worker,
43
+ size: () => worker.length,
44
+ };
45
+ callback();
46
+ });
47
+ }
48
+ }
49
+
50
+ module.exports = RTMSDKWebpack4Plugin;
@@ -0,0 +1,5 @@
1
+ declare class RTMSDKWebpack4Plugin {
2
+ apply(compiler: any): void;
3
+ }
4
+
5
+ export = RTMSDKWebpack4Plugin;
@@ -0,0 +1,129 @@
1
+ # RTM WebSocket SDK 能力总览
2
+
3
+ 本页按接入方的业务目标整理 SDK 能做什么、每项能力对应哪些 API,以及 TLV v1 与 FPNN 的使用入口。具体参数、回调字段和 wire body 以 [SDK API](USAGE.md) 与 [TLV v1 Client API 契约](TLV_CONTRACT.md) 为准;逐 API 的 TLV 支持状态以 [TLV v1 API 支持矩阵](USAGE.md#6-tlv-v1-api-支持矩阵) 为准。
4
+
5
+ 如果要从旧 FPNN 接入切换协议,参见 [FPNN 与 TLV v1 迁移对照](PROTOCOL_MIGRATION.md),其中按业务 API 列出 FPNN method 和 TLV URI 的对应关系。
6
+
7
+ 下面的能力地图覆盖 SDK 整体 API;选择具体协议后,结合“协议与能力入口”表确定对应的调用入口和业务范围。
8
+
9
+ ## 能力地图
10
+
11
+ 推荐通过 `createClient()` 接入:使用扁平配置,UID 从登录参数取得;浏览器支持 SharedWorker 且配置可安全传递时,SDK 按 PID、协议、UID 和 Gate endpoint 自动隔离并复用连接。`compatibility: 'legacy-rtm'` 可在显式选择 TLV 时保留旧 RTM 页面 API 契约;具体支持范围与 17 个不支持方法见 [旧 RTM 迁移指南](LEGACY_RTM_TLV_COMPATIBILITY.md)。协议仍默认 FPNN,原生契约仍默认 `native`;兼容字段不改变 Worker 身份或服务端能力。其他共享配置、错误和生命周期见 [默认共享接入](USAGE.md#默认共享接入)。
12
+
13
+ | 业务目标 | SDK 能力 | 常用 API |
14
+ | --- | --- | --- |
15
+ | 建立实时连接 | 登录、协议级关闭、主动关闭、自动重连、服务端时间、连接属性、调试日志 | `login`、`bye`、`close`、`startAutoReconnect`、`getServerTime`、`addAttrs`、`getAttrs`、`addDebugLog` |
16
+ | 同浏览器多窗口 | 同一 UID 共享一条 RTM WebSocket、共享登录态、按会话路由 Push | `createClient`、`RTMSharedWorkerClient`、`whenReady`、`loginIfNeeded`、`SharedSessionState`、`setConversation` |
17
+ | 维护用户状态 | 查询在线用户、设置/读取个人资料、读取公开资料、设置翻译语言 | `getOnlineUsers`、`setUserInfo`、`getUserInfo`、`getUserOpenInfo`、`setTranslationLanguage` |
18
+ | 保存用户数据 | 按 key 写入、读取和删除用户存储 | `dataSet`、`dataGet`、`dataDelete` |
19
+ | 用户关系控制 | 添加/解除黑名单并读取黑名单列表 | `addBlacks`、`deleteBlacks`、`getBlacks` |
20
+ | 一对一消息 | 发送文本、语音、命令消息;批量发送;接收可靠 Push | `sendChat`、`sendAudio`、`sendCmd`、`sendMessages`、`event.direct` |
21
+ | 群组消息 | 发送文本、语音、命令消息;接收群组 Push | `sendGroupChat`、`sendGroupAudio`、`sendGroupCmd`、`event.group` |
22
+ | 房间消息 | 进入/退出房间,发送文本、语音、命令消息,接收房间 Push | `enterRoom`、`leaveRoom`、`sendRoomChat`、`sendRoomAudio`、`sendRoomCmd`、`event.room` |
23
+ | 广播消息 | 接收广播 Push,查询广播历史和数量 | `event.broadcast`、`getBroadcastMessage`、`getBroadcastChat`、`getBroadcastMessageCount` |
24
+ | 群组管理 | 添加/移除成员,查询成员和人数,读取用户所在群组,设置和读取群组资料 | `addGroupMembers`、`deleteGroupMembers`、`getGroupMembers`、`getGroupCount`、`getUserGroups`、`setGroupInfo`、`getGroupInfo` |
25
+ | 房间管理 | 批量进入房间,查询房间成员/人数/资料,读取用户所在房间 | `enterRooms`、`getRoomMembers`、`getRoomCount`、`getUserRooms`、`setRoomInfo`、`getRoomInfo` |
26
+ | 历史消息 | 按时间和游标分页,按消息 ID 定位,统计消息数量 | `getP2PMessage`、`getGroupMessage`、`getRoomMessage`、`getBroadcastMessage`、`get*MessageByMessageId`、`get*MessageCount` |
27
+ | 单条消息管理 | 获取单条消息和撤回消息 | `getMessage`、`deleteMessage`、`getChat`、`deleteChat` |
28
+ | 收件箱同步 | 查询未读、清除未读、读取会话、标记会话已读、删除本地会话、读取会话列表 | `getUnreadMessage`、`cleanUnreadMessage`、`getSession`、`setSessionRead`、`removeSession`、`get*ConversationList` |
29
+ | 文本服务 | 文本审核、文本翻译、按用户设置翻译语言 | `textCheck`、`translate`、`setTranslationLanguage` |
30
+ | 文件消息 | 获取上传凭证和 endpoint,发送一对一/群组/房间文件 | `fileToken`、`sendFile`、`sendGroupFile`、`sendRoomFile` |
31
+ | 设备与好友 | 维护设备 Push 信息,维护好友关系 | `addDevice`、`removeDevice`、`getDevicePushOption`、`addFriends`、`deleteFriends`、`getFriends` |
32
+ | 多媒体内容服务 | 敏感词处理、图片/音频/视频审核、语音转文字 | `profanity`、`imageCheck`、`audioCheck`、`videoCheck`、`speech2Text` |
33
+
34
+ ## 协议与能力入口
35
+
36
+ | 入口 | 适合场景 | 主要能力 |
37
+ | --- | --- | --- |
38
+ | `protocol: 'tlv-v1'` | 新项目、浏览器和 Node.js 接入 | 连接鉴权、用户与存储、黑名单、用户/群组/房间/广播消息、可靠 Push、历史、未读、会话、文本审核、翻译。 |
39
+ | `protocol: 'fpnn'` | 现有浏览器 RTM 应用的兼容接入 | 兼容 SDK 的完整传统 API 族,包括文件、设备、好友和多媒体内容服务。 |
40
+
41
+ ### 协议与运行边界
42
+
43
+ | 能力 | `RTMClient` + TLV v1 | `RTMClient` + FPNN | `RTMSharedWorkerClient` |
44
+ | --- | --- | --- | --- |
45
+ | 连接环境 | 浏览器;Node.js 需传入 `webSocketFactory` | 浏览器 | 支持 SharedWorker 的浏览器,同源页面 |
46
+ | 用户/群组/房间/广播消息 | 支持;按 TLV v1 契约字段校验 | 支持兼容 API | 沿用底层 SDK 的所选协议能力,包含 FPNN 文件发送 |
47
+ | Push ACK 与去重 | SDK 自动 ACK 可靠 Push,并按 `message_ref` 去重 | 沿用兼容实现 | 底层 SDK 只 ACK 一次;Worker 原样广播,页面可显式筛选 |
48
+ | 文件、设备、好友、多媒体审核 | TLV v1 当前未开放的传统 API 不可用 | 兼容 API 可用,依赖对应服务端能力 | FPNN 文件/设备/好友/审核由底层 SDK 处理,TLV 按其支持范围 |
49
+ | 多页面连接共享 | 每个 `RTMClient` 实例各自管理连接 | 每个 `RTMClient` 实例各自管理连接 | 相同协议、Worker identity 与配置下,同一 UID 共用一条连接 |
50
+ | 业务 UI 与消息存储 | 应用负责展示、缓存和历史补拉 | 应用负责展示、缓存和历史补拉 | 只路由实时 Push;不跨页同步草稿、未读 UI 状态或本地消息列表,也不持久化消息 |
51
+
52
+ TLV v1 的能力以 [Client API 契约](TLV_CONTRACT.md) 的 URI 表为准;旧 API 名称存在不代表 TLV 服务端开放了该 wire。保留但未开放的 wire 返回 `200020`(`RTM_EC_FORBIDDEN_METHOD`);未知且未登记的 wire 返回 `20004`(`RTM_EC_UNKNOWN_METHOD`)。显式使用 `compatibility: 'legacy-rtm'` 时,17 个没有 TLV 等价的旧 FPNN API 会在页面本地以 `RTM_COMPATIBILITY_UNSUPPORTED` 拒绝,不会发到 Gate;native TLV 则按实际 TLV API contract 返回服务端拒绝。共享层自动代理 SDK 公开业务方法;FPNN 文件发送可用,TLV 文件发送由底层 SDK 拒绝,native callback 收到 `{mid, error}`、`error.code` 为 `200020`,Promise 版本 reject 同一对象。以上情况均不会退回 FPNN。SharedWorker 不是另一套 RTC 协议,也不替业务服务端签发 credential。
53
+
54
+ ### SharedWorker 共享范围
55
+
56
+ - 常规接入无需传 `workerUrl`:普通 HTML 将 SDK 脚本与 `rtm.shared-worker.js` 放在同源同目录;现代 ESM 项目从包根导入,Vite 配置 `/vite-plugin`,Webpack 4 配置 `/webpack4` 插件,Webpack 5 使用标准 ESM 资源解析。Worker 必须在页面同源下可访问;只有自定义 Worker 部署位置时才显式提供同源 `workerUrl`。直接从 unpkg / jsDelivr 加载 UMD 时,默认 Worker 通常会跨域;此时需在应用同源托管 Worker 并覆盖 `workerUrl`,或设置 `sharing: false`。Vue、React 和普通 JS 的用法相同,Worker 配置取决于构建工具。
57
+ - 共享键由浏览器 origin、Worker URL、Worker 名称和完全相同的 `clientOptions` 共同决定;这些值不同的页面不会共用连接。
58
+ - 直接构造 `RTMSharedWorkerClient` 时支持 `clientOptions.protocol: 'tlv-v1'` 或 `'fpnn'`,省略时默认 FPNN;新工厂 `createClient()` 省略 `protocol` 时也默认 FPNN。只有显式传 `protocol: 'tlv-v1'` 才选择 TLV。FPNN 扩展是否可用以 npm `latest` 标签对应的 SDK 为准,同 UID 使用不同协议会建立独立连接。
59
+ - 一个 Worker 只登录一个 UID。不同 UID 同时在线必须分别建立 Worker/RTC 连接;单 UID 的多页面共享登录态。
60
+ - 每个页面有独立的 Push 监听端口。Worker 原样广播 SDK 事件。配置 `conversation` 后,由页面适配器按所选协议筛选监听器通知;未配置时该页面接收全部会话 Push。
61
+ - SDK 负责连接、重连、Push ACK/去重和端口分发;业务仍负责消息展示、历史补拉、业务未读规则、草稿与页面状态。
62
+ - 登录态保存在 Worker 内存。底层 RTC 断线由 `autoReconnect` 处理;初始化失败、Worker `error` 或消息端口错误会报告 `SharedWorkerError`,此时业务可丢弃失效 client 并重新创建。SDK 目前没有 Worker 就绪后的心跳检测;浏览器静默回收 Worker 时不保证触发该事件,页面可能无法及时察觉。新 Worker 的登录快照为 `idle` 时,业务需重新提供服务端签发的 credential。SDK 不持久化 credential,也不承诺把断线期间未投递的 Push 自动补齐。
63
+ - `destroy()` 只 detach 当前页面;最后一个页面 detach 后默认等待 5 秒再销毁共享 RTMClient,期间有新页面接入会取消回收。可通过 `idleShutdownTimeout` 调整,设为 0 表示立即关闭;同一个 Worker 的页面须使用相同值。`bye()` / `close()` 会结束所有共用页面的 RTC 会话。共享 Worker 初始化失败时不会静默降级为每页单独连接。
64
+
65
+ TLV v1 使用 MessagePack 二进制 WebSocket frame。SDK 提供以下基础模块:
66
+
67
+ - `RTMClient`:面向业务的登录、消息、群组、房间、历史和会话 API。
68
+ - `RTMProcessor`:接收并分发 Push;通过 `client.processor.on(name, callback)` 订阅事件。
69
+ - `TLVCodec`:编解码 TLV frame、Answer、Push 和 MessagePack body。
70
+ - `TLVWebSocketClient`:管理 TLV WebSocket 请求、响应、心跳和连接状态。
71
+ - `RTMConfig`:提供 `Int64`、消息类型、文件类型和 Push 名称常量。
72
+
73
+ ## 典型业务流程
74
+
75
+ ### Callback 与 Promise 写法
76
+
77
+ 为兼容既有应用,`RTMClient` 和 `RTMSharedWorkerClient` 保留 callback 方法;两者也提供 `client.promises`,把所有 callback 型业务请求封装为 Promise。原方法参数顺序不变,只省略 callback:
78
+
79
+ ```js
80
+ const result = await client.promises.sendChat(peerUid, 'hello', '{}', 0, 12000);
81
+ ```
82
+
83
+ `client.promises.login(uid, credential, timeout?)` 成功时 resolve `{ accepted: true, errorCode }`,鉴权失败时 reject 一个带 `code` 的 Error。TLV Gate 返回 `control.error` 时保留服务端错误码;若只返回 `accepted: false`,SDK 使用 `200027`。`client.promises.bye(timeout?)` 等待 Gate 应答协议关闭;TLV 请求失败时 SDK 主动关闭连接。`RTMSharedWorkerClient.loginIfNeeded()` 保持自己的结果约定:RTC 鉴权结果 resolve 为 `{ accepted, errorCode, reused, uid }`;Worker 初始化错误及缺少首次登录 credential 会 reject。其他生命周期方法和事件仍通过 client 本身调用。
84
+
85
+ ### 一对一聊天
86
+
87
+ 1. 构造 `RTMClient`,注册 `ErrorRecorder` 和 `event.direct` Push 监听。
88
+ 2. 调用 `login` 进入登录态。
89
+ 3. 使用 `sendChat`、`sendAudio` 或 `sendCmd` 发送消息。
90
+ 4. 在 `event.direct` 回调中接收对方消息;SDK 自动回复可靠 Push 的 `control.ack` 并按 `message_ref` 去重。
91
+ 5. 使用 `getP2PMessage` 或 `getP2PConversationList` 加载历史和会话摘要。
92
+
93
+ ### 群组与房间互动
94
+
95
+ 群组流程使用 `addGroupMembers`、`getGroupMembers` 和 `sendGroupChat` 管理成员与消息;房间流程使用 `enterRoom`、`getRoomMembers` 和 `sendRoomChat` 管理在线参与者与消息。两类消息分别通过 `event.group` 和 `event.room` 接收。
96
+
97
+ ### 登录后的收件箱同步
98
+
99
+ 应用恢复到前台或完成重新登录后,可以组合使用:
100
+
101
+ 1. `getUnreadMessage` 获取未读范围;
102
+ 2. `getP2PUnreadConversationList`、`getGroupUnreadConversationList` 或 `getUnreadConversationList` 获取会话摘要;
103
+ 3. `getP2PMessage`、`getGroupMessage` 或 `getRoomMessage` 分页读取历史;
104
+ 4. `setSessionRead` 标记已读,必要时使用 `cleanUnreadMessage` 清理全局未读状态。
105
+
106
+ ### 发送前的内容处理
107
+
108
+ 发送文本前可先调用 `textCheck` 获取审核结果,再根据业务策略调用 `translate` 生成目标语言内容,最后使用 `sendChat`、`sendGroupChat` 或 `sendRoomChat` 发送。审核和翻译的请求字段、返回结构见 [TLV v1 Client API 契约](TLV_CONTRACT.md)。
109
+
110
+ ### 文件消息
111
+
112
+ 文件消息可以使用 `fileToken` 获取上传所需的 token 和 endpoint,再调用 `sendFile`、`sendGroupFile` 或 `sendRoomFile` 完成消息发送;接收方通过对应的文件 Push 获取文件地址和消息元数据。
113
+
114
+ ## 核心数据约定
115
+
116
+ - **ID 与时间**:用户 ID、群组 ID、房间 ID、消息引用和时间游标可能超过 JavaScript 安全整数范围,使用 `new RTMConfig.Int64(String(value))` 传入和读取。
117
+ - **消息类型**:`RTMConfig.CHAT_TYPE.text`、`audio`、`cmd` 分别对应文本、语音和命令消息。
118
+ - **文件类型**:文件消息的类型使用 `RTMConfig.FILE_TYPE` 中的 image、audio、video、file。
119
+ - **普通回调**:大多数业务 API 使用 `callback(err, data)`;发送 API 成功结果包含 `message_ref` 和 `payload`。
120
+ - **登录回调**:`login` 使用 `callback(accepted, errorCode)`;连接、协议和登录错误可通过 `ErrorRecorder` 观察。普通业务 API 的 Gate 错误由对应的 `callback(err, data)` 或 Promise rejection 返回,不会另发全局事件。
121
+ - **TLV Push**:应用通过 `RTMConfig.TLV_SERVER_PUSH` 取得 `event.direct`、`event.group`、`event.room`、`event.broadcast`、`event.kicked` 和 `event.room_removed` 的订阅名称。
122
+
123
+ ## 文档导航
124
+
125
+ - [快速开始与引用](../README.md)
126
+ - [公开 API 参数](USAGE.md)
127
+ - [FPNN 与 TLV v1 迁移对照](PROTOCOL_MIGRATION.md)
128
+ - [TLV v1 URI、字段和返回值](TLV_CONTRACT.md)
129
+ - [TLV v1 frame 与编解码](TLV.md)
package/docs/Chat.md ADDED
@@ -0,0 +1,278 @@
1
+ # RTM Client Websocket SDK Chat API Docs
2
+
3
+ ## Index
4
+
5
+ [TOC]
6
+
7
+ ## Apis
8
+
9
+ **协议范围:** 本页记录 FPNN 兼容 API 的参数和事件名称;列出的方法不一定都能通过 TLV v1 调用。请先核对 [TLV v1 支持矩阵](USAGE.md#6-tlv-v1-api-支持矩阵);两协议的 method、URI 和 Push 对照见[协议迁移说明](PROTOCOL_MIGRATION.md)。
10
+
11
+ * `sendChat(to, msg, attrs, mid, timeout, callback)`: 发送文本聊天
12
+ * `to`: **(Required | Int64)** 接收方uid
13
+ * `msg`: **(Required | string)** 消息内容
14
+ * `attrs`: **(Required | string)** 消息附加信息, 没有可传`''`
15
+ * `mid`: **(Optional | Int64)** 消息 id, 用于过滤重复消息, 非重发时为`Int64(0)`
16
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
17
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
18
+ * `err`: **(object[mid:Int64, error:Error])**
19
+ * `data`: **(object[mid:Int64, payload:object[mtime:Int64]])**
20
+
21
+ * `sendGroupChat(gid, msg, attrs, mid, timeout, callback)`: 发送group文本聊天
22
+ * `gid`: **(Required | Int64)** group id
23
+ * `msg`: **(Required | string)** 消息内容
24
+ * `attrs`: **(Required | string)** 消息附加信息, 可传`''`
25
+ * `mid`: **(Optional | Int64)** 消息 id, 用于过滤重复消息, 非重发时为`Int64(0)`
26
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
27
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
28
+ * `err`: **(object[mid:Int64, error:Error])**
29
+ * `data`: **(object[mid:Int64, payload:object[mtime:Int64]])**
30
+
31
+ * `sendRoomChat(rid, msg, attrs, mid, timeout, callback)`: 发送room文本聊天
32
+ * `rid`: **(Required | Int64)** room id
33
+ * `msg`: **(Required | string)** 消息内容
34
+ * `attrs`: **(Required | string)** 消息附加信息, 可传`''`
35
+ * `mid`: **(Optional | Int64)** 消息 id, 用于过滤重复消息, 非重发时为`Int64(0)`
36
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
37
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
38
+ * `err`: **(object[mid:Int64, error:Error])**
39
+ * `data`: **(object[mid:Int64, payload:object[mtime:Int64]])**
40
+
41
+ * `sendAudio(to, msg, attrs, mid, timeout, callback)`: 发送语音聊天
42
+ * `to`: **(Required | Int64)** 接收方uid
43
+ * `msg`: **(Required | string)** 消息内容
44
+ * `attrs`: **(Required | string)** 消息附加信息, 没有可传`''`
45
+ * `mid`: **(Optional | Int64)** 消息 id, 用于过滤重复消息, 非重发时为`Int64(0)`
46
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
47
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
48
+ * `err`: **(object[mid:Int64, error:Error])**
49
+ * `data`: **(object[mid:Int64, payload:object[mtime:Int64]])**
50
+
51
+ * `sendGroupAudio(gid, msg, attrs, mid, timeout, callback)`: 发送group语音聊天
52
+ * `gid`: **(Required | Int64)** group id
53
+ * `msg`: **(Required | string)** 消息内容
54
+ * `attrs`: **(Required | string)** 消息附加信息, 可传`''`
55
+ * `mid`: **(Optional | Int64)** 消息 id, 用于过滤重复消息, 非重发时为`Int64(0)`
56
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
57
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
58
+ * `err`: **(object[mid:Int64, error:Error])**
59
+ * `data`: **(object[mid:Int64, payload:object[mtime:Int64]])**
60
+
61
+ * `sendRoomAudio(rid, msg, attrs, mid, timeout, callback)`: 发送room语音聊天
62
+ * `rid`: **(Required | Int64)** room id
63
+ * `msg`: **(Required | string)** 消息内容
64
+ * `attrs`: **(Required | string)** 消息附加信息, 可传`''`
65
+ * `mid`: **(Optional | Int64)** 消息 id, 用于过滤重复消息, 非重发时为`Int64(0)`
66
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
67
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
68
+ * `err`: **(object[mid:Int64, error:Error])**
69
+ * `data`: **(object[mid:Int64, payload:object[mtime:Int64]])**
70
+
71
+ * `sendCmd(to, msg, attrs, mid, timeout, callback)`: 发送聊天控制命令
72
+ * `to`: **(Required | Int64)** 接收方uid
73
+ * `msg`: **(Required | string)** 消息内容
74
+ * `attrs`: **(Required | string)** 消息附加信息, 没有可传`''`
75
+ * `mid`: **(Optional | Int64)** 消息 id, 用于过滤重复消息, 非重发时为`Int64(0)`
76
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
77
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
78
+ * `err`: **(object[mid:Int64, error:Error])**
79
+ * `data`: **(object[mid:Int64, payload:object[mtime:Int64]])**
80
+
81
+ * `sendGroupCmd(gid, msg, attrs, mid, timeout, callback)`: 发送group聊天控制命令
82
+ * `gid`: **(Required | Int64)** group id
83
+ * `msg`: **(Required | string)** 消息内容
84
+ * `attrs`: **(Required | string)** 消息附加信息, 可传`''`
85
+ * `mid`: **(Optional | Int64)** 消息 id, 用于过滤重复消息, 非重发时为`Int64(0)`
86
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
87
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
88
+ * `err`: **(object[mid:Int64, error:Error])**
89
+ * `data`: **(object[mid:Int64, payload:object[mtime:Int64]])**
90
+
91
+ * `sendRoomCmd(rid, msg, attrs, mid, timeout, callback)`: 发送room聊天控制命令
92
+ * `rid`: **(Required | Int64)** room id
93
+ * `msg`: **(Required | string)** 消息内容
94
+ * `attrs`: **(Required | string)** 消息附加信息, 可传`''`
95
+ * `mid`: **(Optional | Int64)** 消息 id, 用于过滤重复消息, 非重发时为`Int64(0)`
96
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
97
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
98
+ * `err`: **(object[mid:Int64, error:Error])**
99
+ * `data`: **(object[mid:Int64, payload:object[mtime:Int64]])**
100
+
101
+ * `deleteChat(from, mid, xid, type, timeout, callback)`: 删除消息
102
+ * `from`: **(Required | Int64)** 发送者用户 id
103
+ * `mid`: **(Required | Int64)** 消息 id
104
+ * `xid`: **(Required | Int64)** 消息接收方 id (userId/RoomId/GroupId)
105
+ * `type`: **(Required | number)** 接收方类型 (1:p2p, 2:group, 3:room)
106
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
107
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
108
+ * `err`: **(Error)**
109
+ * `data`: **(object)**
110
+
111
+ * `getChat(from, mid, xid, type, timeout, callback)`: 获取聊天
112
+ * `from`: **(Required | Int64)** 发送者用户 id
113
+ * `mid`: **(Required | Int64)** 消息 id
114
+ * `xid`: **(Required | Int64)** 消息接收方 id (userId/RoomId/GroupId)
115
+ * `type`: **(Required | number)** 接收方类型 (1:p2p, 2:group, 3:room)
116
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
117
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
118
+ * `err`: **(Error)**
119
+ * `data`: **(object[id: Int64, mtype: number, msg: string, attrs: string, mtime: Int64])**
120
+
121
+ * `getGroupChat(gid, desc, num, begin, end, lastid, timeout, callback)`: 获取Group历史聊天
122
+ * `gid`: **(Required | Int64)** Group id
123
+ * `desc`: **(Required | bool)** `true`: 则从`end`的时间戳开始倒序翻页, `false`: 则从`begin`的时间戳顺序翻页
124
+ * `num`: **(Required | number)** 获取数量, **一次最多获取20条, 建议10条**
125
+ * `begin`: **(Optional | Int64)** 开始时间戳, 毫秒, 默认`0`, 条件:`>=`
126
+ * `end`: **(Optional | Int64)** 结束时间戳, 毫秒, 默认`0`, 条件:`<=`
127
+ * `lastid`: **(Optional | Int64)** 最后一条消息的id, 第一次默认传`0`, 条件:`> or <`
128
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
129
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
130
+ * `err`: **(Error)**
131
+ * `data`: **(object[num:number, lastid:Int64, begin:Int64, end:Int64, msgs:array[GroupMsg]])**
132
+ * `GroupMsg.id` **(Int64)**
133
+ * `GroupMsg.from` **(Int64)**
134
+ * `GroupMsg.mtype` **(number)**
135
+ * `GroupMsg.mid` **(Int64)**
136
+ * `GroupMsg.deleted` **(bool)**
137
+ * `GroupMsg.msg` **(string)**
138
+ * `GroupMsg.attrs` **(string)**
139
+ * `GroupMsg.mtime` **(Int64)**
140
+
141
+ * `getRoomChat(rid, desc, num, begin, end, lastid, timeout, callback)`: 获取Room历史聊天
142
+ * `rid`: **(Required | Int64)** Room id
143
+ * `desc`: **(Required | bool)** `true`: 则从`end`的时间戳开始倒序翻页, `false`: 则从`begin`的时间戳顺序翻页
144
+ * `num`: **(Required | number)** 获取数量, **一次最多获取20条, 建议10条**
145
+ * `begin`: **(Optional | Int64)** 开始时间戳, 毫秒, 默认`0`, 条件:`>=`
146
+ * `end`: **(Optional | Int64)** 结束时间戳, 毫秒, 默认`0`, 条件:`<=`
147
+ * `lastid`: **(Optional | Int64)** 最后一条消息的id, 第一次默认传`0`, 条件:`> or <`
148
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
149
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
150
+ * `err`: **(Error)**
151
+ * `data`: **(object[num:number, lastid:Int64, begin:Int64, end:Int64, msgs:array[RoomMsg]])**
152
+ * `RoomMsg.id` **(Int64)**
153
+ * `RoomMsg.from` **(Int64)**
154
+ * `RoomMsg.mtype` **(number)**
155
+ * `RoomMsg.mid` **(Int64)**
156
+ * `RoomMsg.deleted` **(bool)**
157
+ * `RoomMsg.msg` **(string)**
158
+ * `RoomMsg.attrs` **(string)**
159
+ * `RoomMsg.mtime` **(Int64)**
160
+
161
+ * `getBroadcastChat(desc, num, begin, end, lastid, timeout, callback)`: 获取广播历史聊天
162
+ * `desc`: **(Required | bool)** `true`: 则从`end`的时间戳开始倒序翻页, `false`: 则从`begin`的时间戳顺序翻页
163
+ * `num`: **(Required | number)** 获取数量, **一次最多获取20条, 建议10条**
164
+ * `begin`: **(Optional | Int64)** 开始时间戳, 毫秒, 默认`0`, 条件:`>=`
165
+ * `end`: **(Optional | Int64)** 结束时间戳, 毫秒, 默认`0`, 条件:`<=`
166
+ * `lastid`: **(Optional | Int64)** 最后一条消息的id, 第一次默认传`0`, 条件:`> or <`
167
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
168
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
169
+ * `err`: **(Error)**
170
+ * `data`: **(object[num:number, lastid:Int64, begin:Int64, end:Int64, msgs:array[BroadcastMsg]])**
171
+ * `BroadcastMsg.id` **(Int64)**
172
+ * `BroadcastMsg.from` **(Int64)**
173
+ * `BroadcastMsg.mtype` **(number)**
174
+ * `BroadcastMsg.mid` **(Int64)**
175
+ * `BroadcastMsg.deleted` **(bool)**
176
+ * `BroadcastMsg.msg` **(string)**
177
+ * `BroadcastMsg.attrs` **(string)**
178
+ * `BroadcastMsg.mtime` **(Int64)**
179
+
180
+ * `getP2PChat(ouid, desc, num, begin, end, lastid, timeout, callback)`: 获取P2P历史聊天
181
+ * `ouid`: **(Required | Int64)** 获取和哪个用户id的历史消息
182
+ * `desc`: **(Required | bool)** `true`: 则从`end`的时间戳开始倒序翻页, `false`: 则从`begin`的时间戳顺序翻页
183
+ * `num`: **(Required | number)** 获取数量, **一次最多获取20条, 建议10条**
184
+ * `begin`: **(Optional | Int64)** 开始时间戳, 毫秒, 默认`0`, 条件:`>=`
185
+ * `end`: **(Optional | Int64)** 结束时间戳, 毫秒, 默认`0`, 条件:`<=`
186
+ * `lastid`: **(Optional | Int64)** 最后一条消息的id, 第一次默认传`0`, 条件:`> or <`
187
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
188
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
189
+ * `err`: **(Error)**
190
+ * `data`: **(object[num:number, lastid:Int64, begin:Int64, end:Int64, msgs:array[P2PMsg]])**
191
+ * `P2PMsg.id` **(Int64)**
192
+ * `P2PMsg.direction` **(number)**
193
+ * `P2PMsg.mtype` **(number)**
194
+ * `P2PMsg.mid` **(Int64)**
195
+ * `P2PMsg.deleted` **(bool)**
196
+ * `P2PMsg.msg` **(string)**
197
+ * `P2PMsg.attrs` **(string)**
198
+ * `P2PMsg.mtime` **(Int64)**
199
+
200
+ * `getSession(timeout, callback)`: 获取所有会话
201
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
202
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
203
+ * `err`: **(Error)**
204
+ * `data`: **(object[p2p:object[string, Int64], group:object[string, Int64]])** 对应值为最后一次会话的UTC时间戳
205
+
206
+ * `setTranslationLanguage(targetLanguage, timeout, callback)`: 设置自动翻译的默认目标语言类型, 如果 targetLanguage 为空字符串, 则取消自动翻译
207
+ * `targetLanguage`: **(Required | string)** 翻译的目标语言类型
208
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
209
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
210
+ * `err`: **(Error)**
211
+ * `data`: **(object)**
212
+
213
+ * `getP2PConversationList(mtime, mtypes, timeout, callback)`: 获取所有p2p会话列表
214
+ * `mtime`: **(Optional | int64)** 毫秒级时间戳,大于该时间戳的消息被计为未读消息,未读消息的最后一条作为会话的最后一条消息。不传则默认取上次离线时间。
215
+ * `mtypes`: **(Optional | set<int8>)** 消息类型列表,不传则默认查询mtype为30-50的消息
216
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
217
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
218
+ * `err`: **(Error)**
219
+ * `data`: **(object)**
220
+ * conversations参数为会话id列表,为p2p会话中对方的uid
221
+ * unreads参数为未读数量列表
222
+ * msgs参数为最后一条消息列表
223
+
224
+ * `getP2PUnreadConversationList(mtime, mtypes, timeout, callback)`: 获取所有p2p会话列表
225
+ * `mtime`: **(Optional | int64)** 毫秒级时间戳,大于该时间戳的消息被计为未读消息,未读消息的最后一条作为会话的最后一条消息。不传则默认取上次离线时间。
226
+ * `mtypes`: **(Optional | set<int8>)** 消息类型列表,不传则默认查询mtype为30-50的消息
227
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
228
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
229
+ * `err`: **(Error)**
230
+ * `data`: **(object)**
231
+ * conversations参数为会话id列表,为p2p会话中对方的uid
232
+ * unreads参数为未读数量列表
233
+ * msgs参数为最后一条消息列表
234
+
235
+ * `getGroupConversationList(mtime, mtypes, timeout, callback)`: 获取所有群组会话列表
236
+ * `mtime`: **(Optional | int64)** 毫秒级时间戳,大于该时间戳的消息被计为未读消息,未读消息的最后一条作为会话的最后一条消息。不传则默认取上次离线时间。
237
+ * `mtypes`: **(Optional | set<int8>)** 消息类型列表,不传则默认查询mtype为30-50的消息
238
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
239
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
240
+ * `err`: **(Error)**
241
+ * `data`: **(object)**
242
+ * conversations参数为会话id列表,为p2p会话中对方的uid
243
+ * unreads参数为未读数量列表
244
+ * msgs参数为最后一条消息列表
245
+
246
+ * `getGroupUnreadConversationList(mtime, mtypes, timeout, callback)`: 获取所有群组未读会话列表
247
+ * `mtime`: **(Optional | int64)** 毫秒级时间戳,大于该时间戳的消息被计为未读消息,未读消息的最后一条作为会话的最后一条消息。不传则默认取上次离线时间。
248
+ * `mtypes`: **(Optional | set<int8>)** 消息类型列表,不传则默认查询mtype为30-50的消息
249
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
250
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
251
+ * `err`: **(Error)**
252
+ * `data`: **(object)**
253
+ * conversations参数为会话id列表,为p2p会话中对方的uid
254
+ * unreads参数为未读数量列表
255
+ * msgs参数为最后一条消息列表
256
+
257
+ * `getUnreadConversationList(clear, mtime, mtypes, timeout, callback)`: 获取所有群组未读会话列表
258
+ * `clear`: **(Optional | bool)** 是否清除会话未读状态
259
+ * `mtime`: **(Optional | int64)** 毫秒级时间戳,大于该时间戳的消息被计为未读消息,未读消息的最后一条作为会话的最后一条消息。不传则默认取上次离线时间。
260
+ * `mtypes`: **(Optional | set<int8>)** 消息类型列表,不传则默认查询mtype为30-50的消息
261
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
262
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
263
+ * `err`: **(Error)**
264
+ * `data`: **(object)**
265
+ * groupConversations参数为群组会话id列表,为群组id
266
+ * groupUnreads参数为群组会话未读数量列表
267
+ * groupMsgs参数为群组会话最后一条消息列表
268
+ * p2pConversations参数为P2P会话id列表,为p2p会话中对方的uid
269
+ * p2pUnreads参数为P2P会话未读数量列表
270
+ * p2pMsgs参数为P2P会话最后一条消息列表
271
+
272
+ * `removeSession(to, localOnly, timeout, callback)`: 删除 p2p 会话;旧调用 `removeSession(to, timeout, callback)` 仍兼容。
273
+ * `to`: **(Required | Int64)** p2p会话中对方的uid
274
+ * `localOnly`: **(Optional | bool)** 只在本地移除会话;省略时保留旧 FPNN 请求语义
275
+ * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
276
+ * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
277
+ * `err`: **(object[mid:Int64, error:Error])**
278
+ * `data`: **(object)**