@cg-devcenter/rtc-fpnn-webjs-sdk 1.0.0-cg.6 → 1.0.0-cg.8

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;
@@ -3,6 +3,35 @@ import rtm = require('./rtm');
3
3
  declare const sdk: typeof rtm;
4
4
 
5
5
  export default sdk;
6
+ export type RTMProtocol = rtm.RTMProtocol;
7
+ export type RTMId = rtm.RTMId;
8
+ export type RTMLoginPromiseResult = rtm.RTMLoginPromiseResult;
9
+ export type RTMPromiseApi = rtm.RTMPromiseApi;
10
+ export type RTMSharedWorkerPromiseApi = rtm.RTMSharedWorkerPromiseApi;
11
+ export type RTMDefaultPromiseApi = rtm.RTMDefaultPromiseApi;
12
+ export type RTMRegressiveStrategy = rtm.RTMRegressiveStrategy;
13
+ export type RTMClientBaseOptions = rtm.RTMClientBaseOptions;
14
+ export type RTMClientOptions = rtm.RTMClientOptions;
15
+ export type RTMSharedWorkerBaseClientOptions = rtm.RTMSharedWorkerBaseClientOptions;
16
+ export type RTMSharedWorkerClientOptions = rtm.RTMSharedWorkerClientOptions;
17
+ export type RTMConversationType = rtm.RTMConversationType;
18
+ export type RTMConversation = rtm.RTMConversation;
19
+ export type RTMSharedWorkerOptions = rtm.RTMSharedWorkerOptions;
20
+ export type RTMSharedCreateClientOptions = rtm.RTMSharedCreateClientOptions;
21
+ export type RTMIndependentCreateClientOptions = rtm.RTMIndependentCreateClientOptions;
22
+ export type RTMCreateClientOptions = rtm.RTMCreateClientOptions;
23
+ export type RTMConnectionInfo = rtm.RTMConnectionInfo;
24
+ export type RTMConnectionInfoProvider = rtm.RTMConnectionInfoProvider;
25
+ export type RTMDefaultClient = rtm.RTMDefaultClient;
26
+ export type RTMSharedSessionSnapshot = rtm.RTMSharedSessionSnapshot;
27
+ export type RTMSharedLoginResult = rtm.RTMSharedLoginResult;
28
+ export type RTMSharedWorkerIdentity = rtm.RTMSharedWorkerIdentity;
29
+ export type RTMClient = rtm.RTMClient;
30
+ export type RTMSharedWorkerClient = rtm.RTMSharedWorkerClient;
31
+ export type RTMConfig = rtm.RTMConfig;
32
+ export type RTMProcessor = rtm.RTMProcessor;
33
+ export type TLVCodec = rtm.TLVCodec;
34
+ export type TLVWebSocketClient = rtm.TLVWebSocketClient;
6
35
  export const RTMClient: typeof rtm.RTMClient;
7
36
  export const createClient: typeof rtm.createClient;
8
37
  export const RTMSharedWorkerClient: typeof rtm.RTMSharedWorkerClient;
package/dist/rtm.vite.mjs CHANGED
@@ -1,32 +1,30 @@
1
- // Use the package export for the UMD bundle so Vite's dependency optimizer
2
- // provides CommonJS default interop. A relative import from this ESM wrapper
3
- // is served as native ESM in dev and has no default export.
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.
4
3
  import rtmModule from '@cg-devcenter/rtc-fpnn-webjs-sdk/dist/rtm.min.js';
5
4
  import workerUrl from './rtm.shared-worker.js?url';
6
5
 
7
6
  const rtm = rtmModule.default || rtmModule;
8
7
 
9
8
  class RTMSharedWorkerClient extends rtm.RTMSharedWorkerClient {
10
- constructor(options) {
11
- const config = options || {};
12
- super(Object.assign({}, config, {
13
- workerUrl: config.workerUrl || workerUrl
14
- }));
15
- }
9
+ constructor(options) {
10
+ const config = options || {};
11
+ super(Object.assign({}, config, {
12
+ workerUrl: config.workerUrl || workerUrl,
13
+ }));
14
+ }
16
15
  }
17
16
 
18
17
  function createClient(options) {
19
- const config = options || {};
20
- return rtm.createClient(Object.assign({}, config, {
21
- workerUrl: config.workerUrl || workerUrl
22
- }));
18
+ const config = options || {};
19
+ return rtm.createClient(Object.assign({}, config, {
20
+ workerUrl: config.workerUrl || workerUrl,
21
+ }));
23
22
  }
24
23
 
25
24
  const sdk = Object.assign({}, rtm, { RTMSharedWorkerClient, createClient });
26
25
 
27
26
  export const RTMClient = sdk.RTMClient;
28
- export { createClient };
29
- export { RTMSharedWorkerClient };
27
+ export { createClient, RTMSharedWorkerClient };
30
28
  export const RTMConfig = sdk.RTMConfig;
31
29
  export const RTMProcessor = sdk.RTMProcessor;
32
30
  export const TLVCodec = sdk.TLVCodec;
@@ -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;
@@ -8,7 +8,7 @@
8
8
 
9
9
  ## 能力地图
10
10
 
11
- 推荐通过 `createClient()` 默认共享接入:扁平配置,UID 从登录参数取得,SDK 按 PID、协议、UID 和 Gate endpoint 自动隔离并复用连接。`sharing: false` 显式选择独立连接;旧构造器保留业务 API;共享构造器与工厂自动采用同一环境身份。若 npm `latest` 尚未包含此入口,请使用本地构建;配置、错误和生命周期见 [默认共享接入](USAGE.md#默认共享接入当前源码)。
11
+ 推荐通过 `createClient()` 接入:扁平配置,UID 从登录参数取得;浏览器支持 SharedWorker 且配置可安全传递时,SDK 按 PID、协议、UID 和 Gate endpoint 自动隔离并复用连接。工作区 `1.0.0-cg.8` 在不支持 Worker 或配置包含函数、自定义对象等运行时值时,自动使用当前页面连接;`getConnectionInfo()` 报告实际模式和回退原因。工厂和 `RTMSharedWorkerClient` 省略协议时均默认使用 FPNN,TLV 需显式选择。`sharing: false` 可显式选择页面内连接;旧构造器保留业务 API。混用共享入口时,连接参数仍须保持一致。npm `latest` `1.0.0-cg.7` 已包含包根 ESM 和构建插件入口,但尚不包含本段所述配置值回退和诊断 API;这些能力尚未发布到 npm。配置、错误和生命周期见 [默认共享接入](USAGE.md#默认共享接入)。
12
12
 
13
13
  | 业务目标 | SDK 能力 | 常用 API |
14
14
  | --- | --- | --- |
@@ -43,21 +43,21 @@
43
43
  | 能力 | `RTMClient` + TLV v1 | `RTMClient` + FPNN | `RTMSharedWorkerClient` |
44
44
  | --- | --- | --- | --- |
45
45
  | 连接环境 | 浏览器;Node.js 需传入 `webSocketFactory` | 浏览器 | 支持 SharedWorker 的浏览器,同源页面 |
46
- | 用户/群组/房间/广播消息 | 支持;按 TLV v1 契约字段校验 | 支持兼容 API | 沿用所选协议已开放 API(文件发送除外) |
47
- | Push ACK 与去重 | SDK 自动 ACK 可靠 Push,并按 `message_ref` 去重 | 沿用兼容实现 | 单条共享连接只 ACK 一次,再按页面会话路由给各端口 |
48
- | 文件、设备、好友、多媒体审核 | TLV v1 当前未开放的传统 API 不可用 | 兼容 API 可用,依赖对应服务端能力 | 两种模式都不支持文件发送;FPNN 设备/好友/审核可转发,TLV 按其支持范围 |
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
49
  | 多页面连接共享 | 每个 `RTMClient` 实例各自管理连接 | 每个 `RTMClient` 实例各自管理连接 | 相同协议、Worker identity 与配置下,同一 UID 共用一条连接 |
50
50
  | 业务 UI 与消息存储 | 应用负责展示、缓存和历史补拉 | 应用负责展示、缓存和历史补拉 | 只路由实时 Push;不跨页同步草稿、未读 UI 状态或本地消息列表,也不持久化消息 |
51
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`)。`RTMSharedWorkerClient` 的文件发送方法在本地拒绝:callback 收到 `{mid, error}`,Promise 版本 reject 同一对象,`error.code` 为 `200999`(`RTM_EC_UNKNOWN_ERROR`),不发送 wire 请求。以上情况均不会退回 FPNN。SharedWorker 不是另一套 RTC 协议,也不替业务服务端签发 credential。
52
+ TLV v1 的能力以 [Client API 契约](TLV_CONTRACT.md) 的 URI 表为准;旧 API 名称存在不代表 TLV 服务端开放了该 wire。保留但未开放的 wire 返回 `200020`(`RTM_EC_FORBIDDEN_METHOD`);未知且未登记的 wire 返回 `20004`(`RTM_EC_UNKNOWN_METHOD`)。共享层自动代理 SDK 公开业务方法;FPNN 文件发送可用,TLV 文件发送由底层 SDK 拒绝,callback 收到 `{mid, error}`、`error.code` 为 `200020`,Promise 版本 reject 同一对象。以上情况均不会退回 FPNN。SharedWorker 不是另一套 RTC 协议,也不替业务服务端签发 credential。
53
53
 
54
54
  ### SharedWorker 共享范围
55
55
 
56
- - SDK 会默认从加载它的页面脚本同目录定位 `rtm.shared-worker.js`;Vite 项目可从 `@cg-devcenter/rtc-fpnn-webjs-sdk/vite` 导入 ESM 入口,由 SDK 自动将 Worker 作为构建资源配置给客户端。部署时 Worker 必须在页面同源下可访问;非 Vite 自定义部署路径时可显式提供 `workerUrl`。
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
57
  - 共享键由浏览器 origin、Worker URL、Worker 名称和完全相同的 `clientOptions` 共同决定;这些值不同的页面不会共用连接。
58
- - 支持 `clientOptions.protocol: 'tlv-v1'` 或 `'fpnn'`,默认仍为 TLV;FPNN 扩展是否可用以 npm `latest` 标签对应的 SDK 为准,同 UID 使用不同协议会建立独立连接。
58
+ - 直接构造 `RTMSharedWorkerClient` 时支持 `clientOptions.protocol: 'tlv-v1'` 或 `'fpnn'`,省略时默认 FPNN;新工厂 `createClient()` 省略 `protocol` 时也默认 FPNN。只有显式传 `protocol: 'tlv-v1'` 才选择 TLV。FPNN 扩展是否可用以 npm `latest` 标签对应的 SDK 为准,同 UID 使用不同协议会建立独立连接。
59
59
  - 一个 Worker 只登录一个 UID。不同 UID 同时在线必须分别建立 Worker/RTC 连接;单 UID 的多页面共享登录态。
60
- - 每个页面有独立的 Push 监听端口。配置 `conversation` 后,SDK 按所选协议提取 direct sender、group ref 或 room ref 后过滤,保留原协议事件名和数据;未配置时该页面接收全部会话 Push。
60
+ - 每个页面有独立的 Push 监听端口。Worker 原样广播 SDK 事件。配置 `conversation` 后,由页面适配器按所选协议筛选监听器通知;未配置时该页面接收全部会话 Push。
61
61
  - SDK 负责连接、重连、Push ACK/去重和端口分发;业务仍负责消息展示、历史补拉、业务未读规则、草稿与页面状态。
62
62
  - 登录态保存在 Worker 内存。底层 RTC 断线由 `autoReconnect` 处理;初始化失败、Worker `error` 或消息端口错误会报告 `SharedWorkerError`,此时业务可丢弃失效 client 并重新创建。SDK 目前没有 Worker 就绪后的心跳检测;浏览器静默回收 Worker 时不保证触发该事件,页面可能无法及时察觉。新 Worker 的登录快照为 `idle` 时,业务需重新提供服务端签发的 credential。SDK 不持久化 credential,也不承诺把断线期间未投递的 Push 自动补齐。
63
63
  - `destroy()` 只 detach 当前页面;最后一个页面 detach 后默认等待 5 秒再销毁共享 RTMClient,期间有新页面接入会取消回收。可通过 `idleShutdownTimeout` 调整,设为 0 表示立即关闭;同一个 Worker 的页面须使用相同值。`bye()` / `close()` 会结束所有共用页面的 RTC 会话。共享 Worker 初始化失败时不会静默降级为每页单独连接。
package/docs/Chat.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  ## Apis
8
8
 
9
+ **协议范围:** 本页记录 FPNN 兼容 API 的参数和事件名称;列出的方法不一定都能通过 TLV v1 调用。请先核对 [TLV v1 支持矩阵](USAGE.md#6-tlv-v1-api-支持矩阵);两协议的 method、URI 和 Push 对照见[协议迁移说明](PROTOCOL_MIGRATION.md)。
10
+
9
11
  * `sendChat(to, msg, attrs, mid, timeout, callback)`: 发送文本聊天
10
12
  * `to`: **(Required | Int64)** 接收方uid
11
13
  * `msg`: **(Required | string)** 消息内容
@@ -26,7 +28,7 @@
26
28
  * `err`: **(object[mid:Int64, error:Error])**
27
29
  * `data`: **(object[mid:Int64, payload:object[mtime:Int64]])**
28
30
 
29
- * `sendRoomChat(rid, mtype, msg, attrs, mid, timeout, callback)`: 发送room文本聊天
31
+ * `sendRoomChat(rid, msg, attrs, mid, timeout, callback)`: 发送room文本聊天
30
32
  * `rid`: **(Required | Int64)** room id
31
33
  * `msg`: **(Required | string)** 消息内容
32
34
  * `attrs`: **(Required | string)** 消息附加信息, 可传`''`
@@ -56,7 +58,7 @@
56
58
  * `err`: **(object[mid:Int64, error:Error])**
57
59
  * `data`: **(object[mid:Int64, payload:object[mtime:Int64]])**
58
60
 
59
- * `sendRoomAudio(rid, mtype, msg, attrs, mid, timeout, callback)`: 发送room语音聊天
61
+ * `sendRoomAudio(rid, msg, attrs, mid, timeout, callback)`: 发送room语音聊天
60
62
  * `rid`: **(Required | Int64)** room id
61
63
  * `msg`: **(Required | string)** 消息内容
62
64
  * `attrs`: **(Required | string)** 消息附加信息, 可传`''`
@@ -86,7 +88,7 @@
86
88
  * `err`: **(object[mid:Int64, error:Error])**
87
89
  * `data`: **(object[mid:Int64, payload:object[mtime:Int64]])**
88
90
 
89
- * `sendRoomCmd(rid, mtype, msg, attrs, mid, timeout, callback)`: 发送room聊天控制命令
91
+ * `sendRoomCmd(rid, msg, attrs, mid, timeout, callback)`: 发送room聊天控制命令
90
92
  * `rid`: **(Required | Int64)** room id
91
93
  * `msg`: **(Required | string)** 消息内容
92
94
  * `attrs`: **(Required | string)** 消息附加信息, 可传`''`
@@ -267,10 +269,10 @@
267
269
  * p2pUnreads参数为P2P会话未读数量列表
268
270
  * p2pMsgs参数为P2P会话最后一条消息列表
269
271
 
270
- * `removeSession(to, timeout, callback)`: 删除p2p会话
272
+ * `removeSession(to, localOnly, timeout, callback)`: 删除 p2p 会话;旧调用 `removeSession(to, timeout, callback)` 仍兼容。
271
273
  * `to`: **(Required | Int64)** p2p会话中对方的uid
274
+ * `localOnly`: **(Optional | bool)** 只在本地移除会话;省略时保留旧 FPNN 请求语义
272
275
  * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
273
276
  * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
274
277
  * `err`: **(object[mid:Int64, error:Error])**
275
278
  * `data`: **(object)**
276
-
package/docs/Data.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  ## Apis
8
8
 
9
+ **协议范围:** 本页记录 FPNN 兼容 API 的参数和事件名称;列出的方法不一定都能通过 TLV v1 调用。请先核对 [TLV v1 支持矩阵](USAGE.md#6-tlv-v1-api-支持矩阵);两协议的 method、URI 和 Push 对照见[协议迁移说明](PROTOCOL_MIGRATION.md)。
10
+
9
11
  * `dataSet(key, value, timeout, callback)`: 设置存储的数据信息(key:最长128字节,val:最长65535字节)
10
12
  * `key`: **(Required | string)** 数据的key
11
13
  * `value`: **(Optional | string)** 数据的value
@@ -6,6 +6,8 @@
6
6
 
7
7
  ## Apis
8
8
 
9
+ **协议范围:** 本页记录 FPNN 兼容 API 的参数和事件名称;列出的方法不一定都能通过 TLV v1 调用。请先核对 [TLV v1 支持矩阵](USAGE.md#6-tlv-v1-api-支持矩阵);两协议的 method、URI 和 Push 对照见[协议迁移说明](PROTOCOL_MIGRATION.md)。
10
+
9
11
  请参考 `RTMConfig.SERVER_PUSH` 成员
10
12
 
11
13
  > TLV v1 模式说明:网络 Push wire 为 `event.direct`、`event.group`、`event.room`、`event.broadcast`、`event.kicked`、`event.room_removed`,请通过 `RTMConfig.TLV_SERVER_PUSH` 订阅同名事件;data 使用新字段(例如 `message_ref`、`time_ms`、`payload`)。前四类会在回调前自动发送 `control.ack`,后两类不会 ACK。TLV 业务心跳改为 Client 主动 `control.ping`,不再依赖本页的服务端 `ping` Push。
package/docs/Files.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  ## Apis
8
8
 
9
+ FPNN 模式下,以下 API 同时适用于独立 `RTMClient` 和共享客户端(`createClient()` / `RTMSharedWorkerClient`),callback 与 Promise 结果沿用 SDK 约定。SharedWorker 通过结构化克隆接收 `File`,由内部 SDK 获取 token 并建立文件代理连接上传。现有上传会读取整个文件到内存;不承诺所有页面关闭或 Worker 被回收后仍能完成后台上传。TLV v1 的文件接口仍由底层协议契约拒绝。
10
+
9
11
  * `fileToken(cmd, tos, to, rid, gid, timeout, callback)`: 获取发送文件的token
10
12
  * `cmd`: **(Required | string)** 文件发送方式`sendfile | sendroomfile | sendgroupfile`
11
13
  * `tos`: **(Optional | array[Int64])** 接收方 uids
package/docs/Friends.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  ## Apis
8
8
 
9
+ **协议范围:** 本页记录 FPNN 兼容 API 的参数和事件名称;列出的方法不一定都能通过 TLV v1 调用。请先核对 [TLV v1 支持矩阵](USAGE.md#6-tlv-v1-api-支持矩阵);两协议的 method、URI 和 Push 对照见[协议迁移说明](PROTOCOL_MIGRATION.md)。
10
+
9
11
  * `addFriends(friends, timeout, callback)`: 添加好友
10
12
  * `friends`: **(Required | array[Int64])** 多个好友 id
11
13
  * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
package/docs/Groups.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  ## Apis
8
8
 
9
+ **协议范围:** 本页记录 FPNN 兼容 API 的参数和事件名称;列出的方法不一定都能通过 TLV v1 调用。请先核对 [TLV v1 支持矩阵](USAGE.md#6-tlv-v1-api-支持矩阵);两协议的 method、URI 和 Push 对照见[协议迁移说明](PROTOCOL_MIGRATION.md)。
10
+
9
11
  * `setGroupInfo(gid, oinfo, pinfo, timeout, callback) `: 设置组信息
10
12
  * `gid`: **(Required | Int64)** 组id
11
13
  * `oinfo`: **(Optional | string)** 公开信息
package/docs/Messages.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  ## Apis
8
8
 
9
+ **协议范围:** 本页记录 FPNN 兼容 API 的参数和事件名称;列出的方法不一定都能通过 TLV v1 调用。请先核对 [TLV v1 支持矩阵](USAGE.md#6-tlv-v1-api-支持矩阵);两协议的 method、URI 和 Push 对照见[协议迁移说明](PROTOCOL_MIGRATION.md)。
10
+
9
11
  * `sendMessage(to, mtype, msg, attrs, mid, timeout, callback)`: 发送消息
10
12
  * `to`: **(Required | Int64)** 接收方uid
11
13
  * `mtype`: **(Required | number)** 消息类型
@@ -41,8 +43,9 @@
41
43
 
42
44
 
43
45
 
44
- * `getUnreadMessage(clear, timeout, callback)`: 检测未读消息数目
46
+ * `getUnreadMessage(clear, withLogout, timeout, callback)`: 检测未读消息数目;旧调用 `getUnreadMessage(clear, timeout, callback)` 仍兼容。
45
47
  * `clear`: **(Optional | bool)** 是否除离线提醒
48
+ * `withLogout`: **(Optional | bool)** 是否返回登出时间
46
49
  * `timeout`: **(Optional | number)** 超时时间(ms), 默认: `20 * 1000`
47
50
  * `callback`: **(Optional | function)** 回调方法, `callback(err, data)`
48
51
  * `err`: **(Error)**