node-nim 9.14.3 → 10.2.0

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 (182) hide show
  1. package/README.md +7 -1
  2. package/dist/loader.js +35 -35
  3. package/dist/nim/client.js +184 -184
  4. package/dist/nim/client.js.map +1 -1
  5. package/dist/nim/data_sync.js +19 -19
  6. package/dist/nim/friend.js +150 -150
  7. package/dist/nim/global.js +131 -131
  8. package/dist/nim/msglog.js +687 -687
  9. package/dist/nim/nos.js +216 -180
  10. package/dist/nim/nos.js.map +1 -1
  11. package/dist/nim/online_session.js +85 -85
  12. package/dist/nim/pass_through_proxy.js +39 -39
  13. package/dist/nim/plugin.js +65 -65
  14. package/dist/nim/session.js +392 -392
  15. package/dist/nim/subscribe_event.js +142 -142
  16. package/dist/nim/super_team.js +592 -615
  17. package/dist/nim/super_team.js.map +1 -1
  18. package/dist/nim/sysmsg.js +194 -194
  19. package/dist/nim/talk.js +209 -209
  20. package/dist/nim/talk.js.map +1 -1
  21. package/dist/nim/talkex.js +191 -191
  22. package/dist/nim/team.js +818 -830
  23. package/dist/nim/team.js.map +1 -1
  24. package/dist/nim/tool.js +119 -119
  25. package/dist/nim/user.js +201 -201
  26. package/dist/nim_def/client_def.js +245 -245
  27. package/dist/nim_def/client_def.js.map +1 -1
  28. package/dist/nim_def/data_sync_def.js +20 -20
  29. package/dist/nim_def/doc_trans_def.js +16 -16
  30. package/dist/nim_def/friend_def.js +37 -37
  31. package/dist/nim_def/global_def.js +39 -39
  32. package/dist/nim_def/msglog_def.js +148 -148
  33. package/dist/nim_def/nos_def.js +16 -16
  34. package/dist/nim_def/online_session_def.js +2 -2
  35. package/dist/nim_def/pass_through_proxy_def.js +10 -10
  36. package/dist/nim_def/plugin_def.js +2 -2
  37. package/dist/nim_def/session_def.js +26 -26
  38. package/dist/nim_def/subscribe_event_def.js +52 -52
  39. package/dist/nim_def/super_team_def.js +64 -71
  40. package/dist/nim_def/super_team_def.js.map +1 -1
  41. package/dist/nim_def/sysmsg_def.js +28 -28
  42. package/dist/nim_def/talk_def.js +2 -2
  43. package/dist/nim_def/talkex_def.js +2 -2
  44. package/dist/nim_def/team_def.js +69 -76
  45. package/dist/nim_def/team_def.js.map +1 -1
  46. package/dist/nim_def/tool_def.js +11 -11
  47. package/dist/nim_def/user_def.js +22 -22
  48. package/dist/node-nim.js +171 -171
  49. package/dist/node-nim.js.map +1 -1
  50. package/dist/qchat/attachment.js +63 -63
  51. package/dist/qchat/channel.js +314 -314
  52. package/dist/qchat/channel_category.js +187 -187
  53. package/dist/qchat/instance.js +77 -77
  54. package/dist/qchat/message.js +285 -285
  55. package/dist/qchat/role.js +423 -423
  56. package/dist/qchat/server.js +453 -453
  57. package/dist/qchat/system_notification.js +74 -74
  58. package/dist/qchat_def/attachment_def.js +2 -2
  59. package/dist/qchat_def/channel_def.js +2 -2
  60. package/dist/qchat_def/instance_def.js +2 -2
  61. package/dist/qchat_def/message_def.js +2 -2
  62. package/dist/qchat_def/public_def.js +649 -649
  63. package/dist/qchat_def/public_def.js.map +1 -1
  64. package/dist/qchat_def/role_def.js +2 -2
  65. package/dist/qchat_def/server_def.js +2 -2
  66. package/dist/qchat_def/system_notification_def.js +2 -2
  67. package/dist/v2/v2_nim_chatroom_client.js +135 -0
  68. package/dist/v2/v2_nim_chatroom_client.js.map +1 -0
  69. package/dist/v2/v2_nim_chatroom_service.js +244 -0
  70. package/dist/v2/v2_nim_chatroom_service.js.map +1 -0
  71. package/dist/v2/v2_nim_client.js +138 -0
  72. package/dist/v2/v2_nim_client.js.map +1 -0
  73. package/dist/v2/v2_nim_conversation_group_service.js +116 -0
  74. package/dist/v2/v2_nim_conversation_group_service.js.map +1 -0
  75. package/dist/v2/v2_nim_conversation_service.js +236 -0
  76. package/dist/v2/v2_nim_conversation_service.js.map +1 -0
  77. package/dist/v2/v2_nim_friend_service.js +128 -0
  78. package/dist/v2/v2_nim_friend_service.js.map +1 -0
  79. package/dist/v2/v2_nim_login_service.js +119 -123
  80. package/dist/v2/v2_nim_login_service.js.map +1 -1
  81. package/dist/v2/v2_nim_message_service.js +382 -0
  82. package/dist/v2/v2_nim_message_service.js.map +1 -0
  83. package/dist/v2/v2_nim_notification_service.js +30 -0
  84. package/dist/v2/v2_nim_notification_service.js.map +1 -0
  85. package/dist/v2/v2_nim_setting_service.js +86 -0
  86. package/dist/v2/v2_nim_setting_service.js.map +1 -0
  87. package/dist/v2/v2_nim_storage_service.js +58 -0
  88. package/dist/v2/v2_nim_storage_service.js.map +1 -0
  89. package/dist/v2/v2_nim_team_service.js +360 -0
  90. package/dist/v2/v2_nim_team_service.js.map +1 -0
  91. package/dist/v2/v2_nim_user_service.js +76 -0
  92. package/dist/v2/v2_nim_user_service.js.map +1 -0
  93. package/dist/v2/v2_nim_utilities.js +276 -0
  94. package/dist/v2/v2_nim_utilities.js.map +1 -0
  95. package/dist/v2_def/v2_nim_callback_def.js +2 -2
  96. package/dist/v2_def/v2_nim_enum_def.js +1087 -325
  97. package/dist/v2_def/v2_nim_enum_def.js.map +1 -1
  98. package/dist/v2_def/v2_nim_struct_def.js +2 -2
  99. package/package.json +1 -1
  100. package/script/download-sdk.js +2 -2
  101. package/script/publish-to-netease-npm.js +3 -2
  102. package/types/loader.d.ts +2 -2
  103. package/types/nim/client.d.ts +123 -123
  104. package/types/nim/data_sync.d.ts +12 -12
  105. package/types/nim/friend.d.ts +82 -82
  106. package/types/nim/global.d.ts +69 -69
  107. package/types/nim/msglog.d.ts +392 -392
  108. package/types/nim/nos.d.ts +118 -118
  109. package/types/nim/online_session.d.ts +44 -44
  110. package/types/nim/pass_through_proxy.d.ts +24 -24
  111. package/types/nim/plugin.d.ts +39 -39
  112. package/types/nim/session.d.ts +212 -212
  113. package/types/nim/subscribe_event.d.ts +87 -87
  114. package/types/nim/super_team.d.ts +331 -342
  115. package/types/nim/sysmsg.d.ts +105 -105
  116. package/types/nim/talk.d.ts +94 -94
  117. package/types/nim/talkex.d.ts +95 -95
  118. package/types/nim/team.d.ts +461 -467
  119. package/types/nim/tool.d.ts +77 -77
  120. package/types/nim/user.d.ts +111 -111
  121. package/types/nim_def/client_def.d.ts +284 -284
  122. package/types/nim_def/data_sync_def.d.ts +19 -19
  123. package/types/nim_def/doc_trans_def.d.ts +11 -11
  124. package/types/nim_def/friend_def.d.ts +65 -65
  125. package/types/nim_def/global_def.d.ts +62 -62
  126. package/types/nim_def/msglog_def.d.ts +373 -373
  127. package/types/nim_def/nos_def.d.ts +72 -72
  128. package/types/nim_def/online_session_def.d.ts +34 -34
  129. package/types/nim_def/pass_through_proxy_def.d.ts +13 -13
  130. package/types/nim_def/plugin_def.d.ts +8 -8
  131. package/types/nim_def/session_def.d.ts +114 -114
  132. package/types/nim_def/subscribe_event_def.d.ts +83 -83
  133. package/types/nim_def/super_team_def.d.ts +144 -163
  134. package/types/nim_def/sysmsg_def.d.ts +70 -70
  135. package/types/nim_def/talk_def.d.ts +96 -96
  136. package/types/nim_def/talkex_def.d.ts +112 -112
  137. package/types/nim_def/team_def.d.ts +167 -184
  138. package/types/nim_def/tool_def.d.ts +28 -28
  139. package/types/nim_def/user_def.d.ts +59 -59
  140. package/types/node-nim.d.ts +90 -93
  141. package/types/qchat/attachment.d.ts +40 -40
  142. package/types/qchat/channel.d.ts +139 -139
  143. package/types/qchat/channel_category.d.ts +82 -82
  144. package/types/qchat/instance.d.ts +46 -46
  145. package/types/qchat/message.d.ts +128 -128
  146. package/types/qchat/role.d.ts +166 -166
  147. package/types/qchat/server.d.ts +198 -198
  148. package/types/qchat/system_notification.d.ts +39 -39
  149. package/types/qchat_def/attachment_def.d.ts +71 -71
  150. package/types/qchat_def/channel_def.d.ts +643 -643
  151. package/types/qchat_def/instance_def.d.ts +214 -214
  152. package/types/qchat_def/message_def.d.ts +565 -565
  153. package/types/qchat_def/public_def.d.ts +754 -754
  154. package/types/qchat_def/role_def.d.ts +413 -413
  155. package/types/qchat_def/server_def.d.ts +529 -529
  156. package/types/qchat_def/system_notification_def.d.ts +172 -172
  157. package/types/v2/v2_nim_chatroom_client.d.ts +73 -0
  158. package/types/v2/v2_nim_chatroom_service.d.ts +114 -0
  159. package/types/v2/v2_nim_client.d.ts +75 -0
  160. package/types/v2/v2_nim_conversation_group_service.d.ts +54 -0
  161. package/types/v2/v2_nim_conversation_service.d.ts +110 -0
  162. package/types/v2/v2_nim_friend_service.d.ts +58 -0
  163. package/types/v2/v2_nim_login_service.d.ts +80 -96
  164. package/types/v2/v2_nim_message_service.d.ts +143 -0
  165. package/types/v2/v2_nim_notification_service.d.ts +18 -0
  166. package/types/v2/v2_nim_setting_service.d.ts +43 -0
  167. package/types/v2/v2_nim_storage_service.d.ts +28 -0
  168. package/types/v2/v2_nim_team_service.d.ts +184 -0
  169. package/types/v2/v2_nim_user_service.d.ts +34 -0
  170. package/types/v2/v2_nim_utilities.d.ts +168 -0
  171. package/types/v2_def/v2_nim_callback_def.d.ts +7 -20
  172. package/types/v2_def/v2_nim_enum_def.d.ts +1009 -300
  173. package/types/v2_def/v2_nim_struct_def.d.ts +1539 -338
  174. package/dist/chatroom/chatroom.js +0 -263
  175. package/dist/chatroom/chatroom.js.map +0 -1
  176. package/dist/chatroom_def/chatroom_def.js +0 -120
  177. package/dist/chatroom_def/chatroom_def.js.map +0 -1
  178. package/dist/v2/v2_nim_instance.js +0 -44
  179. package/dist/v2/v2_nim_instance.js.map +0 -1
  180. package/types/chatroom/chatroom.d.ts +0 -55
  181. package/types/chatroom_def/chatroom_def.d.ts +0 -448
  182. package/types/v2/v2_nim_instance.d.ts +0 -25
@@ -1,393 +1,393 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NIMSession = void 0;
7
- const loader_1 = __importDefault(require("../loader"));
8
- const eventemitter3_1 = require("eventemitter3");
9
- class NIMSession extends eventemitter3_1.EventEmitter {
10
- constructor() {
11
- super();
12
- this.session = new loader_1.default.NIMSession({ emit: this.emit.bind(this) });
13
- }
14
- /** 注册全局回调 */
15
- initEventHandlers() {
16
- return this.session.InitEventHandlers();
17
- }
18
- /** 查询置顶会话列表
19
- * @param cb 置顶会话列表查询结果的回调函数
20
- * @return void 无返回值
21
- * @note
22
- * <pre>
23
- * 200:成功
24
- * </pre>
25
- */
26
- queryStickTopSessionList(cb) {
27
- return new Promise((resolve) => {
28
- this.session.QueryStickTopSessionList((rescode, result) => {
29
- if (cb) {
30
- cb(rescode, result);
31
- }
32
- resolve([rescode, result]);
33
- });
34
- });
35
- }
36
- /** 设置置顶会话
37
- * @param session_id 会话id
38
- * @param to_type 会话类型
39
- * @param ext 扩展字段
40
- * @param cb 置顶会话设置结果的回调函数
41
- * @return void 无返回值
42
- * @note
43
- * <pre>
44
- * 200:成功
45
- * </pre>
46
- */
47
- setToStickTopSession(session_id, to_type, ext, cb) {
48
- return new Promise((resolve) => {
49
- this.session.SetToStickTopSession(session_id, to_type, ext, (rescode, result) => {
50
- if (cb) {
51
- cb(rescode, result);
52
- }
53
- resolve([rescode, result]);
54
- });
55
- });
56
- }
57
- /** 更新置顶会话列表
58
- * @param session_id 会话id
59
- * @param to_type 会话类型
60
- * @param ext 扩展字段
61
- * @param cb 更新置顶会话设置结果的回调函数
62
- * @return void 无返回值
63
- * @note
64
- * <pre>
65
- * 200:成功
66
- * </pre>
67
- */
68
- updateToStickTopSession(session_id, to_type, ext, cb) {
69
- return new Promise((resolve) => {
70
- this.session.UpdateToStickTopSession(session_id, to_type, ext, (rescode, result) => {
71
- if (cb) {
72
- cb(rescode, result);
73
- }
74
- resolve([rescode, result]);
75
- });
76
- });
77
- }
78
- /** 取消置顶会话列表
79
- * @param session_id 会话id
80
- * @param to_type 会话类型
81
- * @param cb 取消置顶会话设置结果的回调函数
82
- * @return void 无返回值
83
- * @note
84
- * <pre>
85
- * 200:成功
86
- * </pre>
87
- */
88
- cancelToStickTopSession(session_id, to_type, cb) {
89
- return new Promise((resolve) => {
90
- this.session.CancelToStickTopSession(session_id, to_type, (rescode, session_id, session_type) => {
91
- if (cb) {
92
- cb(rescode, session_id, session_type);
93
- }
94
- resolve([rescode, session_id, session_type]);
95
- });
96
- });
97
- }
98
- /** 查询指定数量的最后会话数据
99
- * @param limit 要返回的最大数量
100
- * @param cb 查询会话列表的回调函数
101
- * @param jsonExtension json扩展参数(备用,目前不需要)
102
- * @return void 无返回值
103
- */
104
- queryLastFewSessionAsync(limit, cb, jsonExtension) {
105
- return new Promise((resolve) => {
106
- this.session.QueryLastFewSessionAsync(limit, (rescode, result) => {
107
- if (cb) {
108
- cb(rescode, result);
109
- }
110
- resolve([rescode, result]);
111
- }, jsonExtension);
112
- });
113
- }
114
- /** 查询会话列表,可指定最后一条会话消息要排除掉的类型(列表)
115
- * @param msg_excluded_type_list 最后一条会话消息要排除掉的类型(列表),如果不排除任何消息,传入空列表
116
- * @param cb 查询会话列表的回调函数
117
- * @param jsonExtension json扩展参数(备用,目前不需要)
118
- * @return void 无返回值
119
- */
120
- queryAllRecentSessionAsync(msg_excluded_type_list, cb, jsonExtension) {
121
- return new Promise((resolve) => {
122
- this.session.QueryAllRecentSessionAsync(msg_excluded_type_list, (rescode, result) => {
123
- if (cb) {
124
- cb(rescode, result);
125
- }
126
- resolve([rescode, result]);
127
- }, jsonExtension);
128
- });
129
- }
130
- /** 删除最近联系人
131
- * @param to_type 会话类型,双人0,群组1 (nim_msglog_def.h)
132
- * @param id 对方的account id或者群组tid。
133
- * @param delete_roaming 是否同时删除漫游消息
134
- * @param cb 最近会话列表项变更的回调函数
135
- * @return boolean 检查参数如果不符合要求则返回失败
136
- * @note
137
- * <pre>
138
- * 200:成功
139
- * </pre>
140
- */
141
- deleteRecentSession(type, id, cb, delete_roaming) {
142
- return new Promise((resolve) => {
143
- this.session.DeleteRecentSession(type, id, (rescode, session_data, count) => {
144
- if (cb) {
145
- cb(rescode, session_data, count);
146
- }
147
- resolve([rescode, session_data, count]);
148
- }, delete_roaming);
149
- });
150
- }
151
- /** 删除全部最近联系人
152
- * @param jsonExtension json扩展参数(备用,目前不需要)
153
- * @param cb 最近会话列表项变更的回调函数
154
- * @return void 无返回值
155
- * @note
156
- * <pre>
157
- * 200:成功
158
- * </pre>
159
- */
160
- deleteAllRecentSession(cb, jsonExtension) {
161
- return new Promise((resolve) => {
162
- this.session.DeleteAllRecentSession((rescode, session_data, count) => {
163
- if (cb) {
164
- cb(rescode, session_data, count);
165
- }
166
- resolve([rescode, session_data, count]);
167
- }, jsonExtension);
168
- });
169
- }
170
- /** 删除某会话的漫游消息
171
- * @param to_type 会话类型,双人0,群组1 (nim_msglog_def.h)
172
- * @param id 对方的account id或者群组tid。
173
- * @param jsonExtension json扩展参数(备用,目前不需要)
174
- * @param cb 删除结果 回调回调函数
175
- * @return boolean 检查参数如果不符合要求则返回失败
176
- * @note
177
- * <pre>
178
- * 200:成功
179
- * </pre>
180
- */
181
- deleteSessionRoamingMessage(to_type, session_id, cb, ext) {
182
- return new Promise((resolve) => {
183
- this.session.DeleteSessionRoamingMessage(to_type, session_id, (rescode, to_type, session_id) => {
184
- if (cb) {
185
- cb(rescode, to_type, session_id);
186
- }
187
- resolve([rescode, to_type, session_id]);
188
- }, ext);
189
- });
190
- }
191
- /** 最近联系人项未读数清零
192
- * @param to_type 会话类型,双人0,群组1 (nim_msglog_def.h)
193
- * @param id 对方的account id或者群组tid。
194
- * @param jsonExtension json扩展参数(备用,目前不需要)
195
- * @param cb 最近会话列表项变更的回调函数
196
- * @return boolean 检查参数如果不符合要求则返回失败
197
- * @note
198
- * <pre>
199
- * 200:成功
200
- * </pre>
201
- */
202
- setUnreadCountZeroAsync(type, id, cb, jsonExtension) {
203
- return new Promise((resolve) => {
204
- if (!this.session.SetUnreadCountZeroAsync(type, id, (rescode, session_data, count) => {
205
- if (cb) {
206
- cb(rescode, session_data, count);
207
- }
208
- resolve([rescode, session_data, count]);
209
- }, jsonExtension)) {
210
- resolve(null);
211
- }
212
- });
213
- }
214
- /** 最近联系人项未读数清零
215
- * @param is_super_team 会话列表中的会话是否是超大群会话
216
- * @param zero_list 清零的会话信息列表。
217
- * @param cb 最近会话列表项变更的回调函数
218
- * @return boolean 检查参数如果不符合要求则返回失败
219
- * @note
220
- * <pre>
221
- * 200:成功
222
- * </pre>
223
- */
224
- setMultiUnreadCountZeroAsync(is_super_team, zero_list, cb) {
225
- return new Promise((resolve) => {
226
- if (!this.session.SetMultiUnreadCountZeroAsync(is_super_team, zero_list, (rescode, data_list, unread_count) => {
227
- if (cb) {
228
- cb(rescode, data_list, unread_count);
229
- }
230
- resolve([rescode, data_list, unread_count]);
231
- })) {
232
- resolve(null);
233
- }
234
- });
235
- }
236
- /** 设置会话项是否置顶(置顶属性只保存在本地)
237
- * @param to_type 会话类型
238
- * @param id 对方的account id或者群组tid。
239
- * @param top true - 置顶 false - 取消置顶
240
- * @param cb 回调函数
241
- * @param jsonExtension json扩展参数(备用,目前不需要)
242
- * @return boolean 检查参数如果不符合要求则返回失败
243
- * @note
244
- * <pre>
245
- * 200:成功
246
- * </pre>
247
- */
248
- setSessionTop(type, id, top, cb, jsonExtension) {
249
- return new Promise((resolve) => {
250
- if (!this.session.SetSessionTop(type, id, top, (rescode, session_data, count) => {
251
- if (cb) {
252
- cb(rescode, session_data, count);
253
- }
254
- resolve([rescode, session_data, count]);
255
- }, jsonExtension)) {
256
- resolve(null);
257
- }
258
- });
259
- }
260
- /** 设置会话项扩展数据(扩展数据只保存在本地)
261
- * @param to_type 会话类型
262
- * @param id 对方的account id或者群组tid。
263
- * @param data 扩展数据,建议使用灵活可扩展的数据结构,例如Json
264
- * @param cb 回调函数
265
- * @param jsonExtension json扩展参数(备用,目前不需要)
266
- * @return boolean 检查参数如果不符合要求则返回失败
267
- * @note
268
- * <pre>
269
- * 200:成功
270
- * </pre>
271
- */
272
- setSessionExtendData(type, id, data, cb, jsonExtension) {
273
- return new Promise((resolve) => {
274
- if (!this.session.SetSessionExtendData(type, id, data, (rescode, session_data, count) => {
275
- if (cb) {
276
- cb(rescode, session_data, count);
277
- }
278
- resolve([rescode, session_data, count]);
279
- }, jsonExtension)) {
280
- resolve(null);
281
- }
282
- });
283
- }
284
- /** 最近联系人项全部未读数清零
285
- * @param jsonExtension json扩展参数(备用,目前不需要)
286
- * @param cb 最近会话列表项变更的回调函数
287
- * @return boolean 检查参数如果不符合要求则返回失败
288
- * @note
289
- * <pre>
290
- * 200:成功
291
- * </pre>
292
- */
293
- setAllUnreadCountZeroAsync(cb, jsonExtension) {
294
- return new Promise((resolve) => {
295
- if (!this.session.SetAllUnreadCountZeroAsync((rescode, session_data, count) => {
296
- if (cb) {
297
- cb(rescode, session_data, count);
298
- }
299
- resolve([rescode, session_data, count]);
300
- }, jsonExtension)) {
301
- resolve(null);
302
- }
303
- });
304
- }
305
- /** 根据给定的id查询相应会话的信息
306
- * @param to_type 会话类型
307
- * @param id 对方的account id或者群组tid。
308
- * @param cb 会话信息查询结果的回调函数
309
- * @param jsonExtension json扩展参数(备用,目前不需要)
310
- * @return void 无返回值
311
- * @note
312
- * <pre>
313
- * 200:成功
314
- * </pre>
315
- */
316
- querySessionDataById(type, id, cb, jsonExtension) {
317
- return new Promise((resolve) => {
318
- this.session.QuerySessionDataById(type, id, (rescode, session_data) => {
319
- if (cb) {
320
- cb(rescode, session_data);
321
- }
322
- resolve([rescode, session_data]);
323
- }, jsonExtension);
324
- });
325
- }
326
- /** 查询会话是漫游消息未拉取信息
327
- * @param session_id 会话id
328
- * @param to_type 会话类型
329
- * @param cb 查询会话是漫游消息未拉取信息回调函数
330
- * @return void 无返回值
331
- * @note
332
- * <pre>
333
- * 200:成功
334
- * </pre>
335
- */
336
- queryHasmoreRoammsg(session_id, to_type, cb) {
337
- return new Promise((resolve) => {
338
- this.session.QueryHasmoreRoammsg(session_id, to_type, (rescode, info) => {
339
- if (cb) {
340
- cb(rescode, info);
341
- }
342
- resolve([rescode, info]);
343
- });
344
- });
345
- }
346
- /** 查询所有漫游消息未拉取完全的会话
347
- * @param cb 结果回调
348
- * @return void 无返回值
349
- */
350
- queryAllHasmoreRoammsg(cb) {
351
- return new Promise((resolve) => {
352
- this.session.QueryAllHasmoreRoammsg((rescode, infos) => {
353
- if (cb) {
354
- cb(rescode, infos);
355
- }
356
- resolve([rescode, infos]);
357
- });
358
- });
359
- }
360
- /** 更新会话是漫游消息未拉取信息
361
- * @param msg 对应的消息内容
362
- * @param cb 结果回调
363
- * @return void 无返回值
364
- */
365
- updateHasmoreRoammsg(msg, cb) {
366
- return new Promise((resolve) => {
367
- this.session.UpdateHasmoreRoammsg(msg, (rescode) => {
368
- if (cb) {
369
- cb(rescode);
370
- }
371
- resolve([rescode]);
372
- });
373
- });
374
- }
375
- /** 删除会话是漫游消息未拉取信息
376
- * @param session_id 会话id
377
- * @param to_type 会话类型
378
- * @param cb 结果回调
379
- * @return void 无返回值
380
- */
381
- deleteHasmoreRoammsg(session_id, to_type, cb) {
382
- return new Promise((resolve) => {
383
- this.session.DeleteHasmoreRoammsg(session_id, to_type, (rescode) => {
384
- if (cb) {
385
- cb(rescode);
386
- }
387
- resolve([rescode]);
388
- });
389
- });
390
- }
391
- }
392
- exports.NIMSession = NIMSession;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NIMSession = void 0;
7
+ const loader_1 = __importDefault(require("../loader"));
8
+ const eventemitter3_1 = require("eventemitter3");
9
+ class NIMSession extends eventemitter3_1.EventEmitter {
10
+ constructor() {
11
+ super();
12
+ this.session = new loader_1.default.NIMSession({ emit: this.emit.bind(this) });
13
+ }
14
+ /** 注册全局回调 */
15
+ initEventHandlers() {
16
+ return this.session.InitEventHandlers();
17
+ }
18
+ /** 查询置顶会话列表
19
+ * @param cb 置顶会话列表查询结果的回调函数
20
+ * @return void 无返回值
21
+ * @note
22
+ * <pre>
23
+ * 200:成功
24
+ * </pre>
25
+ */
26
+ queryStickTopSessionList(cb) {
27
+ return new Promise((resolve) => {
28
+ this.session.QueryStickTopSessionList((rescode, result) => {
29
+ if (cb) {
30
+ cb(rescode, result);
31
+ }
32
+ resolve([rescode, result]);
33
+ });
34
+ });
35
+ }
36
+ /** 设置置顶会话
37
+ * @param session_id 会话id
38
+ * @param to_type 会话类型
39
+ * @param ext 扩展字段
40
+ * @param cb 置顶会话设置结果的回调函数
41
+ * @return void 无返回值
42
+ * @note
43
+ * <pre>
44
+ * 200:成功
45
+ * </pre>
46
+ */
47
+ setToStickTopSession(session_id, to_type, ext, cb) {
48
+ return new Promise((resolve) => {
49
+ this.session.SetToStickTopSession(session_id, to_type, ext, (rescode, result) => {
50
+ if (cb) {
51
+ cb(rescode, result);
52
+ }
53
+ resolve([rescode, result]);
54
+ });
55
+ });
56
+ }
57
+ /** 更新置顶会话列表
58
+ * @param session_id 会话id
59
+ * @param to_type 会话类型
60
+ * @param ext 扩展字段
61
+ * @param cb 更新置顶会话设置结果的回调函数
62
+ * @return void 无返回值
63
+ * @note
64
+ * <pre>
65
+ * 200:成功
66
+ * </pre>
67
+ */
68
+ updateToStickTopSession(session_id, to_type, ext, cb) {
69
+ return new Promise((resolve) => {
70
+ this.session.UpdateToStickTopSession(session_id, to_type, ext, (rescode, result) => {
71
+ if (cb) {
72
+ cb(rescode, result);
73
+ }
74
+ resolve([rescode, result]);
75
+ });
76
+ });
77
+ }
78
+ /** 取消置顶会话列表
79
+ * @param session_id 会话id
80
+ * @param to_type 会话类型
81
+ * @param cb 取消置顶会话设置结果的回调函数
82
+ * @return void 无返回值
83
+ * @note
84
+ * <pre>
85
+ * 200:成功
86
+ * </pre>
87
+ */
88
+ cancelToStickTopSession(session_id, to_type, cb) {
89
+ return new Promise((resolve) => {
90
+ this.session.CancelToStickTopSession(session_id, to_type, (rescode, session_id, session_type) => {
91
+ if (cb) {
92
+ cb(rescode, session_id, session_type);
93
+ }
94
+ resolve([rescode, session_id, session_type]);
95
+ });
96
+ });
97
+ }
98
+ /** 查询指定数量的最后会话数据
99
+ * @param limit 要返回的最大数量
100
+ * @param cb 查询会话列表的回调函数
101
+ * @param jsonExtension json扩展参数(备用,目前不需要)
102
+ * @return void 无返回值
103
+ */
104
+ queryLastFewSessionAsync(limit, cb, jsonExtension) {
105
+ return new Promise((resolve) => {
106
+ this.session.QueryLastFewSessionAsync(limit, (rescode, result) => {
107
+ if (cb) {
108
+ cb(rescode, result);
109
+ }
110
+ resolve([rescode, result]);
111
+ }, jsonExtension);
112
+ });
113
+ }
114
+ /** 查询会话列表,可指定最后一条会话消息要排除掉的类型(列表)
115
+ * @param msg_excluded_type_list 最后一条会话消息要排除掉的类型(列表),如果不排除任何消息,传入空列表
116
+ * @param cb 查询会话列表的回调函数
117
+ * @param jsonExtension json扩展参数(备用,目前不需要)
118
+ * @return void 无返回值
119
+ */
120
+ queryAllRecentSessionAsync(msg_excluded_type_list, cb, jsonExtension) {
121
+ return new Promise((resolve) => {
122
+ this.session.QueryAllRecentSessionAsync(msg_excluded_type_list, (rescode, result) => {
123
+ if (cb) {
124
+ cb(rescode, result);
125
+ }
126
+ resolve([rescode, result]);
127
+ }, jsonExtension);
128
+ });
129
+ }
130
+ /** 删除最近联系人
131
+ * @param to_type 会话类型,双人0,群组1 (nim_msglog_def.h)
132
+ * @param id 对方的account id或者群组tid。
133
+ * @param delete_roaming 是否同时删除漫游消息
134
+ * @param cb 最近会话列表项变更的回调函数
135
+ * @return boolean 检查参数如果不符合要求则返回失败
136
+ * @note
137
+ * <pre>
138
+ * 200:成功
139
+ * </pre>
140
+ */
141
+ deleteRecentSession(type, id, cb, delete_roaming) {
142
+ return new Promise((resolve) => {
143
+ this.session.DeleteRecentSession(type, id, (rescode, session_data, count) => {
144
+ if (cb) {
145
+ cb(rescode, session_data, count);
146
+ }
147
+ resolve([rescode, session_data, count]);
148
+ }, delete_roaming);
149
+ });
150
+ }
151
+ /** 删除全部最近联系人
152
+ * @param jsonExtension json扩展参数(备用,目前不需要)
153
+ * @param cb 最近会话列表项变更的回调函数
154
+ * @return void 无返回值
155
+ * @note
156
+ * <pre>
157
+ * 200:成功
158
+ * </pre>
159
+ */
160
+ deleteAllRecentSession(cb, jsonExtension) {
161
+ return new Promise((resolve) => {
162
+ this.session.DeleteAllRecentSession((rescode, session_data, count) => {
163
+ if (cb) {
164
+ cb(rescode, session_data, count);
165
+ }
166
+ resolve([rescode, session_data, count]);
167
+ }, jsonExtension);
168
+ });
169
+ }
170
+ /** 删除某会话的漫游消息
171
+ * @param to_type 会话类型,双人0,群组1 (nim_msglog_def.h)
172
+ * @param id 对方的account id或者群组tid。
173
+ * @param jsonExtension json扩展参数(备用,目前不需要)
174
+ * @param cb 删除结果 回调回调函数
175
+ * @return boolean 检查参数如果不符合要求则返回失败
176
+ * @note
177
+ * <pre>
178
+ * 200:成功
179
+ * </pre>
180
+ */
181
+ deleteSessionRoamingMessage(to_type, session_id, cb, ext) {
182
+ return new Promise((resolve) => {
183
+ this.session.DeleteSessionRoamingMessage(to_type, session_id, (rescode, to_type, session_id) => {
184
+ if (cb) {
185
+ cb(rescode, to_type, session_id);
186
+ }
187
+ resolve([rescode, to_type, session_id]);
188
+ }, ext);
189
+ });
190
+ }
191
+ /** 最近联系人项未读数清零
192
+ * @param to_type 会话类型,双人0,群组1 (nim_msglog_def.h)
193
+ * @param id 对方的account id或者群组tid。
194
+ * @param jsonExtension json扩展参数(备用,目前不需要)
195
+ * @param cb 最近会话列表项变更的回调函数
196
+ * @return boolean 检查参数如果不符合要求则返回失败
197
+ * @note
198
+ * <pre>
199
+ * 200:成功
200
+ * </pre>
201
+ */
202
+ setUnreadCountZeroAsync(type, id, cb, jsonExtension) {
203
+ return new Promise((resolve) => {
204
+ if (!this.session.SetUnreadCountZeroAsync(type, id, (rescode, session_data, count) => {
205
+ if (cb) {
206
+ cb(rescode, session_data, count);
207
+ }
208
+ resolve([rescode, session_data, count]);
209
+ }, jsonExtension)) {
210
+ resolve(null);
211
+ }
212
+ });
213
+ }
214
+ /** 最近联系人项未读数清零
215
+ * @param is_super_team 会话列表中的会话是否是超大群会话
216
+ * @param zero_list 清零的会话信息列表。
217
+ * @param cb 最近会话列表项变更的回调函数
218
+ * @return boolean 检查参数如果不符合要求则返回失败
219
+ * @note
220
+ * <pre>
221
+ * 200:成功
222
+ * </pre>
223
+ */
224
+ setMultiUnreadCountZeroAsync(is_super_team, zero_list, cb) {
225
+ return new Promise((resolve) => {
226
+ if (!this.session.SetMultiUnreadCountZeroAsync(is_super_team, zero_list, (rescode, data_list, unread_count) => {
227
+ if (cb) {
228
+ cb(rescode, data_list, unread_count);
229
+ }
230
+ resolve([rescode, data_list, unread_count]);
231
+ })) {
232
+ resolve(null);
233
+ }
234
+ });
235
+ }
236
+ /** 设置会话项是否置顶(置顶属性只保存在本地)
237
+ * @param to_type 会话类型
238
+ * @param id 对方的account id或者群组tid。
239
+ * @param top true - 置顶 false - 取消置顶
240
+ * @param cb 回调函数
241
+ * @param jsonExtension json扩展参数(备用,目前不需要)
242
+ * @return boolean 检查参数如果不符合要求则返回失败
243
+ * @note
244
+ * <pre>
245
+ * 200:成功
246
+ * </pre>
247
+ */
248
+ setSessionTop(type, id, top, cb, jsonExtension) {
249
+ return new Promise((resolve) => {
250
+ if (!this.session.SetSessionTop(type, id, top, (rescode, session_data, count) => {
251
+ if (cb) {
252
+ cb(rescode, session_data, count);
253
+ }
254
+ resolve([rescode, session_data, count]);
255
+ }, jsonExtension)) {
256
+ resolve(null);
257
+ }
258
+ });
259
+ }
260
+ /** 设置会话项扩展数据(扩展数据只保存在本地)
261
+ * @param to_type 会话类型
262
+ * @param id 对方的account id或者群组tid。
263
+ * @param data 扩展数据,建议使用灵活可扩展的数据结构,例如Json
264
+ * @param cb 回调函数
265
+ * @param jsonExtension json扩展参数(备用,目前不需要)
266
+ * @return boolean 检查参数如果不符合要求则返回失败
267
+ * @note
268
+ * <pre>
269
+ * 200:成功
270
+ * </pre>
271
+ */
272
+ setSessionExtendData(type, id, data, cb, jsonExtension) {
273
+ return new Promise((resolve) => {
274
+ if (!this.session.SetSessionExtendData(type, id, data, (rescode, session_data, count) => {
275
+ if (cb) {
276
+ cb(rescode, session_data, count);
277
+ }
278
+ resolve([rescode, session_data, count]);
279
+ }, jsonExtension)) {
280
+ resolve(null);
281
+ }
282
+ });
283
+ }
284
+ /** 最近联系人项全部未读数清零
285
+ * @param jsonExtension json扩展参数(备用,目前不需要)
286
+ * @param cb 最近会话列表项变更的回调函数
287
+ * @return boolean 检查参数如果不符合要求则返回失败
288
+ * @note
289
+ * <pre>
290
+ * 200:成功
291
+ * </pre>
292
+ */
293
+ setAllUnreadCountZeroAsync(cb, jsonExtension) {
294
+ return new Promise((resolve) => {
295
+ if (!this.session.SetAllUnreadCountZeroAsync((rescode, session_data, count) => {
296
+ if (cb) {
297
+ cb(rescode, session_data, count);
298
+ }
299
+ resolve([rescode, session_data, count]);
300
+ }, jsonExtension)) {
301
+ resolve(null);
302
+ }
303
+ });
304
+ }
305
+ /** 根据给定的id查询相应会话的信息
306
+ * @param to_type 会话类型
307
+ * @param id 对方的account id或者群组tid。
308
+ * @param cb 会话信息查询结果的回调函数
309
+ * @param jsonExtension json扩展参数(备用,目前不需要)
310
+ * @return void 无返回值
311
+ * @note
312
+ * <pre>
313
+ * 200:成功
314
+ * </pre>
315
+ */
316
+ querySessionDataById(type, id, cb, jsonExtension) {
317
+ return new Promise((resolve) => {
318
+ this.session.QuerySessionDataById(type, id, (rescode, session_data) => {
319
+ if (cb) {
320
+ cb(rescode, session_data);
321
+ }
322
+ resolve([rescode, session_data]);
323
+ }, jsonExtension);
324
+ });
325
+ }
326
+ /** 查询会话是漫游消息未拉取信息
327
+ * @param session_id 会话id
328
+ * @param to_type 会话类型
329
+ * @param cb 查询会话是漫游消息未拉取信息回调函数
330
+ * @return void 无返回值
331
+ * @note
332
+ * <pre>
333
+ * 200:成功
334
+ * </pre>
335
+ */
336
+ queryHasmoreRoammsg(session_id, to_type, cb) {
337
+ return new Promise((resolve) => {
338
+ this.session.QueryHasmoreRoammsg(session_id, to_type, (rescode, info) => {
339
+ if (cb) {
340
+ cb(rescode, info);
341
+ }
342
+ resolve([rescode, info]);
343
+ });
344
+ });
345
+ }
346
+ /** 查询所有漫游消息未拉取完全的会话
347
+ * @param cb 结果回调
348
+ * @return void 无返回值
349
+ */
350
+ queryAllHasmoreRoammsg(cb) {
351
+ return new Promise((resolve) => {
352
+ this.session.QueryAllHasmoreRoammsg((rescode, infos) => {
353
+ if (cb) {
354
+ cb(rescode, infos);
355
+ }
356
+ resolve([rescode, infos]);
357
+ });
358
+ });
359
+ }
360
+ /** 更新会话是漫游消息未拉取信息
361
+ * @param msg 对应的消息内容
362
+ * @param cb 结果回调
363
+ * @return void 无返回值
364
+ */
365
+ updateHasmoreRoammsg(msg, cb) {
366
+ return new Promise((resolve) => {
367
+ this.session.UpdateHasmoreRoammsg(msg, (rescode) => {
368
+ if (cb) {
369
+ cb(rescode);
370
+ }
371
+ resolve([rescode]);
372
+ });
373
+ });
374
+ }
375
+ /** 删除会话是漫游消息未拉取信息
376
+ * @param session_id 会话id
377
+ * @param to_type 会话类型
378
+ * @param cb 结果回调
379
+ * @return void 无返回值
380
+ */
381
+ deleteHasmoreRoammsg(session_id, to_type, cb) {
382
+ return new Promise((resolve) => {
383
+ this.session.DeleteHasmoreRoammsg(session_id, to_type, (rescode) => {
384
+ if (cb) {
385
+ cb(rescode);
386
+ }
387
+ resolve([rescode]);
388
+ });
389
+ });
390
+ }
391
+ }
392
+ exports.NIMSession = NIMSession;
393
393
  //# sourceMappingURL=session.js.map