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

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.
package/docs/TLV.md ADDED
@@ -0,0 +1,62 @@
1
+ # TLV v1 传输 API
2
+
3
+ TLV v1 使用 MessagePack over WebSocket。公开方法见 [SDK API](USAGE.md),完整 URI 与字段见
4
+ [TLV v1 Client 契约](TLV_CONTRACT.md)。
5
+
6
+ ## 连接接口
7
+
8
+ | 项目 | 规则 |
9
+ | --- | --- |
10
+ | 协议模式 | `protocol: 'tlv-v1'` |
11
+ | 端点 | `tlvEndpoint` 为完整 `ws://` 或 `wss://` URL |
12
+ | WebSocket | 每个 binary message 恰好一个完整 TLV frame |
13
+ | 非浏览器运行时 | 提供 `webSocketFactory(url)`;旧 `fpnn` 不可用 |
14
+ | 鉴权 | `login(uid, credential, callback, timeout)`;仅 `accepted === true` 进入登录态 |
15
+
16
+ ## Frame 接口
17
+
18
+ | 字段 | 规则 |
19
+ | --- | --- |
20
+ | Header | `magic=0xCC`、`version=1`、`flags=0x04`、正整数 little-endian `sequence` |
21
+ | Metadata | 唯一 `mt`,值为 `'0'`、`'1'` 或 `'2'` |
22
+ | Message | 唯一 URI、空 `passThrough`、MessagePack map body |
23
+ | WebSocket body | 仅 binary;不含 TCP length header |
24
+
25
+ | 方向 | `mt` | URI |
26
+ | --- | --- | --- |
27
+ | Client → Gate 请求 | `'1'` | 业务 URI、`control.ping`、`connection.close` |
28
+ | Gate → Client 应答 | `'2'` | 原请求 URI 或 `control.error` |
29
+ | Gate → Client 可靠 Push | `'1'` | `event.direct`、`event.group`、`event.room`、`event.broadcast` |
30
+ | Client → Gate Push ACK | `'2'` | `control.ack` |
31
+ | Gate → Client 控制 Push | `'0'` | `event.kicked`、`event.room_removed` |
32
+
33
+ ## 编码接口
34
+
35
+ - body 必须是 string-keyed MessagePack map;无参数 body 为 `{}`。
36
+ - 整数使用安全 JavaScript 整数或 `RTMConfig.Int64`;不得以十进制字符串替代整数。
37
+ - `payload` 支持 string、MessagePack bin 或 Chat map;按实际 MessagePack 类型读取。
38
+ - `Uint8Array`、`ArrayBuffer`、`Buffer` 和 typed array 编码为 MessagePack bin。
39
+ - `requestMetadata()` 可附加 `trace:string`、`sent_ms:int64`。
40
+
41
+ ## 控制 API
42
+
43
+ | URI | 请求/响应 body | 行为 |
44
+ | --- | --- | --- |
45
+ | `control.ping` | `{}` / `{}` | SDK 空闲心跳。 |
46
+ | `control.ack` | `{}` | 复用可靠 Push sequence;无需应答。 |
47
+ | `control.error` | `{status:int32, reason:string}` | Gate 请求失败应答。 |
48
+ | `connection.close` | `{}` / `{}` | Gate 应答后关闭连接。 |
49
+
50
+ ## Push 接口
51
+
52
+ | URI | SDK 事件 | ACK |
53
+ | --- | --- | --- |
54
+ | `event.direct` | `TLV_SERVER_PUSH.recvMessage` | 自动 |
55
+ | `event.group` | `TLV_SERVER_PUSH.recvGroupMessage` | 自动 |
56
+ | `event.room` | `TLV_SERVER_PUSH.recvRoomMessage` | 自动 |
57
+ | `event.broadcast` | `TLV_SERVER_PUSH.recvBroadcastMessage` | 自动 |
58
+ | `event.kicked` | `TLV_SERVER_PUSH.kickOut` | 不发送 |
59
+ | `event.room_removed` | `TLV_SERVER_PUSH.kickOutRoom` | 不发送 |
60
+
61
+ 可靠 Push 以 `message_ref` 去重;每次重传仍发送 ACK。协议错误、心跳失败或连接关闭会失败当前
62
+ pending 请求;SDK 不重放结果未知的修改请求。
@@ -0,0 +1,180 @@
1
+ # TLV v1 Client API 契约
2
+
3
+ 本页定义 `RTMClient` 的 TLV v1 URI、请求字段与成功返回字段。公开方法参数见
4
+ [SDK API](USAGE.md),传输规则见 [TLV v1 传输 API](TLV.md)。
5
+
6
+ ## 类型与回调
7
+
8
+ | 标记 | 含义 |
9
+ | --- | --- |
10
+ | `id` / `i64` | `id` 为正整数,`i64` 为 signed int64;超出安全整数范围使用 `RTMConfig.Int64`。 |
11
+ | `i32` | MessagePack integer。 |
12
+ | `str` | UTF-8 string。 |
13
+ | `bin` | MessagePack binary。 |
14
+ | `id[]` | ID 数组;请求是否允许空数组由对应 URI 规定。 |
15
+ | `str-map` | `map<string, string>`。 |
16
+ | `tuple8` | `[cursor_id, sender_or_direction, kind, message_ref, deleted, payload, extra, time_ms]`;`cursor_id` 为不透明 int64 游标,不是 `message_ref`。 |
17
+ | `?` | 可选字段;未标记 `?` 的字段为必填。 |
18
+
19
+ 表中的 `Gate Answer` 是 Gate 的 TLV body;除特别说明的兼容包装外,SDK 将其作为 `data`
20
+ 传给 `callback(err, data)`。`login` 为 `callback(accepted, errorCode)`。所有请求可由
21
+ `requestMetadata` 附加 `trace:str`、`sent_ms:i64`。
22
+
23
+ ## 控制 URI 与 Push
24
+
25
+ | URI | `mt` | body |
26
+ | --- | --- | --- |
27
+ | `control.ping` | `'1'` / `'2'` | `{}` |
28
+ | `control.ack` | `'2'` | `{}` |
29
+ | `control.error` | `'2'` | `{status:i32, reason:str}` |
30
+ | `event.direct` | `'1'` | `recipient, sender, message_ref, kind, payload, extra, time_ms` |
31
+ | `event.group` | `'1'` | `group_ref, sender, message_ref, kind, payload, extra, time_ms` |
32
+ | `event.room` | `'1'` | `room_ref, sender, message_ref, kind, payload, extra, time_ms` |
33
+ | `event.broadcast` | `'1'` | `sender, message_ref, kind, payload, extra, time_ms` |
34
+ | `event.kicked` | `'0'` | `{}` |
35
+ | `event.room_removed` | `'0'` | `{room_ref:id}` |
36
+
37
+ 可靠 Push 自动回复 `control.ack` 并按 `message_ref` 去重;`event.kicked` 与
38
+ `event.room_removed` 不回复 ACK。
39
+
40
+ ## Auth、连接与系统
41
+
42
+ | SDK API | Gate URI | 请求字段 | Gate Answer |
43
+ | --- | --- | --- | --- |
44
+ | `login` | `auth.login` | `project, user, credential, client_ver, auth_sec?, auth_ver?, locale?, props?` | `accepted` |
45
+ | `bye` | `connection.close` | 无 | 无 |
46
+ | `getServerTime` | `system.time` | 无 | `server_ms` |
47
+ | `addAttrs` | `connection.set_props` | `props` | 无 |
48
+ | `getAttrs` | `connection.get_props` | 无 | `props` |
49
+ | `addDebugLog` | `system.debug` | `entry, context` | 无 |
50
+
51
+ `auth_sec` 与 `auth_ver` 必须同时存在或同时省略;存在时 `auth_ver` 必须为 `2`。
52
+
53
+ ## 用户、存储与黑名单
54
+
55
+ | SDK API | Gate URI | 请求字段 | Gate Answer |
56
+ | --- | --- | --- | --- |
57
+ | `getOnlineUsers` | `presence.online` | `users` | `online_users` |
58
+ | `setUserInfo` | `user.set_profile` | `public_data?, private_data?` | 无 |
59
+ | `getUserInfo` | `user.get_profile` | 无 | `public_data, private_data` |
60
+ | `getUserOpenInfo` | `user.get_public` | `users` | `profiles` |
61
+ | `setTranslationLanguage` | `user.set_locale` | `locale` | `updated` |
62
+ | `dataGet` | `storage.get` | `slot` | `value` |
63
+ | `dataSet` | `storage.set` | `slot, value` | 无 |
64
+ | `dataDelete` | `storage.delete` | `slot` | 无 |
65
+ | `addBlacks` | `blacklist.add` | `blocked_users` | 无 |
66
+ | `deleteBlacks` | `blacklist.remove` | `blocked_users` | 无 |
67
+ | `getBlacks` | `blacklist.list` | 无 | `blocked_users` |
68
+
69
+ `getOnlineUsers`、`getBlacks` 的 SDK 回调 data 均为 `RTMConfig.Int64[]`,不是 Gate Answer map。
70
+
71
+ ## 群组
72
+
73
+ | SDK API | Gate URI | 请求字段 | Gate Answer |
74
+ | --- | --- | --- | --- |
75
+ | `addGroupMembers` | `group.add` | `group_ref, members` | 无 |
76
+ | `deleteGroupMembers` | `group.remove` | `group_ref, members` | 无 |
77
+ | `getGroupMembers` | `group.members` | `group_ref, with_online?` | `members, active_members?` |
78
+ | `getGroupCount` | `group.count` | `group_ref, with_online?` | `total, active_total?` |
79
+ | `getUserGroups` | `group.joined` | 无 | `group_refs` |
80
+ | `setGroupInfo` | `group.set_profile` | `group_ref, public_data?, private_data?` | 无 |
81
+ | `getGroupInfo` | `group.get_profile` | `group_ref` | `public_data, private_data` |
82
+ | `getGroupOpenInfo` | `group.get_public` | `group_ref` | `public_data` |
83
+ | `getGroupsOpenInfo` | `group.get_public_batch` | `group_refs` | `profiles` |
84
+
85
+ `getUserGroups` 的 SDK 回调 data 为 `RTMConfig.Int64[]`,不是 `{group_refs}`。
86
+
87
+ ## 房间
88
+
89
+ | SDK API | Gate URI | 请求字段 | Gate Answer |
90
+ | --- | --- | --- | --- |
91
+ | `enterRoom` | `room.join` | `room_ref` | 无 |
92
+ | `enterRooms` | `room.join_batch` | `room_refs` | 无 |
93
+ | `leaveRoom` | `room.leave` | `room_ref` | 无 |
94
+ | `getUserRooms` | `room.joined` | 无 | `room_refs` |
95
+ | `getRoomMembers` | `room.members` | `room_ref` | `members` |
96
+ | `getRoomCount` | `room.counts` | `room_refs` | `totals` |
97
+ | `setRoomInfo` / `setRoomProfile` | `room.set_profile` | `room_ref, public_data?, private_data?, label?, avatar?` | 无 |
98
+ | `getRoomInfo` | `room.get_profile` | `room_ref` | `public_data, private_data` |
99
+ | `getRoomOpenInfo` | `room.get_public` | `room_ref` | `public_data` |
100
+ | `getRoomsOpenInfo` | `room.get_public_batch` | `room_refs` | `profiles` |
101
+ | `getUserRoomsAndLastMessage` | `room.last_messages` | `kinds?` | `last_by_room` |
102
+
103
+ `last_by_room` 的 key 为十进制房间 ID,value 为 `tuple8`。
104
+ `getUserRooms` 的 SDK 回调 data 为 `RTMConfig.Int64[]`,不是 `{room_refs}`。
105
+
106
+ ## 消息发送、审核与翻译
107
+
108
+ | SDK API | Gate URI | 请求字段 | Gate Answer |
109
+ | --- | --- | --- | --- |
110
+ | `sendMessage` | `message.send` | `recipient, message_ref, kind, payload, extra, strategyid?, checkParams?` | `message_ref, time_ms` |
111
+ | `sendMessages` | `message.send_batch` | `recipients, message_ref, kind, payload, extra` | `message_ref, time_ms` |
112
+ | `sendGroupMessage` | `message.send_group` | `group_ref, message_ref, kind, payload, extra, strategyid?, checkParams?` | `message_ref, time_ms` |
113
+ | `sendRoomMessage` | `message.send_room` | `room_ref, message_ref, kind, payload, extra, strategyid?, checkParams?` | `message_ref, time_ms` |
114
+ | `textCheck` | `moderation.check` | `payload, strategyId?, checkParams?, zone?` | `decision, filtered, detected_locale, matches?` |
115
+ | `translate` | `translation.run` | `input, to_locale, from_locale?, format, filter_mode` | `detected_locale, resolved_locale, original, translated, from_locale, to_locale, input, output` |
116
+
117
+ `sendMessage`、`sendMessages`、`sendGroupMessage`、`sendRoomMessage` 的 SDK 成功回调为
118
+ `callback(null, {message_ref, payload: {message_ref, time_ms}})`;失败回调为
119
+ `callback({message_ref, error}, null)`。
120
+
121
+ ## 历史、单条消息与撤回
122
+
123
+ 历史分页字段:`reverse, limit, start_ms, end_ms, cursor, kinds?`;返回 `HistoryResult`:
124
+ `size, items, next, first_ms, last_ms`。`items` 的元素为 `tuple8`。
125
+
126
+ | SDK API | Gate URI | 额外请求字段 | Gate Answer |
127
+ | --- | --- | --- | --- |
128
+ | `getP2PMessage` | `history.direct` | `peer` | `HistoryResult` |
129
+ | `getGroupMessage` | `history.group` | `group_ref` | `HistoryResult` |
130
+ | `getRoomMessage` | `history.room` | `room_ref` | `HistoryResult` |
131
+ | `getBroadcastMessage` | `history.broadcast` | 无 | `HistoryResult` |
132
+ | `getP2PMessageByMessageId` | `history.direct_anchor` | `peer, anchor, reverse, limit, start_ms, end_ms, kinds?` | `HistoryResult` |
133
+ | `getGroupMessageByMessageId` | `history.group_anchor` | `group_ref, anchor, reverse, limit, start_ms, end_ms, kinds?` | `HistoryResult` |
134
+ | `getRoomMessageByMessageId` | `history.room_anchor` | `room_ref, anchor, reverse, limit, start_ms, end_ms, kinds?` | `HistoryResult` |
135
+ | `getBroadcastMessageByMessageId` | `history.broadcast_anchor` | `anchor, reverse, limit, start_ms, end_ms, kinds?` | `HistoryResult` |
136
+ | `getP2PMessageCount` | `history.direct_count` | `peer, start_ms, end_ms, kinds?` | `total` |
137
+ | `getGroupMessageCount` | `history.group_count` | `group_ref, start_ms, end_ms, kinds?` | `total` |
138
+ | `getRoomMessageCount` | `history.room_count` | `room_ref, start_ms, end_ms, kinds?` | `total` |
139
+ | `getBroadcastMessageCount` | `history.broadcast_count` | `start_ms, end_ms, kinds?` | `total` |
140
+ | `getMessage` | `message.get` | `sender, message_ref, target_ref, channel` | `sequence, message_ref, sender, kind, payload, extra, time_ms` |
141
+ | `deleteMessage` | `message.revoke` | `sender, message_ref, target_ref, channel` | 无 |
142
+
143
+ `getP2PChat`、`getGroupChat`、`getRoomChat`、`getBroadcastChat` 复用相应 history URI;
144
+ `getChat`、`deleteChat` 分别复用 `message.get`、`message.revoke`。
145
+
146
+ ## 未读、会话与会话列表
147
+
148
+ | SDK API | Gate URI | 请求字段 | Gate Answer |
149
+ | --- | --- | --- | --- |
150
+ | `getUnreadMessage` | `unread.summary` | `mark_read, with_logout?` | `peers, group_refs, logout_sec?` |
151
+ | `getSession` | `session.list` | 无 | `peers, group_refs` |
152
+ | `cleanUnreadMessage` | `unread.clear` | 无 | 无 |
153
+ | `setSessionRead` | `session.read` | `channel, target_ref, through` | 无 |
154
+ | `getP2PUnreadMessageNum` | `unread.direct` | `peers, since_ms?, kinds?` | `counts, times` |
155
+ | `getGroupUnreadMessageNum` | `unread.group` | `group_refs, since_ms?, kinds?` | `counts, times` |
156
+ | `removeSession` | `session.remove` | `peer, local_only` | 无 |
157
+ | `getP2PConversationList` | `conversation.direct` | `since_ms?, kinds?` | `peers, badges, last_items` |
158
+ | `getP2PUnreadConversationList` | `conversation.direct_unread` | `since_ms?, kinds?` | `peers, badges, last_items` |
159
+ | `getGroupConversationList` | `conversation.group` | `since_ms?, kinds?` | `group_refs, badges, last_items` |
160
+ | `getGroupUnreadConversationList` | `conversation.group_unread` | `since_ms?, kinds?` | `group_refs, badges, last_items` |
161
+ | `getUnreadConversationList` | `conversation.unread` | `mark_read, since_ms?, kinds?` | `group_refs, group_badges, group_last, peers, peer_badges, peer_last` |
162
+
163
+ ## 状态
164
+
165
+ | status | 接口含义 |
166
+ | ---: | --- |
167
+ | `10009` / `10010` | 字段缺失或类型不匹配。 |
168
+ | `200010` | 限流。 |
169
+ | `200020` | TLV 未开放能力。 |
170
+ | `200021` | 权限不足。 |
171
+ | `200022` | 未鉴权。 |
172
+ | `200023` | 重复鉴权。 |
173
+ | `200024` / `200027` | credential 拒绝或失效。 |
174
+ | `200030` | payload 或 extra 超限。 |
175
+ | `200032` / `200033` | 批量或空参数非法。 |
176
+ | `200034` | 契约字段、类型或范围非法。 |
177
+ | `200040` / `200041` | 房间或群组成员状态不满足。 |
178
+ | `200053` | `message_ref` 重复。 |
179
+ | `200070` | `anchor` 不存在。 |
180
+ | `200999` | 连接、超时或内部错误。 |
package/docs/USAGE.md ADDED
@@ -0,0 +1,168 @@
1
+ # RTC WebSocket SDK API
2
+
3
+ 本页定义公开 JavaScript API。TLV v1 的 URI、wire 字段和返回结构见
4
+ [TLV v1 Client 契约](TLV_CONTRACT.md)。
5
+
6
+ ## 通用约定
7
+
8
+ - 新接入使用 `protocol: 'tlv-v1'`。
9
+ - 除 `login` 外,回调为 `callback(err, data)`;`timeout` 单位为毫秒。
10
+ - `uid`、`gid`、`rid`、`mid`、游标和时间戳超出安全整数范围时使用 `RTMConfig.Int64`。
11
+ - `RTMConfig.TLV_SERVER_PUSH` 为 TLV Push 名称集合。
12
+
13
+ ## 构造参数
14
+
15
+ `new rtm.RTMClient(options)`
16
+
17
+ | 参数 | 类型 | 说明 |
18
+ | --- | --- | --- |
19
+ | `pid` | `number` | 必填。 |
20
+ | `protocol` | `'tlv-v1' \| 'fpnn'` | TLV 新接入为 `'tlv-v1'`。 |
21
+ | `tlvEndpoint` | `string` | TLV 必填完整 WebSocket URL。 |
22
+ | `autoReconnect` | `boolean` | 缺省 `true`。 |
23
+ | `connectionTimeout` | `number` | 连接超时。 |
24
+ | `requestTimeout` | `number` | 请求超时。 |
25
+ | `requestMetadata` / `requestMetadataProvider` | `() => Record<string, unknown>` | 可返回 `trace`、`sent_ms`。 |
26
+ | `webSocketFactory` | `(url: string) => RTMWebSocket` | 非浏览器运行时的 WebSocket 工厂。 |
27
+ | `authSec` / `authVer` | `number` | 自签鉴权参数;`authVer` 固定为 `2`。 |
28
+ | `locale` | `string` | 登录语言。 |
29
+ | `clientVersion` | `string` | 客户端版本。 |
30
+ | `attrs` | `Record<string, string>` | 连接属性。 |
31
+ | `tlvHeartbeatIdleMs` / `tlvHeartbeatTimeoutMs` | `number` | TLV 心跳参数。 |
32
+ | `pushDedupTtlMs` | `number` | 可靠 Push 去重窗口。 |
33
+ | `regressiveStrategy` | `RTMRegressiveStrategy` | 重连退避参数。 |
34
+
35
+ `RTMWebSocket` 必须提供 `send(data)`、`close(code?, reason?)`、`onopen`、`onmessage`、
36
+ `onerror`、`onclose`。
37
+
38
+ ## 生命周期与连接
39
+
40
+ | API | 回调 |
41
+ | --- | --- |
42
+ | `login(uid, credential, callback, timeout)` | `callback(accepted, errorCode)` |
43
+ | `bye()` | 无 |
44
+ | `close()` | 无 |
45
+ | `startAutoReconnect()` | 无 |
46
+ | `destroy()` | 无 |
47
+ | `getServerTime(timeout, callback)` | `callback(err, data)` |
48
+ | `addAttrs(attrs, timeout, callback)` | `callback(err, data)` |
49
+ | `getAttrs(timeout, callback)` | `callback(err, data)` |
50
+ | `addDebugLog(msg, attrs, timeout, callback)` | `callback(err, data)` |
51
+
52
+ 事件:`ErrorRecorder(error)`、`ReloginCompleted(successful, retryAgain, errorCode, retriedCount)`、
53
+ `SessionClosed(errorCode)`。
54
+
55
+ ## 用户、存储与黑名单
56
+
57
+ - `getOnlineUsers(uids, timeout, callback)`
58
+ - `setUserInfo(oinfo, pinfo, timeout, callback)`
59
+ - `getUserInfo(timeout, callback)`
60
+ - `getUserOpenInfo(uids, timeout, callback)`
61
+ - `setTranslationLanguage(targetLanguage, timeout, callback)`
62
+ - `dataSet(key, value, timeout, callback)`
63
+ - `dataGet(key, timeout, callback)`
64
+ - `dataDelete(key, timeout, callback)`
65
+ - `addBlacks(blacks, timeout, callback)`
66
+ - `deleteBlacks(blacks, timeout, callback)`
67
+ - `getBlacks(timeout, callback)`
68
+
69
+ ## 群组与房间
70
+
71
+ ### 群组
72
+
73
+ - `addGroupMembers(gid, uids, timeout, callback)`
74
+ - `deleteGroupMembers(gid, uids, timeout, callback)`
75
+ - `getGroupMembers(gid, online, timeout, callback)`
76
+ - `getGroupCount(gid, online, timeout, callback)`
77
+ - `getUserGroups(timeout, callback)`
78
+ - `setGroupInfo(gid, oinfo, pinfo, timeout, callback)`
79
+ - `getGroupInfo(gid, timeout, callback)`
80
+ - `getGroupOpenInfo(gid, timeout, callback)`
81
+ - `getGroupsOpenInfo(gids, timeout, callback)`
82
+
83
+ ### 房间
84
+
85
+ - `enterRoom(rid, timeout, callback)`
86
+ - `enterRooms(rids, timeout, callback)`
87
+ - `leaveRoom(rid, timeout, callback)`
88
+ - `getUserRooms(timeout, callback)`
89
+ - `getUserRoomsAndLastMessage(mtypes, timeout, callback)`
90
+ - `getRoomMembers(rid, timeout, callback)`
91
+ - `getRoomCount(rids, timeout, callback)`
92
+ - `setRoomInfo(rid, oinfo, pinfo, timeout, callback)`
93
+ - `setRoomProfile(rid, publicData, privateData, label, avatar, timeout, callback)`
94
+ - `getRoomInfo(rid, timeout, callback)`
95
+ - `getRoomOpenInfo(rid, timeout, callback)`
96
+ - `getRoomsOpenInfo(rids, timeout, callback)`
97
+
98
+ ## 消息
99
+
100
+ ### 发送
101
+
102
+ - `sendMessage(to, mtype, msg, attrs, mid, timeout, callback)`
103
+ - `sendMessages(tos, mtype, msg, attrs, mid, timeout, callback)`
104
+ - `sendGroupMessage(gid, mtype, msg, attrs, mid, timeout, callback)`
105
+ - `sendRoomMessage(rid, mtype, msg, attrs, mid, timeout, callback)`
106
+ - `sendChat(to, msg, attrs, mid, timeout, callback)`
107
+ - `sendAudio(to, msg, attrs, mid, timeout, callback)`
108
+ - `sendCmd(to, msg, attrs, mid, timeout, callback)`
109
+ - `sendGroupChat(gid, msg, attrs, mid, timeout, callback)`
110
+ - `sendGroupAudio(gid, msg, attrs, mid, timeout, callback)`
111
+ - `sendGroupCmd(gid, msg, attrs, mid, timeout, callback)`
112
+ - `sendRoomChat(rid, msg, attrs, mid, timeout, callback)`
113
+ - `sendRoomAudio(rid, msg, attrs, mid, timeout, callback)`
114
+ - `sendRoomCmd(rid, msg, attrs, mid, timeout, callback)`
115
+
116
+ 发送 API 的成功回调为 `callback(null, {message_ref, payload})`,其中 `payload` 为 Gate 的
117
+ `{message_ref, time_ms}`;失败回调为 `callback({message_ref, error}, null)`。
118
+
119
+ ### 查询、历史与撤回
120
+
121
+ - `getMessage(from, mid, xid, type, timeout, callback)`
122
+ - `deleteMessage(from, mid, xid, type, timeout, callback)`
123
+ - `getChat(from, mid, xid, type, timeout, callback)`
124
+ - `deleteChat(from, mid, xid, type, timeout, callback)`
125
+ - `getP2PMessage(ouid, desc, num, begin, end, lastid, mtypes, timeout, callback)`
126
+ - `getGroupMessage(gid, desc, num, begin, end, lastid, mtypes, timeout, callback)`
127
+ - `getRoomMessage(rid, desc, num, begin, end, lastid, mtypes, timeout, callback)`
128
+ - `getBroadcastMessage(desc, num, begin, end, lastid, mtypes, timeout, callback)`
129
+ - `getP2PMessageByMessageId(ouid, mid, desc, num, begin, end, mtypes, timeout, callback)`
130
+ - `getGroupMessageByMessageId(gid, mid, desc, num, begin, end, mtypes, timeout, callback)`
131
+ - `getRoomMessageByMessageId(rid, mid, desc, num, begin, end, mtypes, timeout, callback)`
132
+ - `getBroadcastMessageByMessageId(mid, desc, num, begin, end, mtypes, timeout, callback)`
133
+ - `getP2PMessageCount(ouid, begin, end, mtypes, timeout, callback)`
134
+ - `getGroupMessageCount(gid, begin, end, mtypes, timeout, callback)`
135
+ - `getRoomMessageCount(rid, begin, end, mtypes, timeout, callback)`
136
+ - `getBroadcastMessageCount(begin, end, mtypes, timeout, callback)`
137
+ - `getP2PChat(ouid, desc, num, begin, end, lastid, timeout, callback)`
138
+ - `getGroupChat(gid, desc, num, begin, end, lastid, timeout, callback)`
139
+ - `getRoomChat(rid, desc, num, begin, end, lastid, timeout, callback)`
140
+ - `getBroadcastChat(desc, num, begin, end, lastid, timeout, callback)`
141
+
142
+ ## 未读与会话
143
+
144
+ - `getUnreadMessage(clear, withLogout, timeout, callback)`
145
+ - `getP2PUnreadMessageNum(uids, mtime, mtypes, timeout, callback)`
146
+ - `getGroupUnreadMessageNum(gids, mtime, mtypes, timeout, callback)`
147
+ - `cleanUnreadMessage(timeout, callback)`
148
+ - `setSessionRead(category, xid, readSeq, timeout, callback)`
149
+ - `getSession(timeout, callback)`
150
+ - `removeSession(to, localOnly, timeout, callback)`
151
+ - `getP2PConversationList(mtime, mtypes, timeout, callback)`
152
+ - `getP2PUnreadConversationList(mtime, mtypes, timeout, callback)`
153
+ - `getGroupConversationList(mtime, mtypes, timeout, callback)`
154
+ - `getGroupUnreadConversationList(mtime, mtypes, timeout, callback)`
155
+ - `getUnreadConversationList(clear, mtime, mtypes, timeout, callback)`
156
+
157
+ ## 文本能力与 Push
158
+
159
+ - `textCheck(text, strategyId, timeout, callback)`
160
+ - `translate(originalMessage, originalLanguage, targetLanguage, type, profanity, timeout, callback)`
161
+ - `client.processor.on(RTMConfig.TLV_SERVER_PUSH.recvMessage, callback)`
162
+ - `client.processor.on(RTMConfig.TLV_SERVER_PUSH.recvGroupMessage, callback)`
163
+ - `client.processor.on(RTMConfig.TLV_SERVER_PUSH.recvRoomMessage, callback)`
164
+ - `client.processor.on(RTMConfig.TLV_SERVER_PUSH.recvBroadcastMessage, callback)`
165
+ - `client.processor.on(RTMConfig.TLV_SERVER_PUSH.kickOut, callback)`
166
+ - `client.processor.on(RTMConfig.TLV_SERVER_PUSH.kickOutRoom, callback)`
167
+
168
+ TLV 未开放 API 返回 `200020`:文件、好友、设备 Push 和未迁移增值能力。
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@cg-devcenter/rtc-fpnn-webjs-sdk",
3
+ "version": "1.0.0-cg.2",
4
+ "description": "Browser RTM SDK with FPNN and TLV v1 MessagePack WebSocket transports",
5
+ "main": "./dist/rtm.min.js",
6
+ "browser": "./dist/rtm.min.js",
7
+ "types": "./dist/rtm.d.ts",
8
+ "unpkg": "./dist/rtm.min.js",
9
+ "jsdelivr": "./dist/rtm.min.js",
10
+ "files": [
11
+ "dist",
12
+ "docs/TLV.md",
13
+ "docs/TLV_CONTRACT.md",
14
+ "docs/USAGE.md"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+ssh://git@gitlab.diandian.info/rtc/rtc-client-sdk-websocket.git"
19
+ },
20
+ "homepage": "https://gitlab.diandian.info/rtc/rtc-client-sdk-websocket",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/rtm.d.ts",
24
+ "require": "./dist/rtm.min.js",
25
+ "default": "./dist/rtm.min.js"
26
+ },
27
+ "./dist/*": "./dist/*",
28
+ "./package.json": "./package.json"
29
+ },
30
+ "author": "Dixun",
31
+ "license": "MIT",
32
+ "scripts": {
33
+ "build": "webpack --mode production",
34
+ "test": "npm run test:unit && npm run test:package",
35
+ "test:unit": "node test/tlv/run.js && node test/tlv/documentation.js",
36
+ "test:package": "npm run build && node test/package-smoke.js",
37
+ "prepack": "npm run build"
38
+ },
39
+ "devDependencies": {
40
+ "babel-core": "^6.26.3",
41
+ "babel-loader": "^7.1.5",
42
+ "babel-preset-env": "^1.7.0",
43
+ "babel-preset-es2015": "^6.24.1",
44
+ "babel-preset-stage-2": "^6.24.1",
45
+ "buffer": "^5.1.0",
46
+ "int64-buffer": "^0.1.10",
47
+ "webpack": "^4.1.1",
48
+ "webpack-cli": "^3.3.12"
49
+ }
50
+ }