@rongcloud/engine 5.6.2-beem.7 → 5.7.0-beem.1

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.
Files changed (4) hide show
  1. package/index.d.ts +1064 -1380
  2. package/index.esm.js +1 -1
  3. package/index.js +1 -1
  4. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -102,154 +102,6 @@ declare enum TagChangeType {
102
102
  delete = 3
103
103
  }
104
104
 
105
- /**
106
- * 通信协议中 fixHeader 第一个字节中的 Qos 数据标识
107
- * ```
108
- * fixHeader:command(4 bit) | dup(1 bit) | Qos(2 bit) | retain(1 bit)
109
- * ```
110
- */
111
- declare enum QOS {
112
- AT_MOST_ONCE = 0,
113
- AT_LEAST_ONCE = 1,
114
- EXACTLY_ONCE = 2,
115
- DEFAULT = 3
116
- }
117
- /**
118
- * 通信协议中 fixHeader 第一个字节中的 command 数据标识,用于判断操作类型
119
- * ```
120
- * fixHeader:command(4 bit) | dup(1 bit) | Qos(2 bit) | retain(1 bit)
121
- * ```
122
- */
123
- declare enum OperationType {
124
- /** 私有云专用,解密协商指令 */
125
- SYMMETRIC = 0,
126
- /** 连接请求 */
127
- CONNECT = 1,
128
- /** 连接应答 */
129
- CONN_ACK = 2,
130
- /** 上行发送消息 */
131
- PUBLISH = 3,
132
- /** 上行发送消息的应答 */
133
- PUB_ACK = 4,
134
- /** 上行拉消息 */
135
- QUERY = 5,
136
- /** 上行拉消息的应答 */
137
- QUERY_ACK = 6,
138
- /** QueryConfirm */
139
- QUERY_CONFIRM = 7,
140
- SUBSCRIBE = 8,
141
- SUB_ACK = 9,
142
- UNSUBSCRIBE = 10,
143
- UNSUB_ACK = 11,
144
- PING_REQ = 12,
145
- PING_RESP = 13,
146
- /** 连接挂断 */
147
- DISCONNECT = 14,
148
- RESERVER2 = 15
149
- }
150
- /**
151
- * connect 版本号,用于区分 ConnAckMessage 的解析规则
152
- */
153
- declare enum ConnAckProtocolVer {
154
- /**
155
- * V4 说明:
156
- * ```
157
- * 增加 flag 来标识每个位置是否有内容,如果没有 messageId 说明此 APP 没有配置防重放,默认取0
158
- * status | 4byte
159
- * flag | 1byte 每一位标识是否有对应值,由低到高
160
- * userId | 可变长
161
- * sessionId | 可变长
162
- * timestamp | 8byte
163
- * messageId | 4byte
164
- * onlineClientInfo | 可变长
165
- * ===
166
- * flag 描述:
167
- * | | | | 4 | 3 | 2 | 1 | 0 |
168
- * | | | | hasOnlineClientInfo | hasMessageId | hasTimeStamp | hasSessionId | hasUserId |
169
- * ```
170
- */
171
- V4 = 4,
172
- /**
173
- * V3 说明:
174
- * ```
175
- * status | 4byte
176
- * userId | 可变长
177
- * sessionId | 可变长
178
- * timestamp | 8byte
179
- * descyptionType | 1byte
180
- * secretKey | 可变长
181
- * onlineClientInfo | 可变长
182
- * ```
183
- */
184
- V3 = 3
185
- }
186
-
187
- /**
188
- * @todo 注释补全
189
- * @description
190
- * Header 处理
191
- */
192
- declare class Header {
193
- readonly type: OperationType;
194
- private readonly _retain;
195
- qos: QOS;
196
- private readonly _dup;
197
- readonly syncMsg: boolean;
198
- constructor(type: OperationType, retain?: boolean, qos?: QOS, dup?: boolean);
199
- encode(): number;
200
- }
201
- /**
202
- * @description
203
- * 融云读取二进制数据
204
- */
205
- declare class RongStreamReader {
206
- private _pool;
207
- private _position;
208
- private _poolLen;
209
- constructor(arr: Uint8Array);
210
- check(): boolean;
211
- /**
212
- * 读 2 位
213
- */
214
- read2Byte(): number;
215
- /**
216
- * 读 4 位
217
- */
218
- readInt(): number;
219
- /**
220
- * 读 8 位
221
- */
222
- readLong(): number;
223
- /**
224
- * 读 1 位
225
- */
226
- readByte(): number;
227
- /**
228
- * 获取数据
229
- */
230
- readUTF(): string;
231
- /**
232
- * 读剩余的所有值
233
- */
234
- readAll(): Uint8Array;
235
- }
236
- /**
237
- * @description
238
- * 融云写入二进制数据
239
- */
240
- declare class RongStreamWriter {
241
- private _pool;
242
- private _position;
243
- private _writen;
244
- /**
245
- * 写入缓存区, writen 值往后移
246
- */
247
- write(byte: number): number;
248
- writeArr(byte: Array<number>): number[];
249
- writeUTF(str: string): void;
250
- getBytesArray(): Array<number>;
251
- }
252
-
253
105
  /**
254
106
  * LogLevel 等级定义,与大数据服务器日志等级保持一致
255
107
  */
@@ -570,7 +422,7 @@ declare enum ErrorCode {
570
422
  */
571
423
  FORBIDDEN_IN_CHATROOM = 23408,
572
424
  /**
573
- * 聊天室中成员被踢出
425
+ * 当前用户被目标聊天室封禁
574
426
  */
575
427
  RC_CHATROOM_USER_KICKED = 23409,
576
428
  /**
@@ -663,9 +515,9 @@ declare enum ErrorCode {
663
515
  */
664
516
  RC_HTTP_RECV_FAIL = 30006,
665
517
  /**
666
- * 导航操作的 HTTP 请求,返回不是200。
518
+ * 导航请求失败
667
519
  */
668
- RC_NAVI_RESOURCE_ERROR = 30007,
520
+ RC_NAVI_REQ_FAILED = 30007,
669
521
  /**
670
522
  * 导航数据解析后,其中不存在有效数据。
671
523
  */
@@ -675,21 +527,17 @@ declare enum ErrorCode {
675
527
  */
676
528
  RC_DOMAIN_NOT_RESOLVE = 30009,
677
529
  /**
678
- * 创建 Socket 失败。
530
+ * Socket 连接失败
679
531
  */
680
532
  RC_SOCKET_NOT_CREATED = 30010,
681
533
  /**
682
- * Socket 被断开。
534
+ * Socket 连接断开
683
535
  */
684
536
  RC_SOCKET_DISCONNECTED = 30011,
685
537
  /**
686
- * PING 操作失败。
687
- */
688
- RC_PING_SEND_FAIL = 30012,
689
- /**
690
- * PING 超时。
538
+ * PING 连续失败次数超限制
691
539
  */
692
- RC_PONG_RECV_FAIL = 30013,
540
+ RC_PING_EXCEED_LIMIT = 30012,
693
541
  /**
694
542
  * 消息发送失败。
695
543
  */
@@ -699,27 +547,27 @@ declare enum ErrorCode {
699
547
  */
700
548
  RC_MSG_CONTENT_EXCEED_LIMIT = 30016,
701
549
  /**
702
- * connect 连接时,收到的 ACK 超时。
550
+ * TCP 连接中,CMP 应答超时。
703
551
  */
704
552
  RC_CONN_ACK_TIMEOUT = 31000,
705
553
  /**
706
- * 参数错误。
554
+ * 连接协议版本错误
707
555
  */
708
556
  RC_CONN_PROTO_VERSION_ERROR = 31001,
709
557
  /**
710
- * 参数错误,App Id 错误。
558
+ * 客户端连接用设备 info 信息错误
711
559
  */
712
- RC_CONN_ID_REJECT = 31002,
560
+ RC_CONN_IDENTIFIER_REJECTED = 31002,
713
561
  /**
714
- * 服务器不可用。
562
+ * 连接服务未开通,需要排查后台小程序(或桌面端)服务是否已开通
715
563
  */
716
564
  RC_CONN_SERVER_UNAVAILABLE = 31003,
717
565
  /**
718
- * Token 错误。
566
+ * Token 无法解析,或 Token 已过期
719
567
  */
720
- RC_CONN_USER_OR_PASSWD_ERROR = 31004,
568
+ RC_CONN_TOKEN_INCORRECT = 31004,
721
569
  /**
722
- * websocket 鉴权失败,通常为连接后未及时发送 Ping 或接收到 Pong
570
+ * 防黑产校验失败
723
571
  */
724
572
  RC_CONN_NOT_AUTHRORIZED = 31005,
725
573
  /**
@@ -727,31 +575,51 @@ declare enum ErrorCode {
727
575
  */
728
576
  RC_CONN_REDIRECTED = 31006,
729
577
  /**
730
- * NAME 与后台注册信息不一致。
578
+ * 包名不合法(目前仅限移动端使用)
731
579
  */
732
580
  RC_CONN_PACKAGE_NAME_INVALID = 31007,
733
581
  /**
734
- * APP 被屏蔽、删除或不存在。
582
+ * Appkey 已被封禁或删除
735
583
  */
736
584
  RC_CONN_APP_BLOCKED_OR_DELETED = 31008,
737
585
  /**
738
- * 用户被屏蔽。
586
+ * 用户已被封禁
739
587
  */
740
588
  RC_CONN_USER_BLOCKED = 31009,
741
589
  /**
742
- * Disconnect,由服务器返回,比如用户互踢。
590
+ * 其他端登录导致本端被踢
743
591
  */
744
592
  RC_DISCONN_KICK = 31010,
745
593
  /**
746
- * Disconnect,由服务器返回,比如用户互踢。
594
+ * 用户在线时被封禁导致连接断开
747
595
  */
748
596
  RC_DISCONN_EXCEPTION = 31011,
749
597
  /**
750
- * 开启禁止把已在线客户端踢下线开关后,该错误码标识已有同类型端在线,禁止链接;
598
+ * Token 已过期
599
+ */
600
+ RC_CONN_TOKEN_EXPIRED = 31020,
601
+ /**
602
+ * Token 中携带 deviceId 时,检测 Token 中 deviceId 与链接设备 deviceId 不一致
603
+ */
604
+ RC_CONN_DEVICE_ERROR = 31021,
605
+ /**
606
+ * 页面域名不在安全域名白名单内,需通过开发者后台添加安全域名配置
607
+ */
608
+ RC_CONN_HOSTNAME_ERROR = 31022,
609
+ /**
610
+ * 开启禁止把已在线客户端踢下线开关后,该错误码标识已有同类型端在线
751
611
  */
752
612
  RC_DISCONN_SAME_CLIENT_ON_LINE = 31023,
753
613
  /**
754
- * app 验证Token 验证不通过。所有内部超时,访问失败,返回给客户端sdk都是验证不通过,由服务端日志去看具体是那种失败。
614
+ * 连接数已达上限(私有云)
615
+ */
616
+ RC_LISCENSE_COUNT_OUT_OF_LIMIT = 31024,
617
+ /**
618
+ * 客户端连错环境,引发连接拒绝;如使用开发环境 Appkey 连接到生产环境
619
+ */
620
+ RC_CONN_WRONG_CLUSTER = 31025,
621
+ /**
622
+ * 开启 AppServer 联合鉴权功能后,到 AppServer 认证失败
755
623
  */
756
624
  RC_APP_AUTH_NOT_PASS = 31026,
757
625
  /**
@@ -759,16 +627,15 @@ declare enum ErrorCode {
759
627
  */
760
628
  RC_OTP_USED = 31027,
761
629
  /**
762
- * token平台验证失败
630
+ * Token 绑定的平台与登录平台不符
763
631
  */
764
632
  RC_PLATFORM_ERROR = 31028,
765
633
  /**
766
634
  * 用户账号已销户
767
- * @desc 请检查您使用的 Token 是否正确,以及对应的 UserId 是否被销户
768
635
  */
769
- RC_CONN_USER_LOGOUT = 31029,
636
+ RC_ACCOUNT_CANCELLATION = 31029,
770
637
  /**
771
- * 证书过期,SDK不会重连
638
+ * License 授权过期(私有云)
772
639
  */
773
640
  RC_LICENSE_EXPIRED = 31030,
774
641
  /**
@@ -779,6 +646,10 @@ declare enum ErrorCode {
779
646
  * 协议层内部错误。
780
647
  */
781
648
  RC_MSG_DATA_INCOMPLETE = 32002,
649
+ /**
650
+ * TCP 连接重置
651
+ */
652
+ RC_TCP_RESET = 32054,
782
653
  /**
783
654
  * 未调用 init 初始化函数。
784
655
  */
@@ -888,7 +759,7 @@ declare enum ErrorCode {
888
759
  */
889
760
  CAN_NOT_RECONNECT = 35007,
890
761
  /**
891
- * 不支持的平台类型,一般小程序或 PC 未开通
762
+ * 无可用的 IM 服务地址
892
763
  */
893
764
  SERVER_UNAVAILABLE = 35008,
894
765
  /**
@@ -1058,11 +929,34 @@ declare enum ErrorCode {
1058
929
  * 聊天室设置批量kv,一次不能超过10个
1059
930
  */
1060
931
  CHATROOM_KV_STORE_OUT_LIMIT = 23429,
1061
- SEARCH_PROPS_LIMIT_ERROR = 35022
932
+ SEARCH_PROPS_LIMIT_ERROR = 35022,
933
+ /**
934
+ * 非法的代理配置,RongIMProxy 为空或者非法
935
+ */
936
+ INVALID_PARAMETER_PROXY = 34238,
937
+ /**
938
+ * 代理测试服务地址为空或者非法
939
+ */
940
+ INVALID_PARAMETER_TESTHOST = 34239,
941
+ /**
942
+ * 开发者接口调用 testProxy 接口时无法联通
943
+ */
944
+ INVALID_CONNECT_TESTHOST_FAILED = 34240,
945
+ /**
946
+ * 开发者调用 connect 时 proxy 服务设置失败
947
+ * 移动端使用的为 31028,但web 端此状态码已经被占用,所以改为 web 端使用号码段 35XXX
948
+ * @discussion 设置 setProxy 接口不可在连接或正在连接中的状态调用。
949
+ */
950
+ RC_CONN_PROXY_UNAVAILABLE = 35028,
951
+ /**
952
+ * proxy 服务不可用
953
+ */
954
+ PROXY_UNAVAILABLE = 17
1062
955
  }
1063
956
 
1064
957
  /**
1065
958
  * 连接状态
959
+ * @deprecated 请使用 `RCConnectionStatus` 替代此枚举声明
1066
960
  */
1067
961
  declare enum ConnectionStatus {
1068
962
  /**
@@ -1148,7 +1042,11 @@ declare enum ConnectionStatus {
1148
1042
  /**
1149
1043
  * 证书过期,SDK不会重连
1150
1044
  */
1151
- RC_LICENSE_EXPIRED = 31030
1045
+ RC_LICENSE_EXPIRED = 31030,
1046
+ /**
1047
+ * Token 错误。
1048
+ */
1049
+ RC_CONN_USER_OR_PASSWD_ERROR = 31004
1152
1050
  }
1153
1051
 
1154
1052
  /**
@@ -1178,92 +1076,6 @@ declare enum ReceivedStatus {
1178
1076
  UNREAD = 0
1179
1077
  }
1180
1078
 
1181
- /**
1182
- * CMP/Comet 服务连接应答码
1183
- */
1184
- declare const ConnectResultCode: {
1185
- /**
1186
- * 连接成功
1187
- */
1188
- ACCEPTED: number;
1189
- /**
1190
- * 协议版本不匹配
1191
- * @description 暂未使用
1192
- */
1193
- UNACCEPTABLE_PROTOCOL_VERSION: number;
1194
- /**
1195
- * 客户端(移动端 TCP 连接建立时)`info` 字段格式错误
1196
- * @description 格式:`{平台类型}-{设备信息}-{sdk版本}`。
1197
- * 其中设备信息为:{手机类型}{手机型号}{网络类型,4G/WIFI}{运营商标识, 移动/电信/联通}
1198
- */
1199
- IDENTIFIER_REJECTED: number;
1200
- /**
1201
- * 不支持的平台类型,一般小程序或 PC 未开通
1202
- */
1203
- SERVER_UNAVAILABLE: number;
1204
- /**
1205
- * Token无法解析,或Token已过期
1206
- */
1207
- TOKEN_INCORRECT: number;
1208
- /**
1209
- * 防黑产规则相关应答
1210
- */
1211
- NOT_AUTHORIZED: number;
1212
- /**
1213
- * 服务重定向,一般服务扩缩容时,落点已经改变,此时 userId 链接到旧的节点时,会触发该错误。
1214
- * 客户端收到该应答后须重新访问导航,重新获取 CMP 地址
1215
- */
1216
- REDIRECT: number;
1217
- /**
1218
- * 暂未使用
1219
- */
1220
- PACKAGE_ERROR: number;
1221
- /**
1222
- * 该 AppKey 已经封禁或删除
1223
- */
1224
- APP_BLOCK_OR_DELETE: number;
1225
- /**
1226
- * 该用户 ID 已经被封禁
1227
- */
1228
- BLOCK: number;
1229
- /**
1230
- * Token 已过期,暂未使用
1231
- */
1232
- TOKEN_EXPIRE: number;
1233
- /**
1234
- * Token 中携带 deviceId 时,检测 Token 中 deviceId 与链接设备 deviceId 不一致
1235
- */
1236
- DEVICE_ERROR: number;
1237
- /**
1238
- * Web 端设置安全域名后,连接端域名不在安全域名范围内
1239
- */
1240
- HOSTNAME_ERROR: number;
1241
- /**
1242
- * 开启`禁止把已在线客户端踢下线`开关后,该错误码标识已有同类型端在线,禁止链接
1243
- */
1244
- HASOHTERSAMECLIENTONLINE: number;
1245
- /**
1246
- * 客户端连错环境,引发连接拒绝
1247
- */
1248
- IN_OTHER_CLUSTER: number;
1249
- /**
1250
- * app 验证Token 验证不通过。所有内部超时,访问失败,返回给客户端sdk都是验证不通过,由服务端日志去看具体是那种失败。
1251
- */
1252
- APP_AUTH_NOT_PASS: number;
1253
- /**
1254
- * One Time Password 已经被使用过
1255
- */
1256
- OTP_USED: number;
1257
- /**
1258
- * token平台验证失败
1259
- */
1260
- PLATFORM_ERROR: number;
1261
- /**
1262
- * 用户账号已销户,不再进行连接
1263
- */
1264
- USER_LOGOUT: number;
1265
- };
1266
-
1267
1079
  /**
1268
1080
  * 内置消息类型
1269
1081
  */
@@ -1328,6 +1140,14 @@ declare enum MessageType {
1328
1140
  * 撤回消息
1329
1141
  */
1330
1142
  RECALL = "RC:RcCmd",
1143
+ /**
1144
+ * 撤回通知消息
1145
+ *
1146
+ * 融云定义了 ObjectName 为 `RC:RcNtf` 的撤回通知消息
1147
+ *
1148
+ * PC: recallMessage 会替换聊天记录中的原始消息为一条 objectName 为 `RC:RcNtf` 的撤回通知消息
1149
+ */
1150
+ RECALL_NOTIFICATION_MESSAGE = "RC:RcNtf",
1331
1151
  /**
1332
1152
  * 已读同步状态消息
1333
1153
  */
@@ -1515,6 +1335,7 @@ declare enum LogTagId {
1515
1335
  L_DESTROY_O = "L_DESTROY_O",
1516
1336
  A_CONNECT_T = "A-connect-T",
1517
1337
  A_CONNECT_R = "A-connect-R",
1338
+ A_CONNECT_S = "A-connect-S",
1518
1339
  A_DISCONNECT_O = "A-disconnect-O",
1519
1340
  A_RECONNECT_T = "A-reconnect-T",
1520
1341
  A_RECONNECT_R = "A_RECONNECT_R",
@@ -1570,6 +1391,8 @@ declare enum LogTagId {
1570
1391
  P_REGTYP_E = "P-regtype-E",
1571
1392
  L_GET_NAVI_T = "L-get_navi-T",
1572
1393
  L_GET_NAVI_R = "L-get_navi-R",
1394
+ L_GET_NAVI_O = "L-get_navi-O",
1395
+ L_PARSE_NAVI_E = "L-parse_navi-E",
1573
1396
  L_ENV_S = "L-Env-S",
1574
1397
  L_GET_INDEX_NAVI_S = "L-get_index_navi-S",
1575
1398
  A_JOIN_CHATROOM_T = "A-join_chatroom-T",
@@ -1580,6 +1403,7 @@ declare enum LogTagId {
1580
1403
  A_QUIT_CHATROOM_R = "A-quit_chatroom-R",
1581
1404
  L_REJOIN_CHATROOM_T = "L-rejoin_chatroom-T",
1582
1405
  L_REJOIN_CHATROOM_R = "L-rejoin_chatroom-R",
1406
+ L_REJOIN_CHATROOM_S = "L-rejoin_chatroom-S",
1583
1407
  L_MEDIA_S = "L-media-S",
1584
1408
  L_MEDIA_UPLOAD_T = "L-media_upload-T",
1585
1409
  L_MEDIA_UPLOAD_R = "L-media_upload-R",
@@ -1589,13 +1413,17 @@ declare enum LogTagId {
1589
1413
  G_GET_REAL_TIMELOG_COMMAND_S = "G-get_real_timelog_command-S",
1590
1414
  L_CHECK_ALIVE_IM_T = "L-check_alive_im-T",
1591
1415
  L_CHECK_ALIVE_IM_R = "L-check_alive_im-R",
1416
+ L_CHECK_ALIVE_IM_S = "L-check_alive_im-S",
1592
1417
  A_GET_HISTORY_MSG_T = "A-get_history_msg-T",
1593
1418
  A_GET_HISTORY_MSG_R = "A-get_history_msg-R",
1594
1419
  L_GET_HISTORY_MSG_T = "L-get_history_msg-T",
1595
1420
  L_GET_HISTORY_MSG_R = "L-get_history_msg-R",
1421
+ A_GET_PRIVATE_MESSAGE_DELIVER_TIME_E = "A-get_privage_message_deliver_time-E",
1422
+ A_GET_GROUP_MESSAGE_DELIVER_LIST_E = "A-get_group_message_deliver_list-E",
1596
1423
  A_CALLBACK_O = "A-callback-O",
1597
1424
  A_CALLBACK_E = "A-callback-E",
1598
1425
  L_CALLBACK_E = "L-callback-E",
1426
+ A_GET_TOP_CONVERSATION_LIST_E = "A-get_top_conversation_list-E",
1599
1427
  /**
1600
1428
  * PB 数据编码错误
1601
1429
  */
@@ -1621,6 +1449,7 @@ declare enum LogTagId {
1621
1449
  L_UNKNOWN_TOPIC_E = "L_UNKNOWN_TOPIC_E",
1622
1450
  L_RECV_RMTP_O = "L_RECV_RMTP_O",
1623
1451
  L_RECV_RMTP_E = "L_RECV_RMTP_E",
1452
+ L_RECV_S_NTF_O = "L-recv_s_ntf_O",
1624
1453
  /** 版本号上报 */
1625
1454
  L_VER_REPORT_T = "L-VER_REPORT-T",
1626
1455
  /** 版本号上报结果 */
@@ -1629,7 +1458,10 @@ declare enum LogTagId {
1629
1458
  L_CALL_MAIN_SYNC_O = "L_CALL_MAIN_SYNC_O",
1630
1459
  /** 未知的通知 */
1631
1460
  L_UNSUPPORT_NTF_FROM_MAIN_E = "L_UNSUPPORT_NTF_FROM_MAIN_E",
1632
- A_SET_MSG_CONTENT_O = "A_SET_MSG_CONTENT_O"
1461
+ A_SET_MSG_CONTENT_O = "A_SET_MSG_CONTENT_O",
1462
+ A_REMOVE_PROXY_O = "A-remove_proxy-O",
1463
+ A_SET_PROXY_O = "A-set_proxy-O",
1464
+ A_TEST_PROXY_O = "A-test_proxy-O"
1633
1465
  }
1634
1466
 
1635
1467
  /**
@@ -2432,6 +2264,13 @@ interface IUltraUnreadMsg {
2432
2264
  mentionedType?: number;
2433
2265
  }
2434
2266
 
2267
+ interface IMentionInfo {
2268
+ type: MentionedType;
2269
+ /**
2270
+ * 被 @ 的用户 Id 列表,仅在 `type` 为 `2` 时有效
2271
+ */
2272
+ userIdList: string[];
2273
+ }
2435
2274
  /**
2436
2275
  * 从服务器拉取到的会话数据结构
2437
2276
  * @category Interface
@@ -2467,16 +2306,7 @@ interface IReceivedConversation {
2467
2306
  /**
2468
2307
  * 消息中的 @ 数据,仅在 `conversationType` 为 `ConversationType.GROUP` 时有效
2469
2308
  */
2470
- mentionedInfo?: {
2471
- /**
2472
- * `@ 类型,其中 1 为 @ 所有人,2 为 @ 部分人`
2473
- */
2474
- type: 1 | 2;
2475
- /**
2476
- * 被 @ 的用户 Id 列表,仅在 `type` 为 `2` 时有效
2477
- */
2478
- userIdList: string[];
2479
- } | null;
2309
+ mentionedInfo?: IMentionInfo | null;
2480
2310
  /**
2481
2311
  * 会话免打扰状态
2482
2312
  * @description
@@ -2630,742 +2460,855 @@ interface IUltraUnreadConversation {
2630
2460
  }
2631
2461
 
2632
2462
  /**
2633
- * 导航信息数据就结构
2463
+ * @category Interface
2634
2464
  */
2635
- interface INaviInfo {
2465
+ interface IChatroomEntryListenerData {
2636
2466
  /**
2637
- * Navi 数据请求响应码,200 为成功请求
2638
- */
2639
- code: number;
2467
+ * 更新的键
2468
+ */
2469
+ key: string;
2640
2470
  /**
2641
- * 获取 Navi 数据失败时的提示信息
2642
- */
2643
- errorMessage?: string;
2471
+ * 更新的值
2472
+ */
2473
+ value: string;
2644
2474
  /**
2645
- * 获取 Navi 数据失败时的请求 url 信息
2646
- */
2647
- url?: string;
2475
+ * 更新的时间
2476
+ */
2477
+ timestamp: number;
2648
2478
  /**
2649
- * 请求导航数据时使用的协议:http / https
2650
- * @description 该字段为 SDK 内增加的字段,导航接口数据中不存在
2651
- */
2652
- protocol: 'http' | 'https';
2479
+ * 更新的聊天室 ID
2480
+ */
2481
+ chatroomId: string;
2653
2482
  /**
2654
- * 获取导航时使用的 userId,小程序不走导航,故拿不到 userId
2655
- */
2656
- userId?: string;
2483
+ * 更新类型
2484
+ */
2485
+ type: ChatroomEntryType;
2486
+ }
2487
+ /**
2488
+ * @category Interface
2489
+ */
2490
+ interface IChatroomRejoinedFailed {
2657
2491
  /**
2658
- * CMP 服务 Websocket 连接地址,包含域名与端口,不含 ws 或 wss 协议头
2659
- * @example a.domain.com:443
2492
+ * 自动重新加入的聊天室 ID
2493
+ */
2494
+ chatroomId: string;
2495
+ /**
2496
+ * 自动重新加入失败的 code
2497
+ */
2498
+ errorCode: number;
2499
+ }
2500
+ /**
2501
+ * @category Interface
2502
+ */
2503
+ interface IChatroomRejoinedSuccessed {
2504
+ /**
2505
+ * 自动重新加入的聊天室 ID
2506
+ */
2507
+ chatroomId: string;
2508
+ /**
2509
+ * 自动重新加入的聊天室拉取消息的数量
2510
+ */
2511
+ count: number;
2512
+ }
2513
+ /**
2514
+ * @category Interface
2515
+ */
2516
+ interface IChatroomUserChangeInfo {
2517
+ users: {
2518
+ [userId: string]: ChatroomUserChangeType;
2519
+ };
2520
+ chatroomId: string;
2521
+ }
2522
+ declare type IChatroomRejoinedInfo = IChatroomRejoinedFailed | IChatroomRejoinedSuccessed;
2523
+ /**
2524
+ * 聊天室信息
2525
+ * @category Interface
2526
+ */
2527
+ interface IChatroomListenerData {
2528
+ /**
2529
+ * SDK 内部重连聊天室信息
2530
+ */
2531
+ rejoinedRoom?: IChatroomRejoinedInfo;
2532
+ /**
2533
+ * 监听到的聊天室 KV 更新
2534
+ */
2535
+ updatedEntries?: IChatroomEntryListenerData[];
2536
+ /**
2537
+ * 登录退出的用户通知
2660
2538
  */
2661
- server: string;
2539
+ userChange?: IChatroomUserChangeInfo;
2662
2540
  /**
2663
- * 备用 CMP 服务地址,包含域名与端口,不含 ws 或 wss 协议头,多个备用地址以 ',' 分割
2664
- * @example a.domain.com:443,b.domain.com:443
2541
+ * 聊天室销毁
2665
2542
  */
2666
- backupServer?: string;
2543
+ chatroomDestroyed?: string;
2544
+ }
2545
+ /**
2546
+ * @category Interface
2547
+ */
2548
+ interface IChatroomEntry {
2667
2549
  /**
2668
- * 备用 CMP 服务地址,POST 请求 TCP 连接返回的是 bs 字段,非 backupServer 字段
2550
+ * 属性名称, 支持英文字母、数字、+、=、-、_ 的组合方式, 最大长度 128 字符
2669
2551
  */
2670
- bs?: string;
2552
+ key: string;
2671
2553
  /**
2672
- * RTC 服务配置,其值可能为 null、无效字符串、有效 JSON 字符串
2673
- * 1. 公有云未开通音视频时,值为 null
2674
- * 2. 私有云无配置时为 `{ "strategy": 0 }`
2554
+ * 属性对应的值, 最大长度 4096 字符
2675
2555
  */
2676
- voipCallInfo: string | null;
2556
+ value: string;
2677
2557
  /**
2678
- * 聊天室 kv 存储开关
2679
- * @todo 需确认详细有效值
2680
- * @description 公有云独有配置
2558
+ * 设置成功后是否发送通知消息
2681
2559
  */
2682
- kvStorage: number;
2560
+ isSendNotification?: boolean;
2683
2561
  /**
2684
- * HttpDNS 功能开关,在 web 端无效
2685
- * @description 公有云独有配置
2562
+ * RC:chrmKVNotiMsg 消息中携带的附加信息
2686
2563
  */
2687
- openHttpDNS: boolean;
2564
+ notificationExtra?: string;
2688
2565
  /**
2689
- * 历史消息云存储功能开关
2690
- * @description
2691
- * 1. 公有云通过 `developer.rongcloud.cn` 管理后台 `单群聊消息云端存储` 功能开关进行配置
2692
- * 2. 私有云默认为 `true`
2566
+ * 用户退出聊天室时是否清除此属性
2693
2567
  */
2694
- historyMsg: boolean;
2568
+ isAutoDelete?: boolean;
2569
+ }
2570
+ /**
2571
+ * @category Interface
2572
+ */
2573
+ interface IChatroomUser {
2695
2574
  /**
2696
- * 聊天室历史消息开关
2697
- * @description
2698
- * 1. 私有云对聊天室功能支持有限,默认为 `false`
2699
- * 2. TODO: 公有云配置待确认
2575
+ * 用户 id
2700
2576
  */
2701
- chatroomMsg: boolean;
2577
+ id: string;
2702
2578
  /**
2703
- * 文件服务器地址
2704
- * @description
2705
- * 1. 公有云下,该地址为七牛云服务器地址
2706
- * 2. 私有云下,该地址为私有云自研文件服务器地址
2579
+ * 加入聊天室的时间
2707
2580
  */
2708
- uploadServer: string;
2581
+ time: number;
2582
+ }
2583
+ /**
2584
+ * @category Interface
2585
+ */
2586
+ interface IChatroomInfo {
2709
2587
  /**
2710
- * 实时位置共享配置,web 端无需处理
2588
+ * 成员列表
2589
+ * @todo 需确认数组元素的数据结构
2711
2590
  */
2712
- location: null | string;
2591
+ userInfos: IChatroomUser[];
2713
2592
  /**
2714
- * 实时日志上传开关
2715
- * @todo 需确认有效值及作用
2593
+ * 房间内总人数
2716
2594
  */
2717
- monitor: number;
2595
+ userCount: number;
2596
+ }
2597
+ /**
2598
+ * @category Interface
2599
+ */
2600
+ interface IRemoveChatroomEntry {
2718
2601
  /**
2719
- * 是否允许加入多聊天室开关
2602
+ * 属性名称, 支持英文字母、数字、+、=、-、_ 的组合方式, 最大长度 128 字符
2720
2603
  */
2721
- joinMChrm: boolean;
2604
+ key: string;
2722
2605
  /**
2723
- * 是否开启公众号功能:`0` 为未开启,`1` 为已开启
2606
+ * 删除成功后是否发送通知消息
2724
2607
  */
2725
- openMp: 0 | 1;
2608
+ isSendNotification?: boolean;
2726
2609
  /**
2727
- * 是否开启用户级配置,若开启,需连接成功后立即拉取实时配置,0 | 1
2728
- * @description
2729
- * 配置来源:
2730
- * 1. 导航
2731
- * 2. 服务端实时下发
2732
- * 已有配置字段:
2733
- * 1. Lan. 推送使用的语言设置,用户端可自定义修改. Web 端未做设置, 只做接收
2734
- * 2. ShPushSwit. 推送是否显示详情设置,用户端可自定义修改. Web 端未做设置, 只做接收
2735
- * 3. MobPushSwit: Web/PC 在线,移动端不在线是否发送推送开关,用户端可自定义修改. Web 端未做设置, 只做接收
2736
- * 4. OffMsgDur: 离线消息保存天数,设置天数不可大于App级对应配置,用户端可自定义修改. Web 端未做设置, 只做接收
2737
- * 5. VoipInfo: 音视频相关配置,用户端不可自定义修改. 由服务端决定,与导航下发格式一致
2738
- * @todo 需确认公有云与私有云区别
2610
+ * RC:chrmKVNotiMsg 消息中携带的附加信息
2739
2611
  */
2740
- openUS: 0 | 1;
2612
+ notificationExtra?: string;
2613
+ }
2614
+ /**
2615
+ * @category Interface
2616
+ */
2617
+ interface IRemoveChatroomEntries {
2741
2618
  /**
2742
- * 超级群功能开关,1表示开
2619
+ * key 属性名称, 支持英文字母、数字、+、=、-、_ 的组合方式, 最大长度 128 字符
2743
2620
  */
2744
- ugMsg?: 0 | 1;
2621
+ entries: {
2622
+ key: string;
2623
+ }[];
2745
2624
  /**
2746
- * 群离线消息最大下发条数,`0` 为关闭
2747
- * @description 公有云独有配合
2625
+ * 删除成功后是否发送通知消息
2748
2626
  */
2749
- grpMsgLimit: number;
2750
2627
  /**
2751
- * 消息加密开关,0 为关闭
2752
- * @todo
2753
- * 1. 确定其控制的功能
2754
- * 2. 确定 web 相关性
2628
+ * RC:chrmKVNotiMsg 消息中携带的附加信息
2755
2629
  */
2756
- isFormatted: number;
2630
+ notificationExtra?: string;
2631
+ }
2632
+ /**
2633
+ * @category Interface
2634
+ */
2635
+ interface IChatroomEntries {
2757
2636
  /**
2758
- * GIF 动图大小限制,默认 2048 KB
2637
+ * entries ,要设置的属性列表
2638
+ * key 属性名称, 支持英文字母、数字、+、=、-、_ 的组合方式, 最大长度 128 字符
2639
+ * value 属性对应的值, 最大长度 4096 字符
2759
2640
  */
2760
- gifSize: number;
2641
+ entries: {
2642
+ key: string;
2643
+ value: string;
2644
+ }[];
2761
2645
  /**
2762
- * 上传小视频时长限制,单位:秒
2763
- * @description 公有云字段,即私有云配置中的 `uploadVideoTimeLimit`
2646
+ * 设置成功后是否发送通知消息
2764
2647
  */
2765
- videoTimes?: number;
2766
2648
  /**
2767
- * 上传小视频时长限制,单位:秒
2768
- * @description 私有云字段,即公有云配置中的 `videoTimes`
2649
+ * RC:chrmKVNotiMsg 消息中携带的附加信息
2769
2650
  */
2770
- uploadVideoTimeLimit?: number;
2651
+ notificationExtra?: string;
2771
2652
  /**
2772
- * 实时日志上传开关:`0` 为关闭,`1` 为开启
2653
+ * 用户退出聊天室时是否清除此属性
2773
2654
  */
2774
- logSwitch: number;
2655
+ isAutoDelete?: boolean;
2775
2656
  /**
2776
- * 实时日志上传策略,值为 JSON 字符串
2777
- * @example `'{
2778
- * "url": "logcollection.ronghub.com", // 上传地址
2779
- * "level": 1, // 日志等级
2780
- * "itv": 6, // 上传频率,即时间间隔,单位 s
2781
- * "times": 5 // 重试次数?
2782
- * }'`
2657
+ * 是否强制覆盖
2783
2658
  */
2784
- logPolicy: string;
2659
+ isForce?: boolean;
2660
+ }
2661
+
2662
+ /**
2663
+ * @category Interface
2664
+ */
2665
+ interface IUploadAuth {
2785
2666
  /**
2786
- * 百度 BOS 存储服务地址
2787
- * @description 公有云独有配置
2788
- * @example `gz.bcebos.com`
2789
- */
2790
- bosAddr?: string;
2667
+ * 七牛 token 有效期
2668
+ */
2669
+ deadline: number;
2791
2670
  /**
2792
- * 阿里上传配置,字符串数组,数组顺序代表 七牛、百度、阿里云 上传权重
2793
- * @example
2794
- * ```
2795
- * `[{"qiniu":"upload.qiniup.com","p":"1"},
2796
- * {"baidu":"gz.bcebos.com","p":"2"},
2797
- * {"aliyun":"oss-cn-beijing.aliyuncs.com","p":"3"}]`
2798
- * ```
2671
+ * 七牛上传 token
2672
+ */
2673
+ token: string;
2674
+ /**
2675
+ * 百度上传 token
2676
+ */
2677
+ bosToken: string;
2678
+ /**
2679
+ * 百度上传 header Date
2680
+ */
2681
+ bosDate: string;
2682
+ /**
2683
+ * 百度上传路径
2684
+ */
2685
+ path: string;
2686
+ /**
2687
+ * 上传文件名,阿里上传获取下载地址时,必须使用上传文件名,所以需抛出到业务端
2799
2688
  */
2800
- ossConfig?: string;
2689
+ fileName: string;
2801
2690
  /**
2802
- * 私有云专有属性,可用来判断当前环境是公有云还是私有云,私有云环境下该值为 `1`
2691
+ * 阿里云 oss 的 AccessKeyId
2803
2692
  */
2804
- type?: number;
2693
+ osskeyId: string;
2805
2694
  /**
2806
- * @deprecated 已废弃
2695
+ * 阿里云 oss post 请求表单域中的字段 policy
2807
2696
  */
2808
- compDays: number;
2697
+ ossPolicy: string;
2809
2698
  /**
2810
- * @deprecated 已废弃
2699
+ * 阿里云 oss 根据 policy 计算的签名信息
2811
2700
  */
2812
- msgAck: unknown;
2701
+ ossSign: string;
2813
2702
  /**
2814
- * @deprecated 已废弃
2703
+ * 阿里云 oss 存储空间名称
2815
2704
  */
2816
- activeServer: string;
2705
+ ossBucketName: string;
2817
2706
  /**
2818
- * @deprecated 已废弃
2707
+ * s3 认证凭证,对应 post上传 x-amz-credential 字段
2819
2708
  */
2820
- qnAddr: string;
2709
+ s3Credential: string;
2821
2710
  /**
2822
- * @deprecated 已废弃
2711
+ * 加密算法,对应 post上传 x-amz-algorithm 字段
2823
2712
  */
2824
- extkitSwitch: number;
2713
+ s3Algorithm: string;
2825
2714
  /**
2826
- * @deprecated 已废弃
2715
+ * s3 日期,对应 post上传 x-amz-date 字段
2827
2716
  */
2828
- alone: boolean;
2717
+ s3Date: string;
2829
2718
  /**
2830
- * @deprecated 已废弃
2719
+ * s3 policy,对应 post上传 policy 字段
2831
2720
  */
2832
- voipServer: string;
2721
+ s3Policy: string;
2833
2722
  /**
2834
- * 离线日志上报地址
2835
- * @deprecated 已废弃
2723
+ * s3 签名信息,对应 post上传 x-amz-signature 字段
2836
2724
  */
2837
- offlinelogserver: string;
2725
+ s3Signature: string;
2838
2726
  /**
2839
- * 在线日志上报地址
2840
- * @deprecated 已废弃
2727
+ * s3 存储空间名称
2841
2728
  */
2842
- onlinelogserver?: string;
2729
+ s3BucketName: string;
2843
2730
  /**
2844
- * 链路加密字段,内容为 JSON 字符串,仅限 C++ 可用
2731
+ * stc Authorization
2845
2732
  */
2846
- crypto?: string;
2733
+ stcAuthorization: string;
2847
2734
  /**
2848
- * 群组回执开关, 1: 打开,0(或者没有): 关闭
2735
+ * stc xAmzContentSha256
2849
2736
  */
2850
- grpRRVer?: number;
2737
+ stcContentSha256: string;
2851
2738
  /**
2852
- * 防黑产开关, 1: 打开,0:关闭
2739
+ * stc date
2853
2740
  */
2854
- openAnti?: number;
2741
+ stcDate: string;
2855
2742
  /**
2856
- * 鉴权认证
2743
+ * stc 存储空间名称
2857
2744
  */
2858
- jwt?: string;
2745
+ stcBucketName: string;
2859
2746
  }
2860
2747
 
2861
- /**
2862
- * @category Interface
2863
- */
2864
- interface IChatroomEntryListenerData {
2865
- /**
2866
- * 更新的键
2867
- */
2868
- key: string;
2869
- /**
2870
- * 更新的值
2871
- */
2872
- value: string;
2873
- /**
2874
- * 更新的时间
2875
- */
2876
- timestamp: number;
2877
- /**
2878
- * 更新的聊天室 ID
2879
- */
2880
- chatroomId: string;
2881
- /**
2882
- * 更新类型
2883
- */
2884
- type: ChatroomEntryType;
2748
+ interface IRTCRoomInfo {
2749
+ roomId: string;
2750
+ roomData: unknown[];
2751
+ userCount: number;
2752
+ list: unknown[];
2885
2753
  }
2886
- /**
2887
- * @category Interface
2888
- */
2889
- interface IChatroomRejoinedFailed {
2890
- /**
2891
- * 自动重新加入的聊天室 ID
2892
- */
2893
- chatroomId: string;
2894
- /**
2895
- * 自动重新加入失败的 code
2896
- */
2897
- errorCode: number;
2754
+ interface IRtcTokenData {
2755
+ rtcToken: string;
2898
2756
  }
2899
- /**
2900
- * @category Interface
2901
- */
2902
- interface IChatroomRejoinedSuccessed {
2903
- /**
2904
- * 自动重新加入的聊天室 ID
2905
- */
2906
- chatroomId: string;
2907
- /**
2908
- * 自动重新加入的聊天室拉取消息的数量
2909
- */
2910
- count: number;
2757
+ interface IRTCUsers {
2758
+ users: {
2759
+ [userId: string]: {
2760
+ /**
2761
+ * 发布的资源数据,是一个 JSON 字符串,解析后为发布的资源列表
2762
+ */
2763
+ uris?: string;
2764
+ /**
2765
+ * 加房间的身份标识,保存主房间 roomId
2766
+ */
2767
+ extra?: string;
2768
+ };
2769
+ };
2770
+ }
2771
+ interface IJoinRTCRoomData extends IRTCUsers {
2772
+ token: string;
2773
+ sessionId: string;
2774
+ roomInfo: {
2775
+ key: string;
2776
+ value: string;
2777
+ }[];
2778
+ kvEntries: IServerRTCRoomEntry[];
2779
+ offlineKickTime: number;
2780
+ }
2781
+ interface KVString {
2782
+ [key: string]: string;
2911
2783
  }
2912
2784
  /**
2913
- * @category Interface
2785
+ * 设置 RTC 人员 inner、outer 数据
2914
2786
  */
2915
- interface IChatroomUserChangeInfo {
2916
- users: {
2917
- [userId: string]: ChatroomUserChangeType;
2918
- };
2919
- chatroomId: string;
2787
+ interface IRTCUserData {
2788
+ [key: string]: string;
2920
2789
  }
2921
- declare type IChatroomRejoinedInfo = IChatroomRejoinedFailed | IChatroomRejoinedSuccessed;
2790
+
2922
2791
  /**
2923
- * 聊天室信息
2924
2792
  * @category Interface
2925
- */
2926
- interface IChatroomListenerData {
2793
+ */
2794
+ interface IAsyncRes<T = void> {
2927
2795
  /**
2928
- * SDK 内部重连聊天室信息
2929
- */
2930
- rejoinedRoom?: IChatroomRejoinedInfo;
2796
+ * Promise 执行结果
2797
+ */
2798
+ code: ErrorCode;
2931
2799
  /**
2932
- * 监听到的聊天室 KV 更新
2933
- */
2934
- updatedEntries?: IChatroomEntryListenerData[];
2800
+ * 结果数据
2801
+ */
2802
+ data?: T;
2935
2803
  /**
2936
- * 登录退出的用户通知
2804
+ * 错误消息
2937
2805
  */
2938
- userChange?: IChatroomUserChangeInfo;
2806
+ msg?: string;
2807
+ }
2808
+ /**
2809
+ * 异步任务结果定义
2810
+ * @description
2811
+ * 通过 `Promise.resolve` 来处理预期内的异常,进而通过 Uncatch Promise Error 暴露预期外的异常
2812
+ */
2813
+ declare type IPromiseResult<T = void> = Promise<IAsyncRes<T>>;
2814
+ interface IConnectResult {
2939
2815
  /**
2940
- * 聊天室销毁
2816
+ * 连接错误码
2941
2817
  */
2942
- chatroomDestroyed?: string;
2818
+ code: ErrorCode;
2819
+ /**
2820
+ * 导航获取成功后即可有相应的值,在导航数据获取完成之前该值为 undefined
2821
+ */
2822
+ userId?: string;
2943
2823
  }
2824
+
2944
2825
  /**
2945
- * @category Interface
2826
+ * 代理信息
2946
2827
  */
2947
- interface IChatroomEntry {
2828
+ interface IProxy {
2829
+ socksHost: string;
2830
+ socksPort: number;
2831
+ socksUsername?: string;
2832
+ socksPassword?: string;
2833
+ }
2834
+
2835
+ declare enum HttpMethod {
2836
+ GET = "GET",
2837
+ POST = "POST"
2838
+ }
2839
+ interface IRequest {
2840
+ url: string;
2948
2841
  /**
2949
- * 属性名称, 支持英文字母、数字、+、=、-、_ 的组合方式, 最大长度 128 字符
2842
+ * @default `HttpMethod.GET`
2950
2843
  */
2951
- key: string;
2844
+ method?: HttpMethod | 'GET' | 'POST';
2952
2845
  /**
2953
- * 属性对应的值, 最大长度 4096 字符
2846
+ * 查询数据
2954
2847
  */
2955
- value: string;
2848
+ query?: {
2849
+ [key: string]: string | number | null;
2850
+ };
2956
2851
  /**
2957
- * 设置成功后是否发送通知消息
2852
+ * Request Header 信息
2958
2853
  */
2959
- isSendNotification?: boolean;
2854
+ headers?: {
2855
+ [key: string]: string;
2856
+ };
2960
2857
  /**
2961
- * RC:chrmKVNotiMsg 消息中携带的附加信息
2858
+ * Request Body 数据
2962
2859
  */
2963
- notificationExtra?: string;
2860
+ body?: Object | string;
2964
2861
  /**
2965
- * 用户退出聊天室时是否清除此属性
2862
+ * 超时设置,默认 `60s`
2966
2863
  */
2967
- isAutoDelete?: boolean;
2968
- }
2969
- /**
2970
- * @category Interface
2971
- */
2972
- interface IChatroomUser {
2864
+ timeout?: number;
2973
2865
  /**
2974
- * 用户 id
2866
+ * 【Alipay-Only】
2867
+ * 期望返回的数据格式,如果为 json 则返回后会对返回的数据进行一次 JSON.parse
2975
2868
  */
2976
- id: string;
2869
+ dataType?: 'json' | 'text' | 'base64' | 'arraybuffer';
2977
2870
  /**
2978
- * 加入聊天室的时间
2871
+ * socks5 代理参数,仅 Electron 平台有效,web 平台默认为 null
2979
2872
  */
2980
- time: number;
2873
+ proxy?: IProxy | null;
2874
+ }
2875
+ interface IStorage {
2876
+ setItem(key: string, value: string): void;
2877
+ getItem(key: string): string | null;
2878
+ removeItem(key: string): void;
2879
+ clear(): void;
2880
+ }
2881
+ interface IResponse {
2882
+ status: number;
2883
+ data?: string;
2981
2884
  }
2982
2885
  /**
2983
- * @category Interface
2886
+ * 网络状态枚举
2984
2887
  */
2985
- interface IChatroomInfo {
2888
+ declare enum NetworkType {
2889
+ WIFI = "wifi",
2890
+ FOUR_G = "4g",
2891
+ THREE_G = "3g",
2892
+ TWO_G = "2g",
2893
+ FIVE_G = "2g",
2894
+ THREE_GENT = "3gnet",
2895
+ UNKONWN = "unknown"
2896
+ }
2897
+ interface IWebSocket {
2986
2898
  /**
2987
- * 成员列表
2988
- * @todo 需确认数组元素的数据结构
2899
+ * 监听连接建立事件,此时 WebSocket 实例已准备好收发数据
2900
+ * @param callback
2989
2901
  */
2990
- userInfos: IChatroomUser[];
2902
+ onOpen(callback: () => void): void;
2991
2903
  /**
2992
- * 房间内总人数
2904
+ * 监听连接关闭事件
2905
+ * @param callback
2993
2906
  */
2994
- userCount: number;
2995
- }
2996
- /**
2997
- * @category Interface
2998
- */
2999
- interface IRemoveChatroomEntry {
2907
+ onClose(callback: (code?: number, reason?: string) => void): void;
3000
2908
  /**
3001
- * 属性名称, 支持英文字母、数字、+、=、-、_ 的组合方式, 最大长度 128 字符
2909
+ * 监听接收服务器消息事件
2910
+ * @param callback
3002
2911
  */
3003
- key: string;
2912
+ onMessage(callback: (data: string | ArrayBuffer) => void): void;
3004
2913
  /**
3005
- * 删除成功后是否发送通知消息
2914
+ * 监听链接错误事件
2915
+ * @param callback
3006
2916
  */
3007
- isSendNotification?: boolean;
2917
+ onError(callback: (error: unknown) => void): void;
3008
2918
  /**
3009
- * RC:chrmKVNotiMsg 消息中携带的附加信息
2919
+ * 向服务器发送数据
2920
+ * @param data
3010
2921
  */
3011
- notificationExtra?: string;
2922
+ send(data: ArrayBuffer | string): void;
2923
+ /**
2924
+ * 关闭连接
2925
+ * @param code
2926
+ * @param reason
2927
+ */
2928
+ close(code?: number, reason?: string): void;
3012
2929
  }
3013
2930
  /**
3014
- * @category Interface
2931
+ * 平台运行时抽象
3015
2932
  */
3016
- interface IRemoveChatroomEntries {
2933
+ interface IRuntime {
3017
2934
  /**
3018
- * key 属性名称, 支持英文字母、数字、+、=、-、_ 的组合方式, 最大长度 128 字符
2935
+ * 平台标识
3019
2936
  */
3020
- entries: {
3021
- key: string;
3022
- }[];
2937
+ tag: string;
3023
2938
  /**
3024
- * 删除成功后是否发送通知消息
2939
+ * 发送 http 请求
2940
+ * @param options
3025
2941
  */
2942
+ httpReq(options: IRequest): Promise<IResponse>;
3026
2943
  /**
3027
- * RC:chrmKVNotiMsg 消息中携带的附加信息
2944
+ * 是否使用导航
3028
2945
  */
3029
- notificationExtra?: string;
3030
- }
3031
- /**
3032
- * @category Interface
3033
- */
3034
- interface IChatroomEntries {
2946
+ useNavi: boolean;
3035
2947
  /**
3036
- * entries ,要设置的属性列表
3037
- * key 属性名称, 支持英文字母、数字、+、=、-、_ 的组合方式, 最大长度 128 字符
3038
- * value 属性对应的值, 最大长度 4096 字符
2948
+ * websocket 地址上附加的平台字段
3039
2949
  */
3040
- entries: {
3041
- key: string;
3042
- value: string;
3043
- }[];
2950
+ connectPlatform: string;
3044
2951
  /**
3045
- * 设置成功后是否发送通知消息
2952
+ * websocket 地址上 apiVer 字段,代表代码是否来源于 uniapp
3046
2953
  */
2954
+ isFromUniapp: boolean;
3047
2955
  /**
3048
- * RC:chrmKVNotiMsg 消息中携带的附加信息
2956
+ * 创建长连接实例
3049
2957
  */
3050
- notificationExtra?: string;
2958
+ createWebSocket(url: string, protocols?: string[]): IWebSocket;
3051
2959
  /**
3052
- * 用户退出聊天室时是否清除此属性
2960
+ * 存储模块
3053
2961
  */
3054
- isAutoDelete?: boolean;
2962
+ localStorage: IStorage;
3055
2963
  /**
3056
- * 是否强制覆盖
2964
+ * 在某些非浏览器平台,其等同于 localStorage
3057
2965
  */
3058
- isForce?: boolean;
2966
+ sessionStorage: IStorage;
2967
+ /**
2968
+ * 获取网络状态
2969
+ * 2g 3g 4g wifi unkown
2970
+ */
2971
+ getNetworkType(): Promise<NetworkType>;
3059
2972
  }
3060
2973
 
3061
2974
  /**
3062
- * @category Interface
2975
+ * 拓展方法定义,便于 electron-solution 实现时保持接口类型推导可用
3063
2976
  */
3064
- interface IUploadAuth {
2977
+ interface IExtraMethod {
2978
+ getConversationsByPage(conversationTypes: ConversationType[], sentTime: number, count: number, channelId?: string): Promise<IAsyncRes<IReceivedConversation[]>>;
2979
+ getHistoryMessagesByObjectNames(conversationType: ConversationType, targetId: string, sentTime: number, count: number, objectNames: string[], desc: 0 | 1, tag: string): Promise<IAsyncRes<{
2980
+ list: IReceivedMessage[];
2981
+ hasMore: boolean;
2982
+ }>>;
2983
+ updateMessageReceiptStatus(conersationType: ConversationType, targetId: string, timestamp: number, channelId?: string): Promise<IAsyncRes<boolean>>;
2984
+ }
2985
+
2986
+ /**
2987
+ * 导航信息数据就结构
2988
+ */
2989
+ interface INaviInfo {
3065
2990
  /**
3066
- * 七牛 token 有效期
3067
- */
3068
- deadline: number;
2991
+ * Navi 数据请求响应码,200 为成功请求
2992
+ */
2993
+ code: number;
3069
2994
  /**
3070
- * 七牛上传 token
3071
- */
3072
- token: string;
2995
+ * 获取 Navi 数据失败时的提示信息
2996
+ */
2997
+ errorMessage?: string;
3073
2998
  /**
3074
- * 百度上传 token
3075
- */
3076
- bosToken: string;
2999
+ * 获取 Navi 数据失败时的请求 url 信息
3000
+ */
3001
+ url?: string;
3077
3002
  /**
3078
- * 百度上传 header Date
3079
- */
3080
- bosDate: string;
3003
+ * 请求导航数据时使用的协议:http / https
3004
+ * @description 该字段为 SDK 内增加的字段,导航接口数据中不存在
3005
+ */
3006
+ protocol: 'http' | 'https';
3081
3007
  /**
3082
- * 百度上传路径
3083
- */
3084
- path: string;
3008
+ * 获取导航时使用的 userId,小程序不走导航,故拿不到 userId
3009
+ */
3010
+ userId?: string;
3085
3011
  /**
3086
- * 上传文件名,阿里上传获取下载地址时,必须使用上传文件名,所以需抛出到业务端
3012
+ * CMP 服务 Websocket 连接地址,包含域名与端口,不含 ws 或 wss 协议头
3013
+ * @example a.domain.com:443
3087
3014
  */
3088
- fileName: string;
3015
+ server: string;
3089
3016
  /**
3090
- * 阿里云 oss AccessKeyId
3017
+ * 备用 CMP 服务地址,包含域名与端口,不含 ws 或 wss 协议头,多个备用地址以 ',' 分割
3018
+ * @example a.domain.com:443,b.domain.com:443
3091
3019
  */
3092
- osskeyId: string;
3020
+ backupServer?: string;
3093
3021
  /**
3094
- * 阿里云 oss post 请求表单域中的字段 policy
3022
+ * 备用 CMP 服务地址,POST 请求 TCP 连接返回的是 bs 字段,非 backupServer 字段
3095
3023
  */
3096
- ossPolicy: string;
3024
+ bs?: string;
3097
3025
  /**
3098
- * 阿里云 oss 根据 policy 计算的签名信息
3026
+ * RTC 服务配置,其值可能为 null、无效字符串、有效 JSON 字符串
3027
+ * 1. 公有云未开通音视频时,值为 null
3028
+ * 2. 私有云无配置时为 `{ "strategy": 0 }`
3099
3029
  */
3100
- ossSign: string;
3030
+ voipCallInfo: string | null;
3101
3031
  /**
3102
- * 阿里云 oss 存储空间名称
3032
+ * 聊天室 kv 存储开关
3033
+ * @todo 需确认详细有效值
3034
+ * @description 公有云独有配置
3103
3035
  */
3104
- ossBucketName: string;
3036
+ kvStorage: number;
3105
3037
  /**
3106
- * s3 认证凭证,对应 post上传 x-amz-credential 字段
3038
+ * HttpDNS 功能开关,在 web 端无效
3039
+ * @description 公有云独有配置
3107
3040
  */
3108
- s3Credential: string;
3041
+ openHttpDNS: boolean;
3109
3042
  /**
3110
- * 加密算法,对应 post上传 x-amz-algorithm 字段
3043
+ * 历史消息云存储功能开关
3044
+ * @description
3045
+ * 1. 公有云通过 `developer.rongcloud.cn` 管理后台 `单群聊消息云端存储` 功能开关进行配置
3046
+ * 2. 私有云默认为 `true`
3111
3047
  */
3112
- s3Algorithm: string;
3048
+ historyMsg: boolean;
3113
3049
  /**
3114
- * s3 日期,对应 post上传 x-amz-date 字段
3050
+ * 聊天室历史消息开关
3051
+ * @description
3052
+ * 1. 私有云对聊天室功能支持有限,默认为 `false`
3053
+ * 2. TODO: 公有云配置待确认
3115
3054
  */
3116
- s3Date: string;
3055
+ chatroomMsg: boolean;
3117
3056
  /**
3118
- * s3 policy,对应 post上传 policy 字段
3057
+ * 文件服务器地址
3058
+ * @description
3059
+ * 1. 公有云下,该地址为七牛云服务器地址
3060
+ * 2. 私有云下,该地址为私有云自研文件服务器地址
3119
3061
  */
3120
- s3Policy: string;
3062
+ uploadServer: string;
3121
3063
  /**
3122
- * s3 签名信息,对应 post上传 x-amz-signature 字段
3064
+ * 实时位置共享配置,web 端无需处理
3123
3065
  */
3124
- s3Signature: string;
3066
+ location: null | string;
3125
3067
  /**
3126
- * s3 存储空间名称
3068
+ * 实时日志上传开关
3069
+ * @todo 需确认有效值及作用
3127
3070
  */
3128
- s3BucketName: string;
3071
+ monitor: number;
3129
3072
  /**
3130
- * stc Authorization 头
3073
+ * 是否允许加入多聊天室开关
3131
3074
  */
3132
- stcAuthorization: string;
3075
+ joinMChrm: boolean;
3133
3076
  /**
3134
- * stc xAmzContentSha256
3077
+ * 是否开启公众号功能:`0` 为未开启,`1` 为已开启
3135
3078
  */
3136
- stcContentSha256: string;
3079
+ openMp: 0 | 1;
3137
3080
  /**
3138
- * stc date
3081
+ * 是否开启用户级配置,若开启,需连接成功后立即拉取实时配置,0 | 1
3082
+ * @description
3083
+ * 配置来源:
3084
+ * 1. 导航
3085
+ * 2. 服务端实时下发
3086
+ * 已有配置字段:
3087
+ * 1. Lan. 推送使用的语言设置,用户端可自定义修改. Web 端未做设置, 只做接收
3088
+ * 2. ShPushSwit. 推送是否显示详情设置,用户端可自定义修改. Web 端未做设置, 只做接收
3089
+ * 3. MobPushSwit: Web/PC 在线,移动端不在线是否发送推送开关,用户端可自定义修改. Web 端未做设置, 只做接收
3090
+ * 4. OffMsgDur: 离线消息保存天数,设置天数不可大于App级对应配置,用户端可自定义修改. Web 端未做设置, 只做接收
3091
+ * 5. VoipInfo: 音视频相关配置,用户端不可自定义修改. 由服务端决定,与导航下发格式一致
3092
+ * @todo 需确认公有云与私有云区别
3139
3093
  */
3140
- stcDate: string;
3094
+ openUS: 0 | 1;
3141
3095
  /**
3142
- * stc 存储空间名称
3096
+ * 超级群功能开关,1表示开
3143
3097
  */
3144
- stcBucketName: string;
3145
- }
3146
-
3147
- interface IRTCRoomInfo {
3148
- roomId: string;
3149
- roomData: unknown[];
3150
- userCount: number;
3151
- list: unknown[];
3152
- }
3153
- interface IRtcTokenData {
3154
- rtcToken: string;
3155
- }
3156
- interface IRTCUsers {
3157
- users: {
3158
- [userId: string]: {
3159
- /**
3160
- * 发布的资源数据,是一个 JSON 字符串,解析后为发布的资源列表
3161
- */
3162
- uris?: string;
3163
- /**
3164
- * 加房间的身份标识,保存主房间 roomId
3165
- */
3166
- extra?: string;
3167
- };
3168
- };
3169
- }
3170
- interface IJoinRTCRoomData extends IRTCUsers {
3171
- token: string;
3172
- sessionId: string;
3173
- roomInfo: {
3174
- key: string;
3175
- value: string;
3176
- }[];
3177
- kvEntries: IServerRTCRoomEntry[];
3178
- offlineKickTime: number;
3179
- }
3180
- interface KVString {
3181
- [key: string]: string;
3182
- }
3183
- /**
3184
- * 设置 RTC 人员 inner、outer 数据
3185
- */
3186
- interface IRTCUserData {
3187
- [key: string]: string;
3188
- }
3189
-
3190
- /**
3191
- * @category Interface
3192
- */
3193
- interface IAsyncRes<T = void> {
3098
+ ugMsg?: 0 | 1;
3194
3099
  /**
3195
- * Promise 执行结果
3100
+ * 群离线消息最大下发条数,`0` 为关闭
3101
+ * @description 公有云独有配合
3196
3102
  */
3197
- code: ErrorCode;
3103
+ grpMsgLimit: number;
3198
3104
  /**
3199
- * 结果数据
3105
+ * 消息加密开关,0 为关闭
3106
+ * @todo
3107
+ * 1. 确定其控制的功能
3108
+ * 2. 确定 web 相关性
3200
3109
  */
3201
- data?: T;
3110
+ isFormatted: number;
3202
3111
  /**
3203
- * 错误消息
3112
+ * GIF 动图大小限制,默认 2048 KB
3204
3113
  */
3205
- msg?: string;
3206
- }
3207
- /**
3208
- * 异步任务结果定义
3209
- * @description
3210
- * 通过 `Promise.resolve` 来处理预期内的异常,进而通过 Uncatch Promise Error 暴露预期外的异常
3211
- */
3212
- declare type IPromiseResult<T = void> = Promise<IAsyncRes<T>>;
3213
- interface IConnectResult {
3114
+ gifSize: number;
3214
3115
  /**
3215
- * 连接错误码
3116
+ * 上传小视频时长限制,单位:秒
3117
+ * @description 公有云字段,即私有云配置中的 `uploadVideoTimeLimit`
3216
3118
  */
3217
- code: ErrorCode;
3119
+ videoTimes?: number;
3218
3120
  /**
3219
- * 导航获取成功后即可有相应的值,在导航数据获取完成之前该值为 undefined
3121
+ * 上传小视频时长限制,单位:秒
3122
+ * @description 私有云字段,即公有云配置中的 `videoTimes`
3220
3123
  */
3221
- userId?: string;
3222
- }
3223
-
3224
- declare enum HttpMethod {
3225
- GET = "GET",
3226
- POST = "POST"
3227
- }
3228
- interface IRequest {
3229
- url: string;
3124
+ uploadVideoTimeLimit?: number;
3230
3125
  /**
3231
- * @default `HttpMethod.GET`
3126
+ * 实时日志上传开关:`0` 为关闭,`1` 为开启
3232
3127
  */
3233
- method?: HttpMethod | 'GET' | 'POST';
3128
+ logSwitch: number;
3234
3129
  /**
3235
- * 查询数据
3130
+ * 实时日志上传策略,值为 JSON 字符串
3131
+ * @example `'{
3132
+ * "url": "logcollection.ronghub.com", // 上传地址
3133
+ * "level": 1, // 日志等级
3134
+ * "itv": 6, // 上传频率,即时间间隔,单位 s
3135
+ * "times": 5 // 重试次数?
3136
+ * }'`
3236
3137
  */
3237
- query?: {
3238
- [key: string]: string | number | null;
3239
- };
3138
+ logPolicy: string;
3240
3139
  /**
3241
- * Request Header 信息
3140
+ * 百度 BOS 存储服务地址
3141
+ * @description 公有云独有配置
3142
+ * @example `gz.bcebos.com`
3242
3143
  */
3243
- headers?: {
3244
- [key: string]: string;
3245
- };
3144
+ bosAddr?: string;
3246
3145
  /**
3247
- * Request Body 数据
3146
+ * 阿里上传配置,字符串数组,数组顺序代表 七牛、百度、阿里云 上传权重
3147
+ * @example
3148
+ * ```
3149
+ * `[{"qiniu":"upload.qiniup.com","p":"1"},
3150
+ * {"baidu":"gz.bcebos.com","p":"2"},
3151
+ * {"aliyun":"oss-cn-beijing.aliyuncs.com","p":"3"}]`
3152
+ * ```
3248
3153
  */
3249
- body?: Object | string;
3154
+ ossConfig?: string;
3250
3155
  /**
3251
- * 超时设置,默认 `60s`
3156
+ * 私有云专有属性,可用来判断当前环境是公有云还是私有云,私有云环境下该值为 `1`
3252
3157
  */
3253
- timeout?: number;
3158
+ type?: number;
3254
3159
  /**
3255
- * 【Alipay-Only】
3256
- * 期望返回的数据格式,如果为 json 则返回后会对返回的数据进行一次 JSON.parse
3160
+ * @deprecated 已废弃
3257
3161
  */
3258
- dataType?: 'json' | 'text' | 'base64' | 'arraybuffer';
3259
- }
3260
- interface IStorage {
3261
- setItem(key: string, value: string): void;
3262
- getItem(key: string): string | null;
3263
- removeItem(key: string): void;
3264
- clear(): void;
3265
- }
3266
- interface IResponse {
3267
- status: number;
3268
- data?: string;
3269
- }
3270
- /**
3271
- * 网络状态枚举
3272
- */
3273
- declare enum NetworkType {
3274
- WIFI = "wifi",
3275
- FOUR_G = "4g",
3276
- THREE_G = "3g",
3277
- TWO_G = "2g",
3278
- FIVE_G = "2g",
3279
- THREE_GENT = "3gnet",
3280
- UNKONWN = "unknown"
3281
- }
3282
- interface IWebSocket {
3162
+ compDays: number;
3283
3163
  /**
3284
- * 监听连接建立事件,此时 WebSocket 实例已准备好收发数据
3285
- * @param callback
3164
+ * @deprecated 已废弃
3286
3165
  */
3287
- onOpen(callback: () => void): void;
3166
+ msgAck: unknown;
3288
3167
  /**
3289
- * 监听连接关闭事件
3290
- * @param callback
3168
+ * @deprecated 已废弃
3291
3169
  */
3292
- onClose(callback: (code?: number, reason?: string) => void): void;
3170
+ activeServer: string;
3171
+ /**
3172
+ * @deprecated 已废弃
3173
+ */
3174
+ qnAddr: string;
3175
+ /**
3176
+ * @deprecated 已废弃
3177
+ */
3178
+ extkitSwitch: number;
3179
+ /**
3180
+ * @deprecated 已废弃
3181
+ */
3182
+ alone: boolean;
3183
+ /**
3184
+ * @deprecated 已废弃
3185
+ */
3186
+ voipServer: string;
3187
+ /**
3188
+ * 离线日志上报地址
3189
+ * @deprecated 已废弃
3190
+ */
3191
+ offlinelogserver: string;
3192
+ /**
3193
+ * 在线日志上报地址
3194
+ * @deprecated 已废弃
3195
+ */
3196
+ onlinelogserver?: string;
3293
3197
  /**
3294
- * 监听接收服务器消息事件
3295
- * @param callback
3198
+ * 链路加密字段,内容为 JSON 字符串,仅限 C++ 可用
3296
3199
  */
3297
- onMessage(callback: (data: string | ArrayBuffer) => void): void;
3200
+ crypto?: string;
3298
3201
  /**
3299
- * 监听链接错误事件
3300
- * @param callback
3202
+ * 群组回执开关, 1: 打开,0(或者没有): 关闭
3301
3203
  */
3302
- onError(callback: (error: unknown) => void): void;
3204
+ grpRRVer?: number;
3303
3205
  /**
3304
- * 向服务器发送数据
3305
- * @param data
3206
+ * 防黑产开关, 1: 打开,0:关闭
3306
3207
  */
3307
- send(data: ArrayBuffer | string): void;
3208
+ openAnti?: number;
3308
3209
  /**
3309
- * 关闭连接
3310
- * @param code
3311
- * @param reason
3210
+ * 鉴权认证
3312
3211
  */
3313
- close(code?: number, reason?: string): void;
3212
+ jwt?: string;
3314
3213
  }
3214
+
3215
+ declare type INaviCache = {
3216
+ token: string;
3217
+ naviInfo: INaviInfo;
3218
+ timestamp: number;
3219
+ };
3315
3220
  /**
3316
- * 平台运行时抽象
3221
+ * 导航数据管理类,负责管理导航有效期、导航请求、导航缓存
3317
3222
  */
3318
- interface IRuntime {
3223
+ declare abstract class BasicNavi {
3224
+ protected readonly appkey: string;
3225
+ protected readonly logger: BasicLogger;
3319
3226
  /**
3320
- * 平台标识
3227
+ * 业务层的自定义导航配置
3321
3228
  */
3322
- tag: string;
3229
+ protected readonly navigators: string[];
3230
+ constructor(appkey: string, logger: BasicLogger,
3323
3231
  /**
3324
- * 发送 http 请求
3325
- * @param options
3232
+ * 业务层的自定义导航配置
3326
3233
  */
3327
- httpReq(options: IRequest): Promise<IResponse>;
3234
+ navigators: string[]);
3328
3235
  /**
3329
- * 是否使用导航
3236
+ * 当前进行中的导航请求
3330
3237
  */
3331
- useNavi: boolean;
3238
+ private crtRequest;
3332
3239
  /**
3333
- * websocket 地址上附加的平台字段
3240
+ * 请求导航数据
3241
+ * @param token
3242
+ * @param ignoreCache 是否忽略缓存,强制从服务器重新拉取。
3243
+ * @param ignoreExpire 是否忽略有效期检查。理论上只需要在建立连接时需要检测 navi 有效期,其他场景无需检测
3244
+ * @param traceId 事务日志跟踪 ID
3334
3245
  */
3335
- connectPlatform: string;
3246
+ request(token: string, ignoreCache: boolean, ignoreExpire: boolean, traceId: string): IPromiseResult<INaviInfo>;
3247
+ private sendRequest;
3336
3248
  /**
3337
- * websocket 地址上 apiVer 字段,代表代码是否来源于 uniapp
3249
+ * 从指定服务列表中顺序尝试获取导航
3250
+ * @param uris 导航服务列表
3251
+ * @param token
3252
+ * @param traceId
3338
3253
  */
3339
- isFromUniapp: boolean;
3254
+ private requestHandler;
3340
3255
  /**
3341
- * 创建长连接实例
3256
+ * 向目标导航服务发送请求
3257
+ * @param uri 导航服务地址
3258
+ * @param appkey
3259
+ * @param token
3260
+ * @param version
3261
+ * @param timeout 请求超时时间
3262
+ * @param traceId
3342
3263
  */
3343
- createWebSocket?(url: string, protocols?: string[]): IWebSocket;
3264
+ protected abstract httpRequest(uri: string, appkey: string, token: string, version: string, timeout: number, traceId: string): IPromiseResult<INaviInfo>;
3344
3265
  /**
3345
- * 存储模块
3266
+ * 转换 Navi 接口 HTTP 请求状态码为 ErrorCode 定义
3267
+ * @param code
3346
3268
  */
3347
- localStorage: IStorage;
3269
+ protected transHttpCode(code: number): ErrorCode;
3348
3270
  /**
3349
- * 在某些非浏览器平台,其等同于 localStorage
3271
+ * 设置缓存
3272
+ * @param formatedToken
3273
+ * @param naviInfo
3274
+ * @description 设置缓存的同时会检测缓存中的既有数据,适当清理,避免无效数据长时间占用存储空间
3350
3275
  */
3351
- sessionStorage: IStorage;
3276
+ protected abstract setNaviCache(formatedToken: string, naviInfo: INaviInfo): void;
3352
3277
  /**
3353
- * 获取网络状态
3354
- * 2g 3g 4g wifi unkown
3278
+ * 获取缓存数据
3279
+ * @param formatedToken
3355
3280
  */
3356
- getNetworkType(): Promise<NetworkType>;
3281
+ protected abstract getNaviCache(formatedToken: string): INaviCache | null;
3282
+ /**
3283
+ * 获取缓存的导航信息
3284
+ * @param token
3285
+ */
3286
+ getNaviInfoFromCache(token: string): INaviInfo | null;
3287
+ /**
3288
+ * RTC 配置变更,更新 navi 缓存
3289
+ * @param token
3290
+ * @param voipCallInfo
3291
+ */
3292
+ updateVoipCallInfo(token: string, voipCallInfo: string): void;
3357
3293
  }
3358
3294
 
3359
3295
  /**
3360
- * 拓展方法定义,便于 electron-solution 实现时保持接口类型推导可用
3296
+ * Websocket 导航工具类
3361
3297
  */
3362
- interface IExtraMethod {
3363
- getConversationsByPage(conversationTypes: ConversationType[], sentTime: number, count: number, channelId?: string): Promise<IAsyncRes<IReceivedConversation[]>>;
3364
- getHistoryMessagesByObjectNames(conversationType: ConversationType, targetId: string, sentTime: number, count: number, objectNames: string[], desc: 0 | 1, tag: string): Promise<IAsyncRes<{
3365
- list: IReceivedMessage[];
3366
- hasMore: boolean;
3367
- }>>;
3368
- updateMessageReceiptStatus(conersationType: ConversationType, targetId: string, timestamp: number, channelId?: string): Promise<IAsyncRes<boolean>>;
3298
+ declare class WebSocketNavi extends BasicNavi {
3299
+ private runtime;
3300
+ /**
3301
+ * 小程序平台服务地址,多个地址以 ',' 分割
3302
+ */
3303
+ private readonly miniCmpUris;
3304
+ constructor(appkey: string, logger: BasicLogger, runtime: IRuntime,
3305
+ /**
3306
+ * 小程序平台服务地址,多个地址以 ',' 分割
3307
+ */
3308
+ miniCmpUris: string, navigators?: string[]);
3309
+ protected httpRequest(uri: string, appkey: string, token: string, version: string, timeout: number, traceId: string): IPromiseResult<INaviInfo>;
3310
+ protected getNaviCache(formatedToken: string): INaviCache | null;
3311
+ protected setNaviCache(formatedToken: string, naviInfo: INaviInfo): void;
3369
3312
  }
3370
3313
 
3371
3314
  /**
@@ -3459,17 +3402,216 @@ interface IProcessInfo {
3459
3402
  }
3460
3403
 
3461
3404
  /**
3462
- * engine 基本接口定义,用于约束 Electron 下主进程、渲染进程、JSEngine 的编码一致性
3405
+ * 连接状态定义枚举值
3463
3406
  */
3464
- interface IEngine {
3407
+ declare enum RCConnectionStatus {
3408
+ /**
3409
+ * 已连接
3410
+ */
3411
+ CONNECTED = 0,
3412
+ /**
3413
+ * 连接中
3414
+ */
3415
+ CONNECTING = 1,
3416
+ /**
3417
+ * 无连接,或已断开
3418
+ */
3419
+ DISCONNECTED = 2,
3420
+ /**
3421
+ * 连接暂停状态,SDK 内部 5s 后会自动尝试重连
3422
+ */
3423
+ SUSPENDED = 3
3424
+ }
3425
+ interface IConnectionListener {
3426
+ /**
3427
+ * 连接成功
3428
+ */
3429
+ onConnected(): void;
3430
+ /**
3431
+ * 连接中止,SDK 内部会进行重连
3432
+ * @param code 中止原因
3433
+ */
3434
+ onSuspend(code: ErrorCode): void;
3435
+ /**
3436
+ * 连接中
3437
+ */
3438
+ onConnecting(): void;
3439
+ /**
3440
+ * 连接已终止
3441
+ * @param code 连接终止原因
3442
+ */
3443
+ onDisconnected(code: ErrorCode): void;
3444
+ }
3445
+ /**
3446
+ * 抽象连接管理器类,负责 engine 层的连接状态维持,和对外的连接状态通知
3447
+ */
3448
+ declare abstract class AConnectionMgr {
3449
+ protected readonly appkey: string;
3450
+ private navi;
3451
+ protected logger: BasicLogger;
3452
+ private listener;
3453
+ constructor(appkey: string, navi: BasicNavi, logger: BasicLogger, listener: IConnectionListener);
3454
+ /**
3455
+ * 当前连接所用 token
3456
+ */
3457
+ private token;
3458
+ /**
3459
+ * 获取当前连接中使用的 token
3460
+ * @returns
3461
+ */
3462
+ getToken(): string;
3463
+ private reconnectKick;
3464
+ /**
3465
+ * 当前连接状态
3466
+ */
3467
+ private _crtConnectionStatus;
3468
+ /**
3469
+ * 当前用户 ID
3470
+ */
3471
+ protected _crtUserId: string;
3472
+ /**
3473
+ * 获取当前用户 ID
3474
+ * @returns
3475
+ */
3476
+ getCurrentUserId(): string;
3477
+ /**
3478
+ * 修改连接状态
3479
+ * @param status
3480
+ * @param code
3481
+ */
3482
+ private setConnectionStatus;
3483
+ /**
3484
+ * 获取当前连接状态
3485
+ * @returns
3486
+ */
3487
+ getConnectionStatus(): RCConnectionStatus;
3465
3488
  /**
3466
3489
  * 建立连接
3467
3490
  * @param token
3491
+ * @param reconnectKickEnable 设置断线重连时是否踢出当前正在重连的设备 (仅 Electron 环境有效)
3492
+ * 同一个账号在一台新设备上登录的时候,会把这个账号在之前登录的设备上踢出。
3493
+ * 由于 SDK 有断线重连功能,存在下面情况。
3494
+ * 用户在 A 设备登录,A 设备网络不稳定,没有连接成功,SDK 启动重连机制。
3495
+ * 用户此时又在 B 设备登录,B 设备连接成功。
3496
+ * A 设备网络稳定之后,用户在 A 设备连接成功,B 设备被踢出。
3497
+ * 这个字段就是为这种情况加的。
3498
+ * 设置 reconnectKickEnable 为 true 时,SDK 重连的时候发现此时已有别的设备连接成功,不再强行踢出已有设备,而是踢出重连设备。
3499
+ */
3500
+ connect(token: string, reconnectKickEnable: boolean, traceId: string): IPromiseResult<string>;
3501
+ /**
3502
+ * 执行中的连接事务
3503
+ */
3504
+ private _crtConnectionTask;
3505
+ /**
3506
+ * 尝试建立连接
3507
+ * @param token
3508
+ * @param reconnectKickEnable
3509
+ * @param ignoreNaviCache
3510
+ * @param traceId
3511
+ * @description 函数会检测当前是否有进行中的连接任务,若存在,则直接返回当前连接任务
3512
+ */
3513
+ private try2Connect;
3514
+ /**
3515
+ * 创建连接任务
3516
+ * @param token
3517
+ * @param reconnectKickEnable
3518
+ * @param ignoreNaviCache
3519
+ * @param traceId
3520
+ * @returns
3521
+ */
3522
+ private createConnectionTask;
3523
+ private reconnectTimer;
3524
+ /**
3525
+ * 尝试重连
3526
+ * @param ignoreNaviCache 是否忽略 navi 缓存以重新请求 navi
3527
+ */
3528
+ private try2Reconnect;
3529
+ /**
3530
+ * 服务器主动断开时由子类调用,函数将根据 reason 确定是否尝试重连
3531
+ * @param reason
3532
+ */
3533
+ protected onDisconnectByServer(code: ErrorCode): void;
3534
+ /**
3535
+ * Socket 异常中断时由子类调用,SDK 尝试恢复重连
3536
+ */
3537
+ protected onDisconenctUnusual(code: ErrorCode): void;
3538
+ /**
3539
+ * 建立 Socket 连接,由子类集成实现
3540
+ * @param token
3468
3541
  * @param naviInfo
3469
3542
  * @param reconnectKickEnable
3543
+ * @param traceId
3544
+ */
3545
+ protected abstract connectWithToken(token: string, naviInfo: INaviInfo, reconnectKickEnable: boolean, traceId: string): IPromiseResult<string>;
3546
+ /**
3547
+ * 当前累计心跳超时次数
3548
+ */
3549
+ private _failedCount;
3550
+ /**
3551
+ * 允许连续 PING 超时次数,超出指定次数后会主动关闭 socket 并重新连接
3552
+ */
3553
+ private readonly ALLOW_FAILED_TIMES;
3554
+ /**
3555
+ * 启动心跳计时器
3556
+ */
3557
+ private checkAlive;
3558
+ /**
3559
+ * 关闭连接
3560
+ * @param inReconnect
3561
+ */
3562
+ protected abstract close(inReconnect: boolean): void;
3563
+ /**
3564
+ * 完成一次 ping 过程,并返回响应状态码
3565
+ * @param timeout 超时时间
3566
+ */
3567
+ protected abstract sendPing(timeout: number): Promise<ErrorCode>;
3568
+ /**
3569
+ * 业务层主动断开连接时调用
3570
+ */
3571
+ disconnect(): Promise<void>;
3572
+ /**
3573
+ * 清理重连计时器
3574
+ */
3575
+ private stopReconnectTimer;
3576
+ }
3577
+
3578
+ /**
3579
+ * 查询错误码是否为服务下发的 disconnect 通知 status 所转换
3580
+ * @param code
3581
+ * @description 排除重定向 31006,因 disconnect 和 connAck 都包含元素可被转换为 31006
3582
+ */
3583
+ declare const isDisconnectCode: (code: ErrorCode) => boolean;
3584
+ /**
3585
+ * 查询错误码是否为服务下发的 connAck status 所转换
3586
+ * @param code
3587
+ * @description 排除重定向 31006,因 disconnect 和 connAck 都包含元素可被转换为 31006
3588
+ */
3589
+ declare const isConnnectAckCode: (code: ErrorCode) => boolean;
3590
+
3591
+ /**
3592
+ * 进程内缓存数据
3593
+ */
3594
+ interface IProcessCache {
3595
+ crtUserId: string;
3596
+ connectedTime: number;
3597
+ naviInfo: INaviInfo | null;
3598
+ connectionStatus: RCConnectionStatus;
3599
+ deviceId: string;
3600
+ }
3601
+ /**
3602
+ * 约束主进程 CppEngine 与 CppService 间的方法定义,以便于代码检查
3603
+ */
3604
+ interface IEngine {
3605
+ /**
3606
+ * 注册本渲染进程至主进程,以接收主进程的消息通知,同时同步主进程的当前缓存数据
3607
+ */
3608
+ getMainProcessCache(): IProcessCache;
3609
+ /**
3610
+ * 建立连接
3611
+ * @param token
3612
+ * @param reconnectKickEnable
3470
3613
  */
3471
- connect(token: string, naviInfo: INaviInfo, reconnectKickEnable?: boolean): Promise<ErrorCode>;
3472
- requestNaviInfo(uris: string[], appkey: string, token: string, checkCA?: boolean): Promise<INaviInfo | null>;
3614
+ connect(token: string, reconnectKickEnable: boolean, traceId: string): IPromiseResult<string>;
3473
3615
  getNaviInfoFromCache(): INaviInfo | null;
3474
3616
  /**
3475
3617
  * 上报版本信息
@@ -3591,6 +3733,10 @@ interface IEngine {
3591
3733
  * 获取指定会话
3592
3734
  */
3593
3735
  getConversation(conversationType: ConversationType, targetId: string, channelId: string): IPromiseResult<IReceivedConversation | null>;
3736
+ /**
3737
+ * 获取未读会话列表
3738
+ */
3739
+ getUnreadConversationList(conversationTypes: ConversationType[]): IPromiseResult<IReceivedConversation[]>;
3594
3740
  /**
3595
3741
  * 删除会话
3596
3742
  * @description 该删除操作会删除服务器端存储的会话数据
@@ -3879,7 +4025,7 @@ interface IEngine {
3879
4025
  /**
3880
4026
  * 获取消息
3881
4027
  */
3882
- getMessage(messageId: number): IPromiseResult<IReceivedMessage>;
4028
+ getMessage(messageId: number | string): IPromiseResult<IReceivedMessage>;
3883
4029
  /**
3884
4030
  * 设置消息内容
3885
4031
  */
@@ -3951,7 +4097,7 @@ interface IEngine {
3951
4097
  /**
3952
4098
  * 无差别获取本地置顶列表
3953
4099
  */
3954
- getTopConversationList(): Promise<IAsyncRes<IBaseConversationInfo[]>>;
4100
+ getTopConversationList(conversationTypes?: ConversationType[], channelId?: string): Promise<IAsyncRes<IReceivedConversation[]>>;
3955
4101
  /**
3956
4102
  * 获取单个群聊会话 @ 消息未读数
3957
4103
  */
@@ -3969,6 +4115,18 @@ interface IEngine {
3969
4115
  * 获取应用主进程信息,仅限 Electron 平台可用
3970
4116
  */
3971
4117
  getMainProcessInfo(): IPromiseResult<IProcessInfo>;
4118
+ /**
4119
+ * 设置代理
4120
+ */
4121
+ setProxy(proxy: IProxy | null): IPromiseResult<IProxy>;
4122
+ /**
4123
+ * 获取代理
4124
+ */
4125
+ getProxy(): IPromiseResult<IProxy>;
4126
+ /**
4127
+ * 测试代理
4128
+ */
4129
+ testProxy(proxy: IProxy, testHost: string): Promise<IResponse>;
3972
4130
  rtcPing(roomId: string, mode: number, broadcastType?: number): Promise<IAsyncRes<any>>;
3973
4131
  rtcSignaling(roomId: string, method: string, isQuery: boolean, sourceData: any): Promise<{
3974
4132
  code: ErrorCode;
@@ -4202,65 +4360,49 @@ interface IEndRoomPKOptions {
4202
4360
  /**
4203
4361
  * 消息送达相关接口
4204
4362
  */
4363
+ /**
4364
+ * 送达的用户信息
4365
+ * @hidden
4366
+ */
4205
4367
  interface IDeliveredUser {
4206
4368
  time: number;
4207
4369
  userId: string;
4208
4370
  }
4371
+ /**
4372
+ * 获取群组消息送达的状态信息
4373
+ * @hidden
4374
+ */
4209
4375
  interface IGroupMessageDeliverInfo {
4210
4376
  totalCount: number;
4211
4377
  list: IDeliveredUser[];
4212
4378
  }
4379
+ /**
4380
+ * 单聊消息送达通知数据
4381
+ * @hidden
4382
+ */
4213
4383
  interface IMessageDeliver {
4214
4384
  deliverTime: number;
4215
4385
  messageUId: string;
4216
4386
  objectName: string;
4217
4387
  targetId: string;
4218
4388
  }
4389
+ /**
4390
+ * 群组消息送达通知数据信息
4391
+ * @hidden
4392
+ */
4219
4393
  interface IGroupMessageDeliveredStatusInfo {
4220
4394
  MessageUId: string;
4221
4395
  deliveryCount: number;
4222
4396
  }
4397
+ /**
4398
+ * 群组消息送达通知数据
4399
+ * @hidden
4400
+ */
4223
4401
  interface IGroupMessageDeliverStatus {
4224
4402
  totalCount: number;
4225
4403
  list: IGroupMessageDeliveredStatusInfo[];
4226
4404
  }
4227
4405
 
4228
- /**
4229
- * IndexDB中存储的log数据
4230
- */
4231
- interface ILogInfo {
4232
- sessionId: string;
4233
- time: number;
4234
- level: LogLevel;
4235
- content: string;
4236
- userId?: string;
4237
- logSource?: LogSource;
4238
- tagId?: LogTagId;
4239
- }
4240
- interface IRealTimeLog {
4241
- level: LogLevel;
4242
- content: string;
4243
- }
4244
- interface ILogExtensions {
4245
- traceId?: string;
4246
- logSource?: LogSource;
4247
- }
4248
- interface ILogInit {
4249
- userId?: string;
4250
- localLogLevel?: LogLevel;
4251
- customLogPrint?: (logLevel: LogLevel, msg: string) => void;
4252
- }
4253
- interface IInitBigDataOption {
4254
- runtime?: IRuntime;
4255
- appkey?: string;
4256
- version?: string;
4257
- userId?: string;
4258
- }
4259
- interface IBigdataLogInit extends IInitBigDataOption {
4260
- logUrl: string;
4261
- sessionId: string;
4262
- }
4263
-
4264
4406
  /**
4265
4407
  * 定义已废弃,请使用 `IRemoveChatroomEntries` 替换
4266
4408
  * @deprecated
@@ -4410,118 +4552,11 @@ declare const initLogDB: (appkey: string, logger: ILogger, expireTime?: number)
4410
4552
  declare const deInitLogDB: () => Promise<void>;
4411
4553
 
4412
4554
  /**
4413
- * 日志数据转为 csv 结构数据
4414
- * @param log
4415
- * @returns
4416
- */
4417
- declare const transcsv: (log: ILogData) => string;
4418
-
4419
- /**
4420
- * @description
4421
- * 读数据处理基类
4422
- */
4423
- declare class BaseReader {
4424
- readonly header: Header;
4425
- messageId: number;
4426
- timestamp: number;
4427
- syncMsg: boolean;
4428
- protected identifier: string;
4429
- constructor(header: Header);
4430
- getIdentifier(): string | number;
4431
- read(logger: ILogger, stream: RongStreamReader, length: number, protocolVer: ConnAckProtocolVer): void;
4432
- readMessage(logger: ILogger, stream: RongStreamReader, length?: number, protocolVer?: ConnAckProtocolVer): {
4433
- stream: RongStreamReader;
4434
- length: number | undefined;
4435
- };
4436
- }
4437
- /**
4438
- * @description
4439
- * 写数据处理基类
4440
- */
4441
- declare abstract class BaseWriter {
4442
- private _header;
4443
- lengthSize: number;
4444
- data: any;
4445
- messageId: number;
4446
- topic: string;
4447
- targetId: string;
4448
- identifier: string;
4449
- constructor(headerType: OperationType);
4450
- getIdentifier(): string | number;
4451
- write(stream: RongStreamWriter): void;
4452
- abstract writeMessage(stream: RongStreamWriter): void;
4453
- setHeaderQos(qos: number): void;
4454
- getHeaderFlag(): number;
4455
- getLengthSize(): number;
4456
- getBufferData(): Int8Array;
4457
- }
4458
- declare class RetryableReader extends BaseReader {
4459
- messageId: number;
4460
- readMessage(logger: ILogger, stream: RongStreamReader, length: number): {
4461
- stream: RongStreamReader;
4462
- length: number;
4463
- };
4464
- }
4465
- declare class RetryableWriter extends BaseWriter {
4466
- writeMessage(stream: RongStreamWriter): void;
4467
- }
4468
- declare class PublishReader extends RetryableReader {
4469
- topic: string;
4470
- data: any;
4471
- targetId: string;
4472
- date: any;
4473
- syncMsg: boolean;
4474
- identifier: string;
4475
- readMessage(logger: ILogger, stream: RongStreamReader, length: number): {
4476
- stream: RongStreamReader;
4477
- length: number;
4478
- };
4479
- }
4480
- /**
4481
- * @description
4482
- * 发消息使用
4483
- */
4484
- declare class PublishWriter extends RetryableWriter {
4485
- topic: string;
4486
- data: any;
4487
- targetId: string;
4488
- date: any;
4489
- syncMsg: boolean;
4490
- identifier: string;
4491
- constructor(topic: string, data: any, targetId: string);
4492
- writeMessage(stream: RongStreamWriter): void;
4493
- }
4494
- /**
4495
- * @description
4496
- * 发消息, Server 给的 Ack 回执
4497
- */
4498
- declare class PubAckReader extends RetryableReader {
4499
- status: number;
4500
- date: number;
4501
- data: any;
4502
- millisecond: number;
4503
- messageUId: string;
4504
- timestamp: number;
4505
- identifier: string;
4506
- topic: string;
4507
- targetId: string;
4508
- readMessage(logger: ILogger, stream: RongStreamReader, length: number): {
4509
- stream: RongStreamReader;
4510
- length: number;
4511
- };
4512
- }
4513
- /**
4514
- * @description
4515
- * Web 主动查询
4555
+ * 日志数据转为 csv 结构数据
4556
+ * @param log
4557
+ * @returns
4516
4558
  */
4517
- declare class QueryWriter extends RetryableWriter {
4518
- topic: string;
4519
- data: any;
4520
- targetId: string;
4521
- identifier: string;
4522
- constructor(topic: string, data: any, targetId: string);
4523
- writeMessage(stream: RongStreamWriter): void;
4524
- }
4559
+ declare const transcsv: (log: ILogData) => string;
4525
4560
 
4526
4561
  /**
4527
4562
  * 会话属性
@@ -4598,26 +4633,12 @@ interface IServerUserSetting {
4598
4633
  };
4599
4634
  version: number;
4600
4635
  }
4601
- interface ISyncMsgArgs {
4602
- inboxTime: number;
4603
- sendboxTime: number;
4604
- broadcastSyncTime?: number;
4605
- }
4606
4636
  interface IGetMsgOption {
4607
4637
  timestamp?: number;
4608
4638
  count?: number;
4609
4639
  order?: number;
4610
4640
  channelId?: string;
4611
4641
  }
4612
- interface IGetConversationListOption {
4613
- type?: number;
4614
- count?: number;
4615
- startTime?: number;
4616
- order?: 0 | 1;
4617
- }
4618
- interface IClearMsgOption {
4619
- timestamp?: number;
4620
- }
4621
4642
 
4622
4643
  /**
4623
4644
  * TODO: 确定对外暴露的必要性
@@ -4633,362 +4654,9 @@ declare const DelayTimer: {
4633
4654
  getTime: () => number;
4634
4655
  };
4635
4656
 
4636
- /**
4637
- * 序列化、反序列化数据通道
4638
- */
4639
- declare class DataCodec {
4640
- private logger;
4641
- private _codec;
4642
- constructor(logger: BasicLogger);
4643
- private static createPBCodec;
4644
- /**
4645
- * PB 数据 转为 rmtp 数据 反序列化 通用数据
4646
- * 根据解析的 PBName 分配解码方法. 如果没有单独的解码方法定义. 直接返回 pb 解析后的结果
4647
- */
4648
- decodeByPBName(data: any, pbName: string, option?: any): any;
4649
- private _readBytes;
4650
- /**
4651
- * ====== 以下为 rmtp 数据 反序列化为 可用数据 ======
4652
- */
4653
- private _formatBytes;
4654
- /**
4655
- * 格式化多端同步消息
4656
- */
4657
- private _formatSyncMessages;
4658
- /**
4659
- * 格式化接收消息
4660
- */
4661
- private _formatReceivedMessage;
4662
- /**
4663
- * 格式化发送消息
4664
- */
4665
- private _formatSentMessage;
4666
- /**
4667
- * 格式化历史消息
4668
- */
4669
- private _formatHistoryMessages;
4670
- /**
4671
- * 格式化超级群消息变更列表
4672
- */
4673
- private _formatUltraMsgChangeList;
4674
- /**
4675
- * 格式化超级群消息变更列表
4676
- */
4677
- private _formatUltraOperateStatusNotifyList;
4678
- /**
4679
- * 格式化超级群变更后消息列表
4680
- */
4681
- private _formatUltraMsgList;
4682
- /**
4683
- * 格式化超级群获取指定会话未读 @ 消息列表
4684
- */
4685
- private _formatUltraGroupUnreadMentionedList;
4686
- /**
4687
- * 格式化会话列表
4688
- */
4689
- private _formatConversationList;
4690
- /**
4691
- * 格式化用户设置
4692
- */
4693
- private _formatSetUserSettingOutput;
4694
- /**
4695
- * 格式化聊天室信息
4696
- */
4697
- private _formatChatRoomInfos;
4698
- /**
4699
- * 格式化 聊天室 KV 列表
4700
- */
4701
- private _formatChatRoomKVList;
4702
- /**
4703
- * 格式化 用户设置
4704
- */
4705
- private _formatUserSetting;
4706
- /**
4707
- * 格式化 会话状态 置顶、免打扰
4708
- */
4709
- private _formatConversationStatus;
4710
- /**
4711
- * 格式化 获取已读列表
4712
- */
4713
- private _formatGrpReadReceiptQryResp;
4714
- /**
4715
- * 格式化用户配置通知
4716
- */
4717
- private _formatUserSettingNotification;
4718
- /**
4719
- * 拉取聊天室 kv 存储时的最新时间戳
4720
- */
4721
- private _formatChrmKVVersion;
4722
- /**
4723
- * 格式化加入 RTC 房间的用户信息
4724
- */
4725
- private _formatRTCJoinedUserInfo;
4726
- /**
4727
- * ===== 以下为通用数据 序列化为 PB 数据 =====
4728
- * Engine Index 调用处理数据
4729
- */
4730
- /**
4731
- * ? 待补全注释
4732
- */
4733
- encodeServerConfParams(): any[];
4734
- /**
4735
- * 上行消息基础配置
4736
- */
4737
- private _getUpMsgModule;
4738
- /**
4739
- * 序列化上行消息
4740
- */
4741
- encodeUpMsg(conversation: IConversationOption, option: ISendMsgOptions): any[];
4742
- /**
4743
- * 序列化拉取多端消息
4744
- */
4745
- encodeSyncMsg(syncMsgArgs: ISyncMsgArgs): any[];
4746
- /**
4747
- * 序列化拉取聊天室消息
4748
- */
4749
- encodeChrmSyncMsg(time: number, count: number): any[];
4750
- /**
4751
- * 序列化历史消息所需参数
4752
- */
4753
- encodeGetHistoryMsg(targetId: string, option: IGetMsgOption): any[];
4754
- /**
4755
- * 序列化同步超级群所需参数
4756
- */
4757
- encodeSuperSyncMsg(syncTime: number): any[];
4758
- /**
4759
- * 序列化会话列表
4760
- */
4761
- encodeGetConversationList(option: IGetConversationListOption): any[];
4762
- /**
4763
- * 旧会话列表. 获取、删除都调用此方法
4764
- */
4765
- encodeOldConversationList(option: IGetConversationListOption): any[];
4766
- /**
4767
- * 旧会话列表删除,支持多组织
4768
- */
4769
- encodeRemoveOldConversationList(conversation: IConversationOption): any[];
4770
- /**
4771
- * 旧会话列表删除
4772
- */
4773
- encodeRemoveConversationList(conversationList: IConversationOption[]): any[];
4774
- /**
4775
- * 批量删除消息通过消息 ID
4776
- */
4777
- encodeDeleteMessages(conversationType: ConversationType, targetId: string, list: {
4778
- messageUId: string;
4779
- sentTime: number;
4780
- messageDirection: MessageDirection;
4781
- }[], channelId: string): any[];
4782
- /**
4783
- * 批量删除消息通过时间
4784
- */
4785
- encodeClearMessages(targetId: string, timestamp: number, channelId: string, conversationType?: ConversationType): any[];
4786
- /**
4787
- * 未读数清除
4788
- */
4789
- encodeClearUnreadCount(conversation: IConversationOption, option: IClearMsgOption): any[];
4790
- /**
4791
- * 对已有的超级群消息扩展
4792
- */
4793
- encodeExpandUltraMessage(option: IUltraExMsgOptions, userId: string): any[];
4794
- /**
4795
- * 对已有的超级群消息扩展
4796
- */
4797
- encodemodifyMessage(option: IUltraModifyMsgOptions, userId: string): any[];
4798
- /**
4799
- * 超级群消息变更通知
4800
- */
4801
- encodeQueryMsgChange(time: number): any[];
4802
- /**
4803
- * 超级群消息变更通知
4804
- */
4805
- encodeMsgQuery(option: IUltraMsgQueryOptions): any[];
4806
- /**
4807
- * 序列化获取超级群获取指定会话未读 @ 消息列表参数
4808
- */
4809
- encodeUnreadMentionedMsgQuery(option: IUltraGroupUnreadMentionedOption): any[];
4810
- /**
4811
- * 正在输入中
4812
- */
4813
- encodeOperateStatus(targetId: string, conversationType: ConversationType, channelId: string, operationType: OperateStatus): any[];
4814
- /**
4815
- * 加入退出聊天室
4816
- */
4817
- encodeJoinOrQuitChatRoom(): any[];
4818
- /**
4819
- * 获取聊天室信息
4820
- * @param count 获取人数
4821
- * @param order 排序方式
4822
- */
4823
- encodeGetChatRoomInfo(count: number, order: number): any[];
4824
- /**
4825
- * 设置指定超级群默认通知配置
4826
- * @param notificationLevel
4827
- * * NotificationLevel
4828
- * @param channelId 超级群频道 Id
4829
- */
4830
- encodeSetUltraGroupDefaultNotificationLevel(notificationLevel: NotificationLevel, channelId: string): any;
4831
- /**
4832
- * 查询指定超级群默认通知配置
4833
- * @param channelId 频道 ID
4834
- */
4835
- encodeGetUltraGroupDefaultNotificationLevel(channelId: string): any;
4836
- /**
4837
- * 上传文件认证信息获取
4838
- */
4839
- encodeGetFileToken(fileType: number, fileName: string, httpMethod?: string, queryString?: string): any;
4840
- /**
4841
- * 获取七牛上传url
4842
- */
4843
- encodeGetFileUrl(inputPBName: string, fileType: number, fileName?: string, originName?: string): any;
4844
- /**
4845
- * 聊天室 KV 存储
4846
- */
4847
- encodeModifyChatRoomKV(chrmId: string, entry: IChrmKVEntry, currentUserId: string): any;
4848
- encodeModifyChatRoomKVS(chrmId: string, entryOptions: IChrmKVEntries, currentUserId: string): any;
4849
- /**
4850
- * KV 存储拉取
4851
- */
4852
- encodePullChatRoomKV(time: number): any;
4853
- /**
4854
- * 用户实时配置更新
4855
- */
4856
- encodePullUserSetting(version: number): any;
4857
- /**
4858
- * 获取会话状态 (置顶、免打扰)
4859
- */
4860
- encodeGetConversationStatus(time: number): any;
4861
- /**
4862
- * 设置会话状态 (置顶、免打扰)
4863
- */
4864
- encodeSetConversationStatus(statusList: Array<ISetConversationStatusOptions>, conversationUpdatedTime: number): any;
4865
- /**
4866
- * 序列化发送群组已读回执
4867
- */
4868
- encodeReadReceipt(messageUIds: string[], channelId?: string): any;
4869
- /**
4870
- * 序列化创建tag消息
4871
- */
4872
- encodeCreateTag(tags: Array<ITagParam>, version: number): any;
4873
- /**
4874
- * 序列化获取群组消息已读列表
4875
- */
4876
- encodeMessageReader(messageUId: string, channelId?: string): any;
4877
- /**
4878
- * 序列化删除tag消息
4879
- */
4880
- encodeRemoveTag(tagIds: Array<string>, version: number): any;
4881
- /**
4882
- * 解除会话标签关系
4883
- */
4884
- encodeDisConversationTag(tagIds: Array<string>): any;
4885
- /**
4886
- * 序列化更新会话标签
4887
- */
4888
- encodeUpdateConversationTag(tags: IConversationTag[], conversations: IConversationOption[]): any;
4889
- /**
4890
- * 序列号上报SDK信息
4891
- */
4892
- encodeReportSDKInfo(info: string): any;
4893
- /**
4894
- * 序列号超级群获取会话参数
4895
- */
4896
- encodeUltraGroup(syncTime: number, isEraseMsgContent: boolean): any;
4897
- /**
4898
- * 设置聊天室关联的rtc房间
4899
- */
4900
- encodebindRTCRoomForChatroom(options: IRTCRoomBindOption): any;
4901
- }
4902
-
4903
- interface IDataChannelWatcher {
4904
- /**
4905
- * 连接状态变更通知
4906
- */
4907
- status: (status: ConnectionStatus) => void;
4908
- /**
4909
- * 业务信令通知
4910
- * @params signal
4911
- * @params ack 当接收到的数据为多端同步消息时,ack 值为 PubAck,否则为 undefined
4912
- */
4913
- signal: (signal: PublishReader, ack?: PubAckReader) => void;
4914
- }
4915
- /**
4916
- * @todo 迁移中的 DataCodec 模块导致数据通道不够独立,与 xhr-polling 通信可能会有耦合,后续需解耦
4917
- * @description
4918
- * 1. 基于 WebSocket 协议建立数据通道,实现数据收发
4919
- * 2. 基于 Protobuf 进行数据编解码
4920
- */
4921
- declare class WebSocketChannel {
4922
- private _runtime;
4923
- private _watcher;
4924
- private logger;
4925
- readonly codec: DataCodec;
4926
- connectedTime: number;
4927
- userId: string;
4928
- sendConnectTime: number;
4929
- private _socket;
4930
- private _pingResolve?;
4931
- /**
4932
- * 本端发送消息时等待接收 PubAck 的 Promise.resolve 函数
4933
- */
4934
- private _messageIds;
4935
- /**
4936
- * 接收多端同步消息时,等待 PubAck 的 Promise.resolve 函数
4937
- */
4938
- private _syncMessageIds;
4939
- constructor(_runtime: IRuntime, _watcher: IDataChannelWatcher, logger: BasicLogger);
4940
- /**
4941
- * 建立连接,连接成功则返回 Websocket 实例,否则返回连接错误码
4942
- * @param appkey
4943
- * @param token
4944
- * @param hosts 服务器地址,不包含协议头,`hostname:port`
4945
- * @param protocol 请求导航数据时使用的网络协议, /ping 与 websocket 需要继续遵循该协议
4946
- * @param apiVersion 需符合 `/\d+(\.\d+){2}/` 规则,对于预发布版本号如 `3.1.0-alpha.1` 需认定为 `3.1.0`
4947
- * @param protocolVer
4948
- */
4949
- connect(appkey: string, token: string, hosts: string[], protocol: 'http' | 'https', apiVersion: string, protocolVer: ConnAckProtocolVer): Promise<ErrorCode>;
4950
- /**
4951
- * 发起连接请求
4952
- */
4953
- private _connect;
4954
- /**
4955
- * 当前累计心跳超时次数
4956
- */
4957
- private _failedCount;
4958
- /**
4959
- * 允许连续 PING 超时次数,次数内不主动关闭连接
4960
- */
4961
- private readonly ALLOW_FAILED_TIMES;
4962
- /**
4963
- * ping定时器
4964
- */
4965
- private _timer;
4966
- private _checkAlive;
4967
- private _onReceiveSignal;
4968
- /**
4969
- * 只发送数据,无需响应
4970
- */
4971
- sendOnly(writer: BaseWriter): void;
4972
- /**
4973
- * 有效值 0 - 65535,超出 65535 位数超长溢出
4974
- */
4975
- private _idCount;
4976
- private _generateMessageId;
4977
- /**
4978
- * @param writer
4979
- * @param pbName 响应数据的 PB 定义
4980
- * @param timeout 超时配置,单位 ms
4981
- */
4982
- send<T>(writer: QueryWriter | PublishWriter, respPBName?: string, option?: any, timeout?: number): Promise<IAsyncRes<T>>;
4983
- /**
4984
- * 关闭数据通道,同时清空监听
4985
- */
4986
- close(): void;
4987
- }
4988
-
4989
4657
  declare type IMessageListnenr = (message: IReceivedMessage, leftCount?: number, hasMore?: boolean) => void;
4990
4658
  declare type IMessagesListnenr = (messages: IReceivedMessage[], leftCount?: number, hasMore?: boolean) => void;
4991
- declare type IConnectionStatusListener = (status: ConnectionStatus) => void;
4659
+ declare type IConnectionStatusListener = (status: RCConnectionStatus | ErrorCode | ConnectionStatus) => void;
4992
4660
  declare type IConversationStateListener = (conversation: IUpdatedConversation[]) => void;
4993
4661
  declare type IChatroomListener = (state: IChatroomListenerData) => void;
4994
4662
  declare type IRTCInnerListener = {
@@ -5005,12 +4673,18 @@ declare type IGroupMessageDeliveredStatusListener = (data: IGroupMessageDeliverS
5005
4673
  interface IWatcher {
5006
4674
  message?: IMessageListnenr;
5007
4675
  batchMessage?: IMessagesListnenr;
5008
- connectionState?: IConnectionStatusListener;
4676
+ /**
4677
+ * 连接状态变更监听
4678
+ * @param status 变更的连接状态
4679
+ * @param code 当连接状态为 `RCConnectionStatus.DISCONNECTED` 或 `RCConnectionStatus.SUSPEND` 时有值
4680
+ */
4681
+ connection?: (status: RCConnectionStatus, code?: ErrorCode) => void;
5009
4682
  conversationState?: IConversationStateListener;
5010
4683
  chatroomState?: IChatroomListener;
5011
4684
  expansion?: IExpansionListener;
5012
4685
  /**
5013
4686
  * 为兼容老版本 RTCLib 与 CallLib 接收消息的方式,新版本消息走插件机制
4687
+ * @deprecated
5014
4688
  */
5015
4689
  rtcInnerWatcher?: IRTCInnerListener;
5016
4690
  /**
@@ -5034,10 +4708,6 @@ interface IWatcher {
5034
4708
  * 群聊消息送达状态通知
5035
4709
  */
5036
4710
  groupMessageDeliveredStatus?: IGroupMessageDeliveredStatusListener;
5037
- onConnecting?: () => void;
5038
- onConnected?: () => void;
5039
- onDisconnect?: (status: ConnectionStatus) => void;
5040
- onSuspend?: (status: ConnectionStatus | ErrorCode) => void;
5041
4711
  readReceiptReceived?: (conversation: IConversationOption, messageUId: string, sentTime: number) => void;
5042
4712
  messageReceiptRequest?: (conversation: IConversationOption, messageUId: string, senderUserId: string) => void;
5043
4713
  messageReceiptResponse?: (conversation: IConversationOption, receivedUserId: string, messageUIdList: string[]) => void;
@@ -5059,10 +4729,6 @@ interface IAPIContextOption {
5059
4729
  * 应用 appkey
5060
4730
  */
5061
4731
  appkey: string;
5062
- /**
5063
- * IMLib 版本号
5064
- */
5065
- apiVersion: string;
5066
4732
  /**
5067
4733
  * 自定义导航地址:
5068
4734
  * 1. 私有云环境下该值为必填项
@@ -5082,10 +4748,6 @@ interface IAPIContextOption {
5082
4748
  * typing状态过期时间
5083
4749
  */
5084
4750
  typingExpireTime?: number;
5085
- /**
5086
- * 是否校验证书,默认为 true
5087
- */
5088
- checkCA?: boolean;
5089
4751
  /**
5090
4752
  * 开启后,SDK 内的 HTTP 请求将由 Electron 主进程内发送。
5091
4753
  * @since 5.6.0
@@ -5186,6 +4848,11 @@ declare class Codec<T> {
5186
4848
  * @param data 待解码数据
5187
4849
  */
5188
4850
  decode(pbname: string, uint8array: Uint8Array): any;
4851
+ /**
4852
+ * protobuf 结构中,int64 类型数据无法直接转为 JS 的 number 数据,需计算获取
4853
+ * @param data
4854
+ */
4855
+ private fixInt64Values;
5189
4856
  }
5190
4857
 
5191
4858
  declare class APIContext {
@@ -5203,19 +4870,10 @@ declare class APIContext {
5203
4870
  */
5204
4871
  private _pluginInstanseMap;
5205
4872
  private readonly _engine;
5206
- /**
5207
- * 核心库版本号,后期与 4.0 IM SDK 版本号保持一致
5208
- */
5209
- readonly coreVersion: string;
5210
4873
  readonly appkey: string;
5211
- readonly apiVersion: string;
5212
4874
  private readonly _options;
5213
4875
  private _versionInfo;
5214
4876
  private _typingInfo;
5215
- /**
5216
- * 内部连接状态标识,为 ture 时不允许调用 reconnect 方法
5217
- */
5218
- private _isInternalConnected;
5219
4877
  /**
5220
4878
  * RTC 相关的编解码模块,用于向前兼容 RTC 旧版本的编解码,
5221
4879
  * 包括向 CppEngine 提供 RTC 业务编解码能力
@@ -5233,21 +4891,23 @@ declare class APIContext {
5233
4891
  * @param options
5234
4892
  */
5235
4893
  install<T, O>(plugin: IPluginGenerator<T, O>, options: O): T | null;
5236
- private _connectionStatus;
5237
- private _canRedirectConnect;
4894
+ private _onConnectionStatusChange;
4895
+ private _processChatrormMessage;
4896
+ private _processChrmMemChangeMessage;
4897
+ private _processTypingStatusMessage;
4898
+ private _processInterceptMessage;
5238
4899
  /**
5239
- * 重定向后,递归调用 connect
5240
- */
5241
- private _handleRedirect;
4900
+ * 消息处理器(v2/v4/next 版本中兼容)
4901
+ * 返回 false | undefined:消息继续向上抛出,true:内部处理或转为事件回调,无需向上抛出
4902
+ */
4903
+ private _compatibleMessageProccessor;
4904
+ private _processReadReceiptMessage;
4905
+ private _processReadReceiptRequestMessage;
4906
+ private _processReadReceiptResponseMessage;
5242
4907
  /**
5243
- * 连接状态变更回调
5244
- * @param message
4908
+ * 消息处理器(imlib-next 中转为事件回调, 无需抛出)
5245
4909
  */
5246
- private _connectionStatusListener;
5247
- _handleConnecting(): void;
5248
- _handleConnected(): void;
5249
- _handleDisconnect(status: ConnectionStatus): void;
5250
- _handleSuspend(status: ConnectionStatus | ErrorCode): void;
4910
+ private _messageProccessor;
5251
4911
  private _messageReceiver;
5252
4912
  _batchMessageReceiver(messages: IReceivedMessage[], leftCount?: number, hasMore?: boolean): void;
5253
4913
  /**
@@ -5320,6 +4980,7 @@ declare class APIContext {
5320
4980
  getCurrentUserId(): string;
5321
4981
  getConnectionStatus(): ConnectionStatus;
5322
4982
  get token(): string;
4983
+ refetchNaviInfo(): IPromiseResult<INaviInfo | null>;
5323
4984
  /**
5324
4985
  * 建立连接,连接失败则抛出异常,连接成功后返回用户 userId,否则返回相应的错误码
5325
4986
  * @param token
@@ -5333,22 +4994,14 @@ declare class APIContext {
5333
4994
  这个字段就是为这种情况加的。
5334
4995
  设置 reconnectKickEnable 为 true 时,SDK 重连的时候发现此时已有别的设备连接成功,不再强行踢出已有设备,而是踢出重连设备。
5335
4996
  */
5336
- connect(token: string, refreshNavi?: boolean, reconnectKickEnable?: boolean, traceId?: string): Promise<IConnectResult>;
5337
- /**
5338
- * 拉取实时配置 web 端需更新 voipCall 字段
5339
- */
5340
- private _pullUserSettings;
4997
+ connect(token: string, reconnectKickEnable: boolean, traceId: string): Promise<IConnectResult>;
5341
4998
  disconnect(): Promise<void>;
5342
4999
  reconnect(reconnectKickEnable?: boolean): Promise<IConnectResult>;
5343
5000
  private _getTokenWithoutNavi;
5344
5001
  /**
5345
5002
  * 获取当前缓存的导航数据
5346
5003
  */
5347
- getInfoFromCache(): INaviInfo | null;
5348
- /**
5349
- * 请求服务导航数据
5350
- */
5351
- reqNaviInfo(refreshNavi: boolean, traceId?: string): IPromiseResult<INaviInfo | null>;
5004
+ getNaviInfoFromCache(): INaviInfo | null;
5352
5005
  private _registerMessageSearchPropsMapping;
5353
5006
  /**
5354
5007
  * 消息注册
@@ -5714,7 +5367,11 @@ declare class APIContext {
5714
5367
  /**
5715
5368
  * 获取所有本地置顶列表
5716
5369
  */
5717
- getTopConversationList(): Promise<IAsyncRes<IBaseConversationInfo[]>>;
5370
+ getTopConversationList(conversationTypes?: ConversationType[], channelId?: string): Promise<IAsyncRes<IReceivedConversation[]>>;
5371
+ /**
5372
+ * 获取未读会话列表
5373
+ */
5374
+ getUnreadConversationList(conversationTypes?: ConversationType[]): Promise<IAsyncRes<IReceivedConversation[]>>;
5718
5375
  getUnreadMentionedCount(conversation: IConversationOption): Promise<IAsyncRes<number>>;
5719
5376
  /**
5720
5377
  * 获取所有群聊会话 @ 消息未读数
@@ -5849,7 +5506,7 @@ declare class APIContext {
5849
5506
  /**
5850
5507
  * 获取本地消息
5851
5508
  */
5852
- getMessage(messageId: number): Promise<IAsyncRes<IReceivedMessage>>;
5509
+ getMessage(messageId: number | string): Promise<IAsyncRes<IReceivedMessage>>;
5853
5510
  /**
5854
5511
  * 设置消息内容
5855
5512
  */
@@ -6003,20 +5660,32 @@ declare class APIContext {
6003
5660
  * SDK设置聊天室关联的rtc房间
6004
5661
  */
6005
5662
  bindRTCRoomForChatroom(option: IRTCRoomBindOption): Promise<ErrorCode>;
5663
+ /**
5664
+ * 设置代理
5665
+ */
5666
+ setProxy(proxy: IProxy | null): IPromiseResult<IProxy>;
5667
+ /**
5668
+ * 获取代理
5669
+ */
5670
+ getProxy(): IPromiseResult<IProxy>;
5671
+ /**
5672
+ * 测试代理
5673
+ */
5674
+ testProxy(proxy: IProxy, testHost: string): Promise<IResponse>;
6006
5675
  }
6007
5676
 
6008
5677
  declare class PluginContext {
6009
5678
  protected readonly _context: APIContext;
6010
5679
  constructor(_context: APIContext);
6011
- /**
6012
- * 重新请求服务导航数据
6013
- */
6014
- refetchNaviInfo(): IPromiseResult<INaviInfo | null>;
6015
5680
  /**
6016
5681
  * 获取 context
6017
5682
  */
6018
5683
  __getContext(): APIContext;
6019
5684
  createCodec<T extends CodecPBMaps>(keymaps: T, pbDesc: string): Codec<T>;
5685
+ /**
5686
+ * 重新请求服务导航数据
5687
+ */
5688
+ refetchNaviInfo(): IPromiseResult<INaviInfo | null>;
6020
5689
  /**
6021
5690
  * 获取当前的导航数据
6022
5691
  */
@@ -6035,9 +5704,10 @@ declare class PluginContext {
6035
5704
  onnavidatachange?(naviInfo: INaviInfo): void;
6036
5705
  /**
6037
5706
  * 接收 IM 连接状态变更通知
6038
- * @param status
5707
+ * @param status 当前连接状态,ConnectionStatus 仅作为向前兼容声明,实际通知只有 RCConnectionStatus 值
5708
+ * @param code 当连接状态为 `RCConnectionStatus.DISCONNECTED` 或 `RCConnectionStatus.SUSPEND` 时有值
6039
5709
  */
6040
- onconnectionstatechange?(status: ConnectionStatus): void;
5710
+ onconnectionstatechange?(status: RCConnectionStatus | ConnectionStatus, code?: ErrorCode): void;
6041
5711
  /**
6042
5712
  * IM 客户端销毁通知
6043
5713
  */
@@ -6314,14 +5984,13 @@ declare const keymaps: CodecPBMaps;
6314
5984
  */
6315
5985
  declare type RTCKeyMaps = typeof keymaps;
6316
5986
 
6317
- interface IEngineWatcher {
5987
+ interface IEngineWatcher extends IConnectionListener {
6318
5988
  /**
6319
5989
  * @param message 消息
6320
5990
  * @param leftCount 参数废弃,值始终为 undefined
6321
5991
  * @param hasMore 消息是否收取结束,需与协议栈配合使用
6322
5992
  */
6323
5993
  batchMessage: (messages: IReceivedMessage[], leftCount?: number, hasMore?: boolean) => void;
6324
- status: (status: ConnectionStatus) => void;
6325
5994
  chatroom: (event: IChatroomListenerData) => void;
6326
5995
  conversation: (event: any) => void;
6327
5996
  expansion: (event: IExpansionListenerData) => void;
@@ -6348,7 +6017,7 @@ interface IEngineWatcher {
6348
6017
  /**
6349
6018
  * 引擎定义
6350
6019
  */
6351
- declare abstract class AEngine implements IEngine {
6020
+ declare abstract class AEngine {
6352
6021
  readonly runtime: IRuntime;
6353
6022
  readonly rtcCodec: Codec<RTCKeyMaps>;
6354
6023
  protected readonly _watcher: IEngineWatcher;
@@ -6359,8 +6028,6 @@ declare abstract class AEngine implements IEngine {
6359
6028
  */
6360
6029
  abstract getConnectedTime(): number;
6361
6030
  protected readonly _appkey: string;
6362
- protected readonly _apiVer: string;
6363
- protected readonly _apiVersion: string;
6364
6031
  private _rtcKVManager;
6365
6032
  /**
6366
6033
  * 引擎初始化
@@ -6373,28 +6040,22 @@ declare abstract class AEngine implements IEngine {
6373
6040
  * @param listener
6374
6041
  */
6375
6042
  registerRTCSignalingListener(listener: ((buffer: Uint8Array) => void) | undefined): void;
6376
- abstract requestNaviInfo(uris: string[], appkey: string, token: string, checkCA?: boolean): Promise<INaviInfo | null>;
6377
6043
  /**
6378
- * 为非 engine 包创建 logger 工具实例
6044
+ * 忽视缓存,重新请求导航数据
6379
6045
  */
6380
- abstract createLogger(id: string, type: LogType): BasicLogger;
6046
+ abstract refetchNaviInfo(): IPromiseResult<INaviInfo | null>;
6381
6047
  /**
6382
- * 获取 engine 包内部 logger 工具
6048
+ * 获取导航缓存数据
6383
6049
  */
6384
- getInnerLogger(): BasicLogger;
6050
+ abstract getNaviInfoFromCache(): INaviInfo | null;
6385
6051
  /**
6386
- * 获取导航数据
6387
- * @param token
6388
- * @param dynamicUris token 携带的动态导航地址
6389
- * @param force 是否强制重新获取并清空缓存数据
6052
+ * 为非 engine 包创建 logger 工具实例
6390
6053
  */
6391
- getNaviInfo(token: string, dynamicUris: string[], force: boolean, checkCA?: boolean): Promise<INaviInfo | null>;
6392
- protected setNaviInfo2Cache(token: string, naviInfo: INaviInfo): void;
6393
- abstract getNaviInfoFromCache(): INaviInfo | null;
6054
+ abstract createLogger(id: string, type: LogType): BasicLogger;
6394
6055
  /**
6395
- * 清空导航数据:内存数据、缓存数据
6056
+ * 获取 engine 包内部 logger 工具
6396
6057
  */
6397
- private _clear;
6058
+ getInnerLogger(): BasicLogger;
6398
6059
  /**
6399
6060
  * 调用非标准方法。所谓非标准方法,是为某些特定需求或产品添加,暂未作为标准接口添加至 API 层。
6400
6061
  * 对于未实现的方法,接口响应 Unsupport 错误码
@@ -6405,10 +6066,10 @@ declare abstract class AEngine implements IEngine {
6405
6066
  /**
6406
6067
  * 建立连接
6407
6068
  * @param token
6408
- * @param naviInfo
6409
6069
  * @param reconnectKickEnable
6070
+ * @param traceId
6410
6071
  */
6411
- abstract connect(token: string, naviInfo: INaviInfo, reconnectKickEnable?: boolean, traceId?: string): Promise<ErrorCode>;
6072
+ abstract connect(token: string, reconnectKickEnable: boolean, traceId: string): IPromiseResult<string>;
6412
6073
  /**
6413
6074
  * 发送SDK版本
6414
6075
  * @param versionInfo
@@ -6518,6 +6179,10 @@ declare abstract class AEngine implements IEngine {
6518
6179
  * 获取指定会话
6519
6180
  */
6520
6181
  abstract getConversation(conversationType: ConversationType, targetId: string, channelId: string): IPromiseResult<IReceivedConversation | null>;
6182
+ /**
6183
+ * 获取未读会话列表
6184
+ */
6185
+ abstract getUnreadConversationList(conversationTypes: ConversationType[]): IPromiseResult<IReceivedConversation[]>;
6521
6186
  /**
6522
6187
  * 删除会话
6523
6188
  * @description 该删除操作会删除服务器端存储的会话数据
@@ -6594,11 +6259,15 @@ declare abstract class AEngine implements IEngine {
6594
6259
  /**
6595
6260
  * 断开连接
6596
6261
  */
6597
- abstract disconnect(): void;
6262
+ abstract disconnect(): Promise<void>;
6598
6263
  /**
6599
6264
  * 拉取用户级配置数据
6600
6265
  */
6601
6266
  abstract pullUserSettings(version: number): IPromiseResult<IServerUserSetting>;
6267
+ /**
6268
+ * 获取当前连接状态
6269
+ */
6270
+ abstract getConnectionStatus(): RCConnectionStatus;
6602
6271
  /**
6603
6272
  * 消息注册
6604
6273
  * @description
@@ -6909,7 +6578,7 @@ declare abstract class AEngine implements IEngine {
6909
6578
  /**
6910
6579
  * 获取消息
6911
6580
  */
6912
- abstract getMessage(messageId: number): IPromiseResult<IReceivedMessage>;
6581
+ abstract getMessage(messageId: number | string): IPromiseResult<IReceivedMessage>;
6913
6582
  /**
6914
6583
  * 设置消息内容
6915
6584
  */
@@ -7014,7 +6683,7 @@ declare abstract class AEngine implements IEngine {
7014
6683
  /**
7015
6684
  * 无差别获取本地置顶列表
7016
6685
  */
7017
- abstract getTopConversationList(): Promise<IAsyncRes<IBaseConversationInfo[]>>;
6686
+ abstract getTopConversationList(conversationTypes: ConversationType[], channelId?: string): Promise<IAsyncRes<IReceivedConversation[]>>;
7018
6687
  /**
7019
6688
  * 获取单个群聊会话 @ 消息未读数
7020
6689
  */
@@ -7118,6 +6787,18 @@ declare abstract class AEngine implements IEngine {
7118
6787
  * Engine 反初始化
7119
6788
  */
7120
6789
  destroy(): void;
6790
+ /**
6791
+ * 设置代理
6792
+ */
6793
+ abstract setProxy(proxy: IProxy | null): IPromiseResult<IProxy>;
6794
+ /**
6795
+ * 获取代理
6796
+ */
6797
+ abstract getProxy(): IPromiseResult<IProxy>;
6798
+ /**
6799
+ * 测试代理
6800
+ */
6801
+ abstract testProxy(proxy: IProxy, testHost: string): Promise<IResponse>;
7121
6802
  }
7122
6803
 
7123
6804
  declare class AppStorage {
@@ -7262,6 +6943,7 @@ declare const notEmptyObject: (val: Object) => boolean;
7262
6943
  declare const isValidConversationType: (conversation: number) => boolean;
7263
6944
  declare const isValidNotificationLevel: (level: number) => boolean;
7264
6945
  declare const isValidChannelId: (value: any) => boolean;
6946
+ declare const isTypeInConversationList: (type: number) => boolean;
7265
6947
  /**
7266
6948
  * 判断是否是一个有效的文件类型
7267
6949
  */
@@ -7292,31 +6974,31 @@ declare function ID(): string;
7292
6974
  /**
7293
6975
  * @deprecated
7294
6976
  */
7295
- declare function init(userLogInfo: ILogInit): void;
6977
+ declare function init(userLogInfo: any): void;
7296
6978
  /**
7297
6979
  * @deprecated
7298
6980
  */
7299
- declare function log(logLevel: LogLevel, tagId: LogTagId | string, logObj?: Object, logExtens?: ILogExtensions): void;
6981
+ declare function log(logLevel: LogLevel, tagId: LogTagId | string, logObj?: Object, logExtens?: any): void;
7300
6982
  /**
7301
6983
  * @deprecated
7302
6984
  */
7303
- declare const debug: (tagId: string, logObj?: Object | undefined, logExtens?: ILogExtensions | undefined) => void;
6985
+ declare const debug: (tagId: string, logObj?: Object | undefined, logExtens?: any) => void;
7304
6986
  /**
7305
6987
  * @deprecated
7306
6988
  */
7307
- declare const info: (tagId: string, logObj?: Object | undefined, logExtens?: ILogExtensions | undefined) => void;
6989
+ declare const info: (tagId: string, logObj?: Object | undefined, logExtens?: any) => void;
7308
6990
  /**
7309
6991
  * @deprecated
7310
6992
  */
7311
- declare const warn: (tagId: string, logObj?: Object | undefined, logExtens?: ILogExtensions | undefined) => void;
6993
+ declare const warn: (tagId: string, logObj?: Object | undefined, logExtens?: any) => void;
7312
6994
  /**
7313
6995
  * @deprecated
7314
6996
  */
7315
- declare const error: (tagId: string, logObj?: Object | undefined, logExtens?: ILogExtensions | undefined) => void;
6997
+ declare const error: (tagId: string, logObj?: Object | undefined, logExtens?: any) => void;
7316
6998
  /**
7317
6999
  * @deprecated
7318
7000
  */
7319
- declare const fatal: (tagId: string, logObj?: Object | undefined, logExtens?: ILogExtensions | undefined) => void;
7001
+ declare const fatal: (tagId: string, logObj?: Object | undefined, logExtens?: any) => void;
7320
7002
 
7321
7003
  declare const base_logLevelTransformer: typeof logLevelTransformer;
7322
7004
  declare const base_ID: typeof ID;
@@ -7553,11 +7235,6 @@ declare const getBrowser: (runtime: IRuntime) => {
7553
7235
  type: any;
7554
7236
  version: any;
7555
7237
  };
7556
- /**
7557
- * 将连接时服务端返回码转换成业务响应码
7558
- * @param code 连接响应码
7559
- */
7560
- declare const formatConnectResponseCode: (code: number) => ErrorCode;
7561
7238
  declare const clone: (target: any) => any;
7562
7239
 
7563
7240
  /**
@@ -7647,6 +7324,12 @@ declare const DB_LOG_FLUSH_FREQUENCY = 3000;
7647
7324
  declare const ONE_LOG_SIZE_MAX = 1000;
7648
7325
  /** 日志上报域名 */
7649
7326
  declare const LOG_REPORT_URI = "logcollection.ronghub.com";
7327
+ /** SDK 版本号 */
7328
+ declare const VERSION: string;
7329
+ /**
7330
+ * 祛除标签的标准版本号,如愿版本号为 `3.1.0-alpha.1`,则该值为 `3.1.0`
7331
+ */
7332
+ declare const FORMATED_VERSION: string;
7650
7333
 
7651
7334
  /**
7652
7335
  * 请使用 `Codec` 替代 `AbsCodec`
@@ -7655,8 +7338,9 @@ declare const LOG_REPORT_URI = "logcollection.ronghub.com";
7655
7338
  declare type AbsCodec<T> = Codec<T>;
7656
7339
 
7657
7340
  /**
7341
+ * @deprecated
7658
7342
  * engine 版本号
7659
7343
  */
7660
7344
  declare const version: string;
7661
7345
 
7662
- export { AEngine, APIContext, AbsCodec, AppStorage, AssertRules, BasicLogger, BasicReporter, CPP_PROTOCAL_MSGTYPE_OPTION, CallLibMsgType, ChatroomEntryType, ChatroomUserChangeType, Codec, CodecPBMaps, ConnectResultCode, ConnectionStatus, ConversationType, DB_LOG_FLUSH_FREQUENCY, DB_LOG_MAX_SIZE, DelayTimer, EnableLogL, ErrorCode, EventEmitter, FileType, HTTP_TIMEOUT, HttpMethod, IAPIContextOption, IAndroidPushConfig, IAsyncRes, IBaseConversationInfo, IBigdataLogInit, IBlockedMessageInfo, ICancelRoomPKOptions, IChatRoomEntries, IChatRoomEntry, IChatroomEntries, IChatroomEntry, IChatroomEntryListenerData, IChatroomInfo, IChatroomListener, IChatroomListenerData, IChatroomRejoinedFailed, IChatroomRejoinedInfo, IChatroomRejoinedSuccessed, IChatroomUser, IChatroomUserChangeInfo, IChrmKVEntries, IChrmKVEntry, IConnectResult, IConnectionStatusListener, IConversationOption, IConversationState, IConversationStateListener, IConversationTag, IConversationTagListener, IDeletedExpansion, IDeliveredUser, IEndRoomPKOptions, IEngine, IEngineWatcher, IEventListener, IExpansionListener, IExpansionListenerData, IExpansionMsgContent, IExtraMethod, IGetMsgOption, IGetUltraGroupListOption, IGooglePushConfig, IGroupMessageDeliverInfo, IGroupMessageDeliverStatus, IInitBigDataOption, IInsertMsgOptions, IIsValidExpansion, IJoinRTCRoomData, ILocalReadReceiptInfo, ILocalTagStatus, ILogDB, ILogData, ILogExtensions, ILogInfo, ILogInit, ILogger, IM_CHATROOM_PULL_INTERVAL_TIME, IM_PING_INTERVAL_TIME, IM_PING_MIN_TIMEOUT, IM_PING_TIMEOUT, IM_SIGNAL_TIMEOUT, IMessageDeliver, IMessageDeliveredListener, IMessageListnenr, IMessageReader, IMessageReaderResponse, IMetionedData, INaviInfo, IOSInfo, IOperateStatusNotify, IPluginGenerator, IProcessInfo, IPromiseResult, IPushConfig, IRTCInnerListener, IRTCJoinedInfo, IRTCRoomBindOption, IRTCRoomInfo, IRTCUserData, IRTCUsers, IReadReceiptInfo, IRealTimeLog, IRecallMsgContent, IRecallMsgOptions, IReceivedConversation, IReceivedConversationByTag, IReceivedMessage, IRemoveChatRoomEntries, IRemoveChatRoomEntry, IRemoveChatroomEntries, IRemoveChatroomEntry, IReqRoomPKOptions, IRequest, IResRoomPKOptions, IResponse, IRtcTokenData, IRuntime, ISendExMsgOptions, ISendMsgOptions, IServerConversationStatus, IServerRTCRoomEntry, IServerUserSetting, ISetConversationStatusOptions, IStorage, ITagInfo, ITagListener, ITagParam, ITagStatus, ITypingInfo, ITypingMessage, ITypingUser, IUltraChannelChangeInfo, IUltraChannelDeleteInfo, IUltraChannelUserKickedInfo, IUltraExMsgOptions, IUltraGroupConversation, IUltraGroupOption, IUltraGroupUnreadMentionedOption, IUltraModifyMsgOptions, IUltraMsgQueryOptions, IUltraUnreadConversation, IUltraUnreadMsg, IUpdatedConversation, IUpdatedExpansion, IUploadAuth, IUserProfile, IWatcher, IWebSocket, IiOSPushConfig, IndexDBLogger, IndexDBReporter, RTCKeyMaps as InnerRTCKeyMaps, ItypingStateListener, KVString, LOG_REPORT_URI, LiveRole, LiveType, LogContent, LogL, LogLevel, LogSource, LogTagId, LogType, Logger, MAX_MESSAGE_CONTENT_BYTES, MAX_MESSAGE_EXPANSION_KEY_LENGTH, MAX_MESSAGE_EXPANSION_VAL_LENGTH, MINI_SOCKET_CONNECT_URIS, MentionedType, MessageBlockSourceType, MessageBlockType, MessageDirection, MessageType, NAVI_CACHE_DURATION, NAVI_REQ_TIMEOUT, NetworkType, NotificationLevel, NotificationStatus, ONE_LOG_SIZE_MAX, OperateStatus, PUBLIC_CLOUD_NAVI_URIS, PluginContext, RCAssertError, REAT_TIME_LOG_SIZE, RTCApiType, RTCIdentityChangeType, RTCJoinType, RTCMode, RTCPluginContext, ReceivedStatus, SEND_MESSAGE_TYPE_OPTION, STATUS_MESSAGE, STORAGE_ROOT_KEY, StoreKeys, TagChangeType, UltraGroupChannelChangeType, UltraGroupChannelType, UltraMsgChangeType, UltraMsgSubChangeType, UploadMethod, VersionManage, WEB_SOCKET_TIMEOUT, WebSocketChannel, appendUrl, assert, clone, cloneByJSON, deInitLogDB, logger as engineLogger, forEach, formatConnectResponseCode, getBrowser, getClientMessageId, getMimeKey, getUUID, getUUID22, getUploadFileName, indexOf, initLogDB, isArray, isArrayBuffer, isBoolean, isFunction, isHttpUrl, isInObject, isInclude, isNull, isNumber, isObject, isString, isUndefined, isValidChannelId, isValidChrmEntryKey, isValidChrmEntryValue, isValidConversationType, isValidExpansion, isValidFileType, isValidNotificationLevel, base as logger, map, notEmptyArray, notEmptyObject, notEmptyString, pushConfigsToJSON, pushJSONToConfigs, todo, transcsv, usingCppEngine, validate, version };
7346
+ export { AConnectionMgr, AEngine, APIContext, AbsCodec, AppStorage, AssertRules, BasicLogger, BasicNavi, BasicReporter, CPP_PROTOCAL_MSGTYPE_OPTION, CallLibMsgType, ChatroomEntryType, ChatroomUserChangeType, Codec, CodecPBMaps, ConnectionStatus, ConversationType, DB_LOG_FLUSH_FREQUENCY, DB_LOG_MAX_SIZE, DelayTimer, EnableLogL, ErrorCode, EventEmitter, FORMATED_VERSION, FileType, HTTP_TIMEOUT, HttpMethod, IAPIContextOption, IAndroidPushConfig, IAsyncRes, IBaseConversationInfo, IBlockedMessageInfo, ICancelRoomPKOptions, IChatRoomEntries, IChatRoomEntry, IChatroomEntries, IChatroomEntry, IChatroomEntryListenerData, IChatroomInfo, IChatroomListener, IChatroomListenerData, IChatroomRejoinedFailed, IChatroomRejoinedInfo, IChatroomRejoinedSuccessed, IChatroomUser, IChatroomUserChangeInfo, IChrmKVEntries, IChrmKVEntry, IConnectResult, IConnectionListener, IConnectionStatusListener, IConversationOption, IConversationState, IConversationStateListener, IConversationTag, IConversationTagListener, IDeletedExpansion, IDeliveredUser, IEndRoomPKOptions, IEngine, IEngineWatcher, IEventListener, IExpansionListener, IExpansionListenerData, IExpansionMsgContent, IExtraMethod, IGetMsgOption, IGetUltraGroupListOption, IGooglePushConfig, IGroupMessageDeliverInfo, IGroupMessageDeliverStatus, IGroupMessageDeliveredStatusInfo, IInsertMsgOptions, IIsValidExpansion, IJoinRTCRoomData, ILocalReadReceiptInfo, ILocalTagStatus, ILogDB, ILogData, ILogger, IM_CHATROOM_PULL_INTERVAL_TIME, IM_PING_INTERVAL_TIME, IM_PING_MIN_TIMEOUT, IM_PING_TIMEOUT, IM_SIGNAL_TIMEOUT, IMessageDeliver, IMessageDeliveredListener, IMessageListnenr, IMessageReader, IMessageReaderResponse, IMetionedData, INaviCache, INaviInfo, IOSInfo, IOperateInfo, IOperateStatusNotify, IOperateSummary, IPluginGenerator, IProcessCache, IProcessInfo, IPromiseResult, IProxy, IPushConfig, IRTCInnerListener, IRTCJoinedInfo, IRTCRoomBindOption, IRTCRoomInfo, IRTCUserData, IRTCUsers, IReadReceiptInfo, IRecallMsgContent, IRecallMsgOptions, IReceivedConversation, IReceivedConversationByTag, IReceivedMessage, IRemoveChatRoomEntries, IRemoveChatRoomEntry, IRemoveChatroomEntries, IRemoveChatroomEntry, IReqRoomPKOptions, IRequest, IResRoomPKOptions, IResponse, IRtcTokenData, IRuntime, ISendExMsgOptions, ISendMsgOptions, IServerConversationStatus, IServerRTCRoomEntry, IServerUserSetting, ISetConversationStatusOptions, IStorage, ITagInfo, ITagListener, ITagParam, ITagStatus, ITypingInfo, ITypingMessage, ITypingUser, IUltraChannelChangeInfo, IUltraChannelDeleteInfo, IUltraChannelUserKickedInfo, IUltraExMsgOptions, IUltraGroupConversation, IUltraGroupOption, IUltraGroupUnreadMentionedOption, IUltraModifyMsgOptions, IUltraMsgQueryOptions, IUltraUnreadConversation, IUltraUnreadMsg, IUpdatedConversation, IUpdatedExpansion, IUploadAuth, IUserProfile, IWatcher, IWebSocket, IiOSPushConfig, IndexDBLogger, IndexDBReporter, RTCKeyMaps as InnerRTCKeyMaps, ItypingStateListener, KVString, LOG_REPORT_URI, LiveRole, LiveType, LogContent, LogL, LogLevel, LogSource, LogTagId, LogType, Logger, MAX_MESSAGE_CONTENT_BYTES, MAX_MESSAGE_EXPANSION_KEY_LENGTH, MAX_MESSAGE_EXPANSION_VAL_LENGTH, MINI_SOCKET_CONNECT_URIS, MentionedType, MessageBlockSourceType, MessageBlockType, MessageDirection, MessageType, NAVI_CACHE_DURATION, NAVI_REQ_TIMEOUT, NetworkType, NotificationLevel, NotificationStatus, ONE_LOG_SIZE_MAX, OperateStatus, PUBLIC_CLOUD_NAVI_URIS, PluginContext, RCAssertError, RCConnectionStatus, REAT_TIME_LOG_SIZE, RTCApiType, RTCIdentityChangeType, RTCJoinType, RTCMode, RTCPluginContext, ReceivedStatus, SEND_MESSAGE_TYPE_OPTION, STATUS_MESSAGE, STORAGE_ROOT_KEY, StoreKeys, TagChangeType, UltraGroupChannelChangeType, UltraGroupChannelType, UltraMsgChangeType, UltraMsgSubChangeType, UploadMethod, VERSION, VersionManage, WEB_SOCKET_TIMEOUT, WebSocketNavi, appendUrl, assert, clone, cloneByJSON, deInitLogDB, logger as engineLogger, forEach, getBrowser, getClientMessageId, getMimeKey, getUUID, getUUID22, getUploadFileName, indexOf, initLogDB, isArray, isArrayBuffer, isBoolean, isConnnectAckCode as isConnnectAck, isDisconnectCode as isDisconnectedByServer, isFunction, isHttpUrl, isInObject, isInclude, isNull, isNumber, isObject, isString, isTypeInConversationList, isUndefined, isValidChannelId, isValidChrmEntryKey, isValidChrmEntryValue, isValidConversationType, isValidExpansion, isValidFileType, isValidNotificationLevel, base as logger, map, notEmptyArray, notEmptyObject, notEmptyString, pushConfigsToJSON, pushJSONToConfigs, todo, transcsv, usingCppEngine, validate, version };