easemob-websdk 3.6.0 → 4.0.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.
@@ -0,0 +1,1479 @@
1
+
2
+ import { InputFiles } from "typescript";
3
+ declare interface GetChatRoomsParams {
4
+ pagenum: number;
5
+ pagesize: number;
6
+ success?: (data: any) => any;
7
+ error?: (error: any) => any;
8
+ }
9
+ declare interface CreateChatRoomParams {
10
+ name: string;
11
+ description: string;
12
+ maxusers: number;
13
+ members: string[];
14
+ token: string;
15
+ success?: (data: any) => any;
16
+ error?: (error: any) => any;
17
+ }
18
+ declare interface DestroyChatRoomParams {
19
+ chatRoomId: string;
20
+ token: string;
21
+ success?: (data: any) => any;
22
+ error?: (error: any) => any;
23
+ }
24
+ declare interface GetChatRoomDetailsParams {
25
+ chatRoomId: string;
26
+ success?: (data: any) => any;
27
+ error?: (error: any) => any;
28
+ }
29
+ declare interface ModifyChatRoomParams {
30
+ chatRoomId: string;
31
+ chatRoomName: string;
32
+ description: string;
33
+ maxusers: number;
34
+ success?: (data: any) => any;
35
+ error?: (error: any) => any;
36
+ }
37
+ declare interface RemoveSingleChatRoomMemberParams {
38
+ chatRoomId: string;
39
+ username: string;
40
+ success?: (data: any) => any;
41
+ error?: (error: any) => any;
42
+ }
43
+ declare interface RemoveMultiChatRoomMemberParams {
44
+ chatRoomId: string;
45
+ users: string[];
46
+ success?: (data: any) => any;
47
+ error?: (error: any) => any;
48
+ }
49
+ declare interface AddUsersToChatRoomParams {
50
+ chatRoomId: string;
51
+ users: string[];
52
+ success?: (data: any) => any;
53
+ error?: (error: any) => any;
54
+ }
55
+ declare interface JoinChatRoomParams {
56
+ roomId: string;
57
+ message?: string;
58
+ success?: (data: any) => any;
59
+ error?: (error: any) => any;
60
+ }
61
+ declare interface QuitChatRoomParams {
62
+ roomId: string;
63
+ success?: (data: any) => any;
64
+ error?: (error: any) => any;
65
+ }
66
+ declare interface ListChatRoomMemberParams {
67
+ pageNum: number;
68
+ pageSize: number;
69
+ chatRoomId: string;
70
+ success?: (data: any) => any;
71
+ error?: (error: any) => any;
72
+ }
73
+ declare interface GetChatRoomAdminParams {
74
+ chatRoomId: string;
75
+ success?: (data: any) => any;
76
+ error?: (error: any) => any;
77
+ }
78
+ declare interface SetChatRoomAdminParams {
79
+ chatRoomId: string;
80
+ username: string;
81
+ success?: (data: any) => any;
82
+ error?: (error: any) => any;
83
+ }
84
+ declare interface RemoveChatRoomAdminParams {
85
+ chatRoomId: string;
86
+ username: string;
87
+ success?: (data: any) => any;
88
+ error?: (error: any) => any;
89
+ }
90
+ declare interface MuteChatRoomMemberParams {
91
+ chatRoomId: string;
92
+ username: string;
93
+ muteDuration: number;
94
+ success?: (data: any) => any;
95
+ error?: (error: any) => any;
96
+ }
97
+ declare interface RemoveMuteChatRoomMemberParams {
98
+ chatRoomId: string;
99
+ username: string;
100
+ success?: (data: any) => any;
101
+ error?: (error: any) => any;
102
+ }
103
+ declare interface GetChatRoomMutedParams {
104
+ chatRoomId: string;
105
+ success?: (data: any) => any;
106
+ error?: (error: any) => any;
107
+ }
108
+ declare interface ChatRoomBlockSingleParams {
109
+ chatRoomId: string;
110
+ username: string;
111
+ success?: (data: any) => any;
112
+ error?: (error: any) => any;
113
+ }
114
+ declare interface ChatRoomBlockMultiParams {
115
+ chatRoomId: string;
116
+ usernames: string[];
117
+ success?: (data: any) => any;
118
+ error?: (error: any) => any;
119
+ }
120
+ declare interface RemoveChatRoomBlockSingleParams {
121
+ chatRoomId: string;
122
+ username: string;
123
+ success?: (data: any) => any;
124
+ error?: (error: any) => any;
125
+ }
126
+ declare type RemoveChatRoomBlockMultiParams = ChatRoomBlockMultiParams;
127
+ declare interface GetChatRoomBlacklistNewParams {
128
+ chatRoomId: string;
129
+ success?: (data: any) => any;
130
+ error?: (error: any) => any;
131
+ }
132
+ declare interface DisableSendChatRoomMsgParams {
133
+ chatRoomId: string;
134
+ success?: (data: any) => any;
135
+ error?: (error: any) => any;
136
+ }
137
+ declare type EnableSendChatRoomMsgParams = DisableSendChatRoomMsgParams;
138
+ declare interface AddUsersToChatRoomWhitelistParams {
139
+ chatRoomId: string;
140
+ users: string[];
141
+ success?: (data: any) => any;
142
+ error?: (error: any) => any;
143
+ }
144
+ declare interface RmUsersFromChatRoomWhitelistParams {
145
+ chatRoomId: string;
146
+ userName: string;
147
+ success?: (data: any) => any;
148
+ error?: (error: any) => any;
149
+ }
150
+ declare interface GetChatRoomWhitelistParams {
151
+ chatRoomId: string;
152
+ success?: (data: any) => any;
153
+ error?: (error: any) => any;
154
+ }
155
+ declare interface IsChatRoomWhiteUserParams {
156
+ chatRoomId: string;
157
+ userName: string;
158
+ success?: (data: any) => any;
159
+ error?: (error: any) => any;
160
+ }
161
+ declare interface FetchChatRoomAnnouncementParams {
162
+ roomId: string;
163
+ success?: (data: any) => any;
164
+ error?: (error: any) => any;
165
+ }
166
+ declare interface UpdateChatRoomAnnouncementParams {
167
+ roomId: string;
168
+ announcement: string;
169
+ success?: (data: any) => any;
170
+ error?: (error: any) => any;
171
+ }
172
+ declare interface UploadChatRoomSharedFileParams {
173
+ roomId: string;
174
+ file: InputFiles;
175
+ onFileUploadProgress?: (data: any) => any;
176
+ onFileUploadComplete?: (data: any) => any;
177
+ onFileUploadError?: (data: any) => any;
178
+ onFileUploadCanceled?: (data: any) => any;
179
+ }
180
+ declare interface DeleteChatRoomSharedFileParams {
181
+ roomId: string;
182
+ fileId: string;
183
+ success?: (data: any) => any;
184
+ error?: (error: any) => any;
185
+ }
186
+ declare interface FetchChatRoomSharedFileListParams {
187
+ roomId: string;
188
+ success?: (data: any) => any;
189
+ error?: (error: any) => any;
190
+ }
191
+ export { GetChatRoomsParams, CreateChatRoomParams, DestroyChatRoomParams, GetChatRoomDetailsParams, ModifyChatRoomParams, RemoveSingleChatRoomMemberParams, RemoveMultiChatRoomMemberParams, AddUsersToChatRoomParams, JoinChatRoomParams, QuitChatRoomParams, ListChatRoomMemberParams, GetChatRoomAdminParams, SetChatRoomAdminParams, RemoveChatRoomAdminParams, MuteChatRoomMemberParams, RemoveMuteChatRoomMemberParams, GetChatRoomMutedParams, ChatRoomBlockSingleParams, ChatRoomBlockMultiParams, RemoveChatRoomBlockSingleParams, RemoveChatRoomBlockMultiParams, GetChatRoomBlacklistNewParams, DisableSendChatRoomMsgParams, EnableSendChatRoomMsgParams, AddUsersToChatRoomWhitelistParams, RmUsersFromChatRoomWhitelistParams, GetChatRoomWhitelistParams, IsChatRoomWhiteUserParams, FetchChatRoomAnnouncementParams, UpdateChatRoomAnnouncementParams, UploadChatRoomSharedFileParams, DeleteChatRoomSharedFileParams, FetchChatRoomSharedFileListParams };
192
+
193
+ // Group Api
194
+ declare interface CreateGroupNewParams {
195
+ data: {
196
+ groupname: string;
197
+ desc: string;
198
+ members: string[];
199
+ public: boolean;
200
+ approval: boolean;
201
+ allowinvites: boolean;
202
+ inviteNeedConfirm: boolean;
203
+ };
204
+ success?: (data: any) => any;
205
+ error?: (error: any) => any;
206
+ }
207
+ declare interface BlockGroupParams {
208
+ groupId: string;
209
+ success?: (data: any) => any;
210
+ error?: (error: any) => any;
211
+ }
212
+ declare interface ListGroupsParams {
213
+ limit: number;
214
+ cursor?: number | null;
215
+ success?: (data: any) => any;
216
+ error?: (error: any) => any;
217
+ }
218
+ declare interface GetGroupParams {
219
+ success?: (data: any) => any;
220
+ error?: (error: any) => any;
221
+ }
222
+ declare interface ChangeOwnerParams {
223
+ groupId: string;
224
+ newOwner: string;
225
+ success?: (data: any) => any;
226
+ error?: (error: any) => any;
227
+ }
228
+ declare interface GetGroupInfoParams {
229
+ groupId: string;
230
+ success?: (data: any) => any;
231
+ error?: (error: any) => any;
232
+ }
233
+ declare interface ModifyGroupParams {
234
+ groupId: string;
235
+ groupName: string;
236
+ description: string;
237
+ success?: (data: any) => any;
238
+ error?: (error: any) => any;
239
+ }
240
+ declare interface ListGroupMemberParams {
241
+ pageNum: number;
242
+ pageSize: number;
243
+ groupId: string;
244
+ success?: (data: any) => any;
245
+ error?: (error: any) => any;
246
+ }
247
+ declare interface GetGroupAdminParams {
248
+ groupId: string;
249
+ success?: (data: any) => any;
250
+ error?: (error: any) => any;
251
+ }
252
+ declare interface SetAdminParams {
253
+ groupId: string;
254
+ username: string;
255
+ success?: (data: any) => any;
256
+ error?: (error: any) => any;
257
+ }
258
+ declare type RemoveAdminParams = SetAdminParams;
259
+ declare interface DissolveGroupParams {
260
+ groupId: string;
261
+ success?: (data: any) => any;
262
+ error?: (error: any) => any;
263
+ }
264
+ declare interface QuitGroupParams {
265
+ groupId: string;
266
+ success?: (data: any) => any;
267
+ error?: (error: any) => any;
268
+ }
269
+ declare interface InviteToGroupParams {
270
+ groupId: string;
271
+ users: string[];
272
+ success?: (data: any) => any;
273
+ error?: (error: any) => any;
274
+ }
275
+ declare interface JoinGroupParams {
276
+ groupId: string;
277
+ message: string;
278
+ success?: (data: any) => any;
279
+ error?: (error: any) => any;
280
+ }
281
+ declare interface AgreeJoinGroupParams {
282
+ groupId: string;
283
+ applicant: string;
284
+ success?: (data: any) => any;
285
+ error?: (error: any) => any;
286
+ }
287
+ declare interface RejectJoinGroupParams {
288
+ groupId: string;
289
+ applicant: string;
290
+ reason: string;
291
+ success?: (data: any) => any;
292
+ error?: (error: any) => any;
293
+ }
294
+ declare interface AgreeInviteIntoGroupParams {
295
+ groupId: string;
296
+ invitee: string;
297
+ success?: (data: any) => any;
298
+ error?: (error: any) => any;
299
+ }
300
+ declare type RejectInviteIntoGroupParams = AgreeInviteIntoGroupParams;
301
+ declare interface RemoveSingleGroupMemberParams {
302
+ groupId: string;
303
+ username: string;
304
+ success?: (data: any) => any;
305
+ error?: (error: any) => any;
306
+ }
307
+ declare interface RemoveMultiGroupMemberParams {
308
+ groupId: string;
309
+ users: string[];
310
+ success?: (data: any) => any;
311
+ error?: (error: any) => any;
312
+ }
313
+ declare interface MuteParams {
314
+ groupId: string;
315
+ username: string;
316
+ muteDuration: number;
317
+ success?: (data: any) => any;
318
+ error?: (error: any) => any;
319
+ }
320
+ declare interface RemoveMuteParams {
321
+ groupId: string;
322
+ username: string;
323
+ success?: (data: any) => any;
324
+ error?: (error: any) => any;
325
+ }
326
+ declare interface GetMutedParams {
327
+ groupId: string;
328
+ success?: (data: any) => any;
329
+ error?: (error: any) => any;
330
+ }
331
+ declare interface GroupBlockSingleParams {
332
+ groupId: string;
333
+ username: string;
334
+ success?: (data: any) => any;
335
+ error?: (error: any) => any;
336
+ }
337
+ declare interface GroupBlockMultiParams {
338
+ groupId: string;
339
+ usernames: string[];
340
+ success?: (data: any) => any;
341
+ error?: (error: any) => any;
342
+ }
343
+ declare type RemoveGroupBlockSingleParams = GroupBlockSingleParams;
344
+ declare type RemoveGroupBlockMultiParams = GroupBlockMultiParams;
345
+ declare interface GetGroupBlacklistNew {
346
+ groupId: string;
347
+ success?: (data: any) => any;
348
+ error?: (error: any) => any;
349
+ }
350
+ declare interface DisableSendGroupMsgParams {
351
+ groupId: string;
352
+ success?: (data: any) => any;
353
+ error?: (error: any) => any;
354
+ }
355
+ declare type EnableSendGroupMsgParams = DisableSendGroupMsgParams;
356
+ declare interface AddUsersToGroupWhitelistParams {
357
+ groupId: string;
358
+ users: string[];
359
+ success?: (data: any) => any;
360
+ error?: (error: any) => any;
361
+ }
362
+ declare interface RmUsersFromGroupWhitelistParams {
363
+ groupId: string;
364
+ userName: string;
365
+ success?: (data: any) => any;
366
+ error?: (error: any) => any;
367
+ }
368
+ declare interface GetGroupWhitelistParams {
369
+ groupId: string;
370
+ success?: (data: any) => any;
371
+ error?: (error: any) => any;
372
+ }
373
+ declare interface IsGroupWhiteUserParams {
374
+ groupId: string;
375
+ userName: string;
376
+ success?: (data: any) => any;
377
+ error?: (error: any) => any;
378
+ }
379
+ declare interface GetGroupMsgReadUserParams {
380
+ groupId: string;
381
+ msgId: string;
382
+ success?: (data: any) => any;
383
+ error?: (error: any) => any;
384
+ }
385
+ declare interface FetchGroupAnnouncementParams {
386
+ groupId: string;
387
+ success?: (data: any) => any;
388
+ error?: (error: any) => any;
389
+ }
390
+ declare interface UpdateGroupAnnouncementParams {
391
+ groupId: string;
392
+ announcement: string;
393
+ success?: (data: any) => any;
394
+ error?: (error: any) => any;
395
+ }
396
+ declare interface UploadGroupSharedFileParams {
397
+ groupId: string;
398
+ file: InputFiles;
399
+ onFileUploadProgress?: (data: any) => any;
400
+ onFileUploadComplete?: (data: any) => any;
401
+ onFileUploadError?: (data: any) => any;
402
+ onFileUploadCanceled?: (data: any) => any;
403
+ }
404
+ declare interface DeleteGroupSharedFileParams {
405
+ groupId: string;
406
+ fileId: string;
407
+ success?: (data: any) => any;
408
+ error?: (error: any) => any;
409
+ }
410
+ declare interface FetchGroupSharedFileListParams {
411
+ groupId: string;
412
+ success?: (data: any) => any;
413
+ error?: (error: any) => any;
414
+ }
415
+ export { CreateGroupNewParams, BlockGroupParams, ListGroupsParams, GetGroupParams, ChangeOwnerParams, GetGroupInfoParams, ModifyGroupParams, ListGroupMemberParams, GetGroupAdminParams, SetAdminParams, RemoveAdminParams, DissolveGroupParams, QuitGroupParams, InviteToGroupParams, JoinGroupParams, AgreeJoinGroupParams, RejectJoinGroupParams, AgreeInviteIntoGroupParams, RejectInviteIntoGroupParams, RemoveSingleGroupMemberParams, RemoveMultiGroupMemberParams, MuteParams, RemoveMuteParams, GetMutedParams, GroupBlockSingleParams, GroupBlockMultiParams, RemoveGroupBlockSingleParams, RemoveGroupBlockMultiParams, GetGroupBlacklistNew, DisableSendGroupMsgParams, EnableSendGroupMsgParams, AddUsersToGroupWhitelistParams, RmUsersFromGroupWhitelistParams, GetGroupWhitelistParams, IsGroupWhiteUserParams, GetGroupMsgReadUserParams, FetchGroupAnnouncementParams, UpdateGroupAnnouncementParams, UploadGroupSharedFileParams, DeleteGroupSharedFileParams, FetchGroupSharedFileListParams };
416
+
417
+ // Contact Api
418
+ declare interface BaseApiParams {
419
+ success?: (data: any) => any;
420
+ error?: (error: any) => any;
421
+ }
422
+
423
+ declare interface UploadTokenParams {
424
+ deviceId: string;
425
+ deviceToken: string;
426
+ notifierName: string;
427
+ success?: (data: any) => any;
428
+ error?: (error: any) => any;
429
+ }
430
+
431
+ declare interface UpdateOwnUserInfoParams {
432
+ nickname?: string;
433
+ avatarurl?: string;
434
+ mail?: string;
435
+ phone?: string;
436
+ gender?: any;
437
+ sign?: string;
438
+ birth?: string;
439
+ ext?: {
440
+ [key: string]: any;
441
+ };
442
+ }
443
+ declare type ConfigurableKey = 'nickname' | 'avatarurl' | 'mail' | 'phone' | 'gender' | 'sign' | 'birth' | 'ext';
444
+ declare interface RosterData {
445
+ name: string;
446
+ subscription: 'both';
447
+ jid: Jid;
448
+ }
449
+ declare interface UserBlackListParams {
450
+ name: string;
451
+ }
452
+ declare interface SubscribeParams {
453
+ to: string;
454
+ message?: string;
455
+ }
456
+ declare interface FetchHistoryMsgsParams {
457
+ queue: string;
458
+ start?: number | null;
459
+ count?: number;
460
+ isGroup?: boolean;
461
+ success?: (data: any) => any;
462
+ fail?: (error?: any) => any;
463
+ }
464
+ declare interface RecallMessageParams {
465
+ mid: string;
466
+ to: string;
467
+ type?: 'chat' | 'groupchat' | 'chatroom';
468
+ chatType?: 'singleChat' | 'groupChat' | 'chatRoom';
469
+ success?: () => any;
470
+ fail?: () => any;
471
+ }
472
+ export type { GetBlacklistParams, GetRosterParams, RosterData, UploadTokenParams, GetSessionListParams, UpdateOwnUserInfoParams, ConfigurableKey, UserBlackListParams, SubscribeParams, FetchHistoryMsgsParams, RecallMessageParams };
473
+
474
+
475
+ // eventHandle types
476
+ declare type OnPresenceMsgType = 'rmChatRoomMute' | 'rmGroupMute' | 'muteChatRoom' | 'muteGroup' | 'rmUserFromChatRoomWhiteList' | 'rmUserFromGroupWhiteList' | 'addUserToChatRoomWhiteList' | 'addUserToGroupWhiteList' | 'deleteFile' | /*delete group file*/ 'uploadFile' | /*upload group file*/ 'deleteAnnouncement' | /*delete group Announcement*/ 'updateAnnouncement' | /*delete group Announcement*/ 'removeMute' | /*Lift a person from the ban in the group*/ 'addMute' | /*Forbid one person in the group*/ 'removeAdmin' | /*Remove a group administrator*/ 'addAdmin' | 'changeOwner' | 'direct_joined' | 'leaveChatRoom' | 'leaveGroup' | 'memberJoinChatRoomSuccess' | 'memberJoinPublicGroupSuccess' | 'unblock' | 'block' | 'update' | 'allow' | 'ban' | 'getBlackList' | 'removedFromGroup' | 'invite_decline' | 'invite_accept' | 'invite' | 'joinPublicGroupDeclined' | 'joinPublicGroupSuccess' | 'joinGroupNotifications' | 'leave' | 'join' | 'deleteGroupChat' | 'subscribe' | 'unsubscribed' | 'subscribed';
477
+ declare interface OnPresenceMsg {
478
+ type: OnPresenceMsgType;
479
+ to: string;
480
+ from: string;
481
+ status: string;
482
+ chatroom?: boolean;
483
+ toJid?: string;
484
+ fromJid?: string;
485
+ gid?: string;
486
+ owner?: string;
487
+ }
488
+ export declare type Event = 'onOpened' | 'onPresence' | 'onTextMessage' | 'onImageMessage' | 'onAudioMessage' | 'onVideoMessage' | 'onFileMessage' | 'onLocationMessage' | 'onCmdMessage' | 'onCustomMessage' | 'onReceivedMessage' | 'onDeliverdMessage' | 'onReadMessage' | 'onRecallMessage' | 'onMutedMessage' | 'onChannelMessage' | 'onError' | 'onOffline' | 'onOnline' | 'onRoster' | 'onStatisticMessage' | 'onContactAgreed' | 'onContactRefuse' | 'onContactDeleted' | 'onContactAdded' | 'onTokenWillExpire' | 'onTokenExpired' | 'onContactInvited' | 'onConnected' | 'onGroupChange' | 'onChatroomChange' | 'onContactChange';
489
+ export interface EventHandlerType {
490
+ 'onOpened'?: (msg: any) => any;
491
+ 'onPresence'?: (msg: OnPresenceMsg) => any;
492
+ 'onTextMessage'?: (msg: TextMsgBody) => any;
493
+ 'onImageMessage'?: (msg: ImgMsgBody) => any;
494
+ 'onAudioMessage'?: (msg: AudioMsgBody) => any;
495
+ 'onVideoMessage'?: (msg: VideoMsgBody) => any;
496
+ 'onFileMessage'?: (msg: FileMsgBody) => any;
497
+ 'onLocationMessage'?: (msg: LocationMsgBody) => any;
498
+ 'onCmdMessage'?: (msg: CmdMsgBody) => any;
499
+ 'onCustomMessage'?: (msg: CustomMsgBody) => any;
500
+ 'onReceivedMessage'?: (msg: ReceivedMsgBody) => any;
501
+ 'onDeliverdMessage'?: (msg: DeliveryMsgBody) => any;
502
+ 'onReadMessage'?: (msg: ReadMsgBody) => any;
503
+ 'onRecallMessage'?: (msg: RecallMsgBody) => any;
504
+ 'onMutedMessage'?: (msg: MuteMsgBody) => any;
505
+ 'onChannelMessage'?: (msg: ChannelMsgBody) => any;
506
+ 'onError'?: (error: ErrorEvent) => any;
507
+ 'onOffline'?: (msg: any) => any;
508
+ 'onOnline'?: (msg: any) => any;
509
+ 'onRoster'?: (rosters: RosterData[]) => any;
510
+ 'onStatisticMessage'?: (msg: any) => any;
511
+ 'onContactAgreed'?: (msg: ContactMsgBody) => any;
512
+ 'onContactRefuse'?: (msg: ContactMsgBody) => any;
513
+ 'onContactDeleted'?: (msg: ContactMsgBody) => any;
514
+ 'onContactAdded'?: (msg: ContactMsgBody) => any;
515
+ 'onTokenWillExpire'?: (msg: any) => any;
516
+ 'onTokenExpired'?: (msg: any) => any;
517
+ 'onContactInvited'?: (msg: any) => any;
518
+ 'onConnected'?: () => any;
519
+ 'onGroupChange'?: (msg: any) => any;
520
+ 'onChatroomChange'?: (msg: any) => any;
521
+ 'onContactChange'?: (msg: any) => any;
522
+ }
523
+ declare interface HandlerData {
524
+ [key: string]: EventHandlerType;
525
+ }
526
+ declare class EventHandler {
527
+ handlerData: HandlerData;
528
+ addEventHandler: (eventHandlerId: string, eventHandler: EventHandlerType) => void;
529
+ removeEventHandler: (eventHandlerId: string) => void;
530
+ protected dispatch: (event: Event, ...args: any[]) => void;
531
+ }
532
+
533
+ declare let EasemobChat: {
534
+ connection: typeof Connection;
535
+ message: typeof Message;
536
+ utils: Utils;
537
+ logger: Logger;
538
+ statusCode: typeof Code;
539
+ };
540
+
541
+ /**
542
+ * The connection module is the module where the SDK creates long link, And all about links, friends, groups, and chat apis are all in this module
543
+ *
544
+ * @module connection
545
+ */
546
+
547
+ declare interface ConnectionParameters {
548
+ apiUrl?: string;
549
+ url?: string;
550
+ isDebug?: boolean;
551
+ isHttpDNS?: boolean;
552
+ heartBeatWait?: number;
553
+ appKey: string;
554
+ deviceId?: string;
555
+ useOwnUploadFun?: boolean;
556
+ autoReconnectNumMax?: number;
557
+ }
558
+ declare interface RegisterUserParameters {
559
+ username: string;
560
+ password: string;
561
+ nickname: string;
562
+ success?: (res: any) => any;
563
+ error?: (err: ErrorEvent) => any;
564
+ apiUrl?: string;
565
+ }
566
+ declare interface LoginParameters {
567
+ user: string;
568
+ pwd: string;
569
+ accessToken?: string;
570
+ agoraToken?: string;
571
+ success?: (res: any) => any;
572
+ error?: (res: any) => any;
573
+ }
574
+ declare interface Host {
575
+ protocol: string;
576
+ domain: string;
577
+ ip: string;
578
+ port: string;
579
+ }
580
+
581
+ declare interface SendMsgResult {
582
+ localMsgId: string, // local message id
583
+ srverMsgId: string // server message id
584
+ }
585
+ /**
586
+ * @category Connection
587
+ */
588
+ declare class Connection {
589
+ isDebug: boolean;
590
+ isHttpDNS: boolean;
591
+ heartBeatWait: number;
592
+ appKey: string;
593
+ /** @hidden */
594
+ appName: string;
595
+ /** @hidden */
596
+ orgName: string;
597
+
598
+ token: string;
599
+ autoReconnectNumMax: number;
600
+ autoReconnectNumTotal: number;
601
+ version: string;
602
+ deviceId: string;
603
+ osType: number;
604
+ useOwnUploadFun: boolean;
605
+ apiUrl: string;
606
+ url: string;
607
+ https: boolean;
608
+
609
+ grantType: 'password' | 'accessToken' | 'agoraToken' | '';
610
+ context: {
611
+ jid: {
612
+ appKey: string;
613
+ clientResource: string;
614
+ domain: string;
615
+ name: string;
616
+ };
617
+ userId: string;
618
+ appKey: string;
619
+ restTokenData: string;
620
+ status: number;
621
+ appName: string;
622
+ orgName: string;
623
+ root: any;
624
+ accessToken: string;
625
+ };
626
+
627
+ _msgHash: {
628
+ [key: string]: any;
629
+ };
630
+
631
+ eventHandler?: EventHandler;
632
+ onOpened?: () => any;
633
+ /**
634
+ * @since 3.0
635
+ * @deprecated 4.0
636
+ */
637
+ onPresence?: (msg: PresenceMsg) => any;
638
+ onTextMessage?: (msg: TextMsgBody) => any;
639
+ onPictureMessage?: (msg: ImgMsgBody) => any;
640
+ onAudioMessage?: (msg: AudioMsgBody) => any;
641
+ onVideoMessage?: (msg: VideoMsgBody) => any;
642
+ onFileMessage?: (msg: FileMsgBody) => any;
643
+ onLocationMessage?: (msg: LocationMsgBody) => any;
644
+ onCmdMessage?: (msg: CmdMsgBody) => any;
645
+ onCustomMessage?: (msg: CustomMsgBody) => any;
646
+ onReceivedMessage?: (msg: ReceivedMsgBody) => any;
647
+ onDeliverdMessage?: (msg: DeliveryMsgBody) => any;
648
+ onReadMessage?: (msg: ReadMsgBody) => any;
649
+ onRecallMessage?: (msg: RecallMsgBody) => any;
650
+ onMutedMessage?: (msg: MuteMsgBody) => any;
651
+ onChannelMessage?: (msg: ChannelMsgBody) => any;
652
+ onError?: (error: ErrorEvent) => any;
653
+ onOffline?: () => any;
654
+ onOnline?: () => any;
655
+ onRoster?: (rosters: RosterData[]) => any;
656
+ onStatisticMessage?: (msg: any) => any;
657
+ onCreateGroup?: (data: any) => any;
658
+ onBlacklistUpdate?: (list: {
659
+ [key: string]: {
660
+ name: string;
661
+ };
662
+ }) => any;
663
+ onContactAgreed?: (msg: ContactMsgBody) => any;
664
+ onContactRefuse?: (msg: ContactMsgBody) => any;
665
+ onContactDeleted?: (msg: ContactMsgBody) => any;
666
+ onContactAdded?: (msg: ContactMsgBody) => any;
667
+ onTokenWillExpire?: () => any;
668
+ onTokenExpired?: () => any;
669
+ /** @hidden */
670
+ [key: string]: any;
671
+ constructor(options: ConnectionParameters);
672
+
673
+ registerUser(this: Connection, params: RegisterUserParameters): Promise<any>;
674
+ open(parameters: LoginParameters): void;
675
+ isOpened(): boolean;
676
+ close(): void;
677
+
678
+ getChatToken(agoraToken: string): Promise<any>;
679
+
680
+ reconnect(): void;
681
+ /** send message */
682
+ send(params: MessagesType): Promise<SendMsgResult>;
683
+
684
+ // ChatRoom API
685
+ getChatRooms(this: Connection, params: GetChatRoomsParams): Promise<Object>;
686
+ createChatRoom(this: Connection, params: CreateChatRoomParams): Promise<Object>;
687
+ destroyChatRoom(this: Connection, params: DestroyChatRoomParams): Promise<Object>;
688
+ getChatRoomDetails(this: Connection, params: GetChatRoomDetailsParams): Promise<Object>;
689
+ modifyChatRoom(this: Connection, params: ModifyChatRoomParams): Promise<Object>;
690
+ removeSingleChatRoomMember(this: Connection, params: RemoveSingleChatRoomMemberParams): Promise<Object>;
691
+ removeMultiChatRoomMember(this: Connection, params: RemoveMultiChatRoomMemberParams): Promise<Object>;
692
+ addUsersToChatRoom(this: Connection, params: AddUsersToChatRoomParams): Promise<Object>;
693
+ joinChatRoom(this: Connection, params: JoinChatRoomParams): Promise<Object>;
694
+ quitChatRoom(this: Connection, params: QuitChatRoomParams): Promise<Object>;
695
+ listChatRoomMember(this: Connection, params: ListChatRoomMemberParams): Promise<Object>;
696
+ getChatRoomAdmin(this: Connection, params: GetChatRoomAdminParams): Promise<Object>;
697
+ setChatRoomAdmin(this: Connection, params: SetChatRoomAdminParams): Promise<Object>;
698
+ removeChatRoomAdmin(this: Connection, params: RemoveChatRoomAdminParams): Promise<Object>;
699
+ muteChatRoomMember(this: Connection, params: MuteChatRoomMemberParams): Promise<Object>;
700
+ removeMuteChatRoomMember(this: Connection, params: RemoveMuteChatRoomMemberParams): Promise<Object>;
701
+ getChatRoomMuted(this: Connection, params: GetChatRoomMutedParams): Promise<Object>;
702
+ chatRoomBlockSingle(this: Connection, params: ChatRoomBlockSingleParams): Promise<Object>;
703
+ chatRoomBlockMulti(this: Connection, params: ChatRoomBlockMultiParams): Promise<Object>;
704
+ removeChatRoomBlockSingle(this: Connection, params: RemoveChatRoomBlockSingleParams): Promise<Object>;
705
+ removeChatRoomBlockMulti(this: Connection, params: RemoveChatRoomBlockMultiParams): Promise<Object>;
706
+ getChatRoomBlacklistNew(this: Connection, params: GetChatRoomBlacklistNewParams): Promise<Object>;
707
+ disableSendChatRoomMsg(this: Connection, params: DisableSendChatRoomMsgParams): Promise<Object>;
708
+ enableSendChatRoomMsg(this: Connection, params: EnableSendChatRoomMsgParams): Promise<Object>;
709
+ addUsersToChatRoomWhitelist(this: Connection, params: AddUsersToChatRoomWhitelistParams): Promise<Object>;
710
+ rmUsersFromChatRoomWhitelist(this: Connection, params: RmUsersFromChatRoomWhitelistParams): Promise<Object>;
711
+ getChatRoomWhitelist(this: Connection, params: GetChatRoomWhitelistParams): Promise<Object>;
712
+ isChatRoomWhiteUser(this: Connection, params: IsChatRoomWhiteUserParams): Promise<Object>;
713
+ fetchChatRoomAnnouncement(this: Connection, params: FetchChatRoomAnnouncementParams): Promise<Object>;
714
+ updateChatRoomAnnouncement(this: Connection, params: UpdateChatRoomAnnouncementParams): Promise<Object>;
715
+ uploadChatRoomSharedFile(this: Connection, params: UploadChatRoomSharedFileParams): void;
716
+ deleteChatRoomSharedFile(this: Connection, params: DeleteChatRoomSharedFileParams): Promise<Object>;
717
+ fetchChatRoomSharedFileList(this: Connection, params: FetchChatRoomSharedFileListParams): Promise<Object>;
718
+
719
+ // Group API
720
+ createGroupNew(this: Connection, params: CreateGroupNewParams): Promise<Object>;
721
+ blockGroup(this: Connection, params: BlockGroupParams): Promise<Object>;
722
+ listGroups(this: Connection, params: ListGroupsParams): Promise<Object>;
723
+ getGroup(this: Connection, params?: BaseApiParams): Promise<Object>;
724
+ changeOwner(this: Connection, params: ChangeOwnerParams): Promise<Object>;
725
+ getGroupInfo(this: Connection, params: GetGroupInfoParams): Promise<Object>;
726
+ modifyGroup(this: Connection, params: ModifyGroupParams): Promise<Object>;
727
+ listGroupMember(this: Connection, params: ListGroupMemberParams): Promise<Object>;
728
+ getGroupAdmin(this: Connection, params: GetGroupAdminParams): Promise<Object>;
729
+ setAdmin(this: Connection, params: SetAdminParams): Promise<Object>;
730
+ removeAdmin(this: Connection, params: RemoveAdminParams): Promise<Object>;
731
+ dissolveGroup(this: Connection, params: DissolveGroupParams): Promise<Object>;
732
+ quitGroup(this: Connection, params: QuitGroupParams): Promise<Object>;
733
+ inviteToGroup(this: Connection, params: InviteToGroupParams): Promise<Object>;
734
+ joinGroup(this: Connection, params: JoinGroupParams): Promise<Object>;
735
+ agreeJoinGroup(this: Connection, params: AgreeJoinGroupParams): Promise<Object>;
736
+ rejectJoinGroup(this: Connection, params: RejectJoinGroupParams): Promise<Object>;
737
+ agreeInviteIntoGroup(this: Connection, params: AgreeInviteIntoGroupParams): Promise<Object>;
738
+ rejectInviteIntoGroup(this: Connection, params: RejectInviteIntoGroupParams): Promise<Object>;
739
+ removeSingleGroupMember(this: Connection, params: RemoveSingleGroupMemberParams): Promise<Object>;
740
+ removeMultiGroupMember(this: Connection, params: RemoveMultiGroupMemberParams): Promise<Object>;
741
+ mute(this: Connection, params: MuteParams): Promise<Object>;
742
+ removeMute(this: Connection, params: RemoveMuteParams): Promise<Object>;
743
+ getMuted(this: Connection, params: GetMutedParams): Promise<Object>;
744
+ groupBlockSingle(this: Connection, params: GroupBlockSingleParams): Promise<Object>;
745
+ groupBlockMulti(this: Connection, params: GroupBlockMultiParams): Promise<Object>;
746
+ removeGroupBlockSingle(this: Connection, params: RemoveGroupBlockSingleParams): Promise<Object>;
747
+ removeGroupBlockMulti(this: Connection, params: RemoveGroupBlockMultiParams): Promise<Object>;
748
+ getGroupBlacklistNew(this: Connection, params: GetGroupBlacklistNew): Promise<Object>;
749
+ disableSendGroupMsg(this: Connection, params: DisableSendGroupMsgParams): Promise<Object>;
750
+ enableSendGroupMsg(this: Connection, params: EnableSendGroupMsgParams): Promise<Object>;
751
+ addUsersToGroupWhitelist(this: Connection, params: AddUsersToGroupWhitelistParams): Promise<Object>;
752
+ rmUsersFromGroupWhitelist(this: Connection, params: RmUsersFromGroupWhitelistParams): Promise<Object>;
753
+ getGroupWhitelist(this: Connection, params: GetGroupWhitelistParams): Promise<Object>;
754
+ isGroupWhiteUser(this: Connection, params: IsGroupWhiteUserParams): Promise<Object>;
755
+ getGroupMsgReadUser(this: Connection, params: GetGroupMsgReadUserParams): Promise<Object>;
756
+ fetchGroupAnnouncement(this: Connection, params: FetchGroupAnnouncementParams): Promise<Object>;
757
+ updateGroupAnnouncement(this: Connection, params: UpdateGroupAnnouncementParams): Promise<Object>;
758
+ uploadGroupSharedFile(this: Connection, params: UploadGroupSharedFileParams): void;
759
+ deleteGroupSharedFile(this: Connection, params: DeleteGroupSharedFileParams): Promise<Object>;
760
+ fetchGroupSharedFileList(this: Connection, params: FetchGroupSharedFileListParams): Promise<Object>;
761
+
762
+ // Contact API
763
+ getBlacklist(this: Connection, params?: BaseApiParams): Promise<Object>;
764
+ getRoster(this: Connection, params?: BaseApiParams): Promise<Object>;
765
+ uploadToken(this: Connection, params: UploadTokenParams): Promise<Object>;
766
+ getSessionList(this: Connection, params?: BaseApiParams): Promise<Object>;
767
+ updateOwnUserInfo(this: Connection, params: UpdateOwnUserInfoParams | ConfigurableKey, value?: any): Promise<Object>;
768
+ fetchUserInfoById(this: Connection, userId: string | string[], properties: ConfigurableKey[] | ConfigurableKey): Promise<Object>;
769
+ updateCurrentUserNick(this: Connection, nick: string): Promise<Object>;
770
+ getChatToken(this: Connection, agoraToken: string): Promise<Object>;
771
+ fetchHistoryMessages(this: Connection, options: FetchHistoryMsgsParams): Promise<any>;
772
+ addContact(this: Connection, to: string, message?: string): Promise<Object>;
773
+ deleteContact(this: Connection, to: string): Promise<Object>;
774
+ acceptInvitation(this: Connection, to: string): Promise<Object>;
775
+ declineInvitation(this: Connection, to: string): Promise<Object>;
776
+ addToBlackList(this: Connection, options: UserBlackListParams): Promise<Object>;
777
+ removeFromBlackList(this: Connection, options: UserBlackListParams): Promise<Object>;
778
+ /** @deprecated*/
779
+ subscribe(this: Connection, options: SubscribeParams): void;
780
+ /** @deprecated*/
781
+ subscribed(this: Connection, options: SubscribeParams): void;
782
+ /** @deprecated*/
783
+ unsubscribed(this: Connection, options: SubscribeParams): void;
784
+ /** @deprecated*/
785
+ removeRoster(this: Connection, options: SubscribeParams): void;
786
+
787
+ recallMessage(this: Connection, option: RecallMessageParams): void;
788
+
789
+ // listen @since 3.0
790
+ listen(this: Connection, parameters: ListenParameters): void;
791
+
792
+ // eventHandler @since 4.0
793
+ addEventHandler(id: string, handler: EventHandlerType): void { }
794
+ removeEventHandler(id: string): void { }
795
+ }
796
+
797
+
798
+ /**
799
+ * This is the doc comment for file1.ts (can be delete)
800
+ *
801
+ * Specify this is a module comment and rename it to my-module:
802
+ * @module eventHandler
803
+ */
804
+
805
+ declare type DispatchParameters = MessagesType | OnPresenceMsg | RosterData | ErrorEvent | MuteMsgBody | ReceivedMsgBody | RecallMsgBody | ChannelMsgBody;
806
+ declare class EventHandler {
807
+ handlerData: HandlerData;
808
+ constructor(Connection: any, eventHandlerId: string, eventHandler: EventHandlerType);
809
+ addEventHandler(eventHandlerId: string, eventHandler: EventHandlerType): void;
810
+ removeEventHandler(eventHandlerId: string): void;
811
+ /** @hidden */
812
+ dispatch(this: EventHandler, event: Event, parameters?: DispatchParameters): void;
813
+ }
814
+
815
+ /**
816
+ * @module listen
817
+ */
818
+ declare interface ListenParameters {
819
+ onOpened?: () => any;
820
+ onPresence?: (msg: PresenceMsg) => any;
821
+ onTextMessage?: (msg: TextMsgBody) => any;
822
+ onPictureMessage?: (msg: ImgMsgBody) => any;
823
+ onAudioMessage?: (msg: AudioMsgBody) => any;
824
+ onVideoMessage?: (msg: VideoMsgBody) => any;
825
+ onFileMessage?: (msg: FileMsgBody) => any;
826
+ onLocationMessage?: (msg: LocationMsgBody) => any;
827
+ onCmdMessage?: (msg: CmdMsgBody) => any;
828
+ onCustomMessage?: (msg: CustomMsgBody) => any;
829
+ onReceivedMessage?: (msg: ReceivedMsgBody) => any;
830
+ onDeliverdMessage?: (msg: DeliveryMsgBody) => any;
831
+ onReadMessage?: (msg: ReadMsgBody) => any;
832
+ onRecallMessage?: (msg: RecallMsgBody) => any;
833
+ onMutedMessage?: (msg: MuteMsgBody) => any;
834
+ onChannelMessage?: (msg: ChannelMsgBody) => any;
835
+ onError?: (error: ErrorEvent) => any;
836
+ onOffline?: () => any;
837
+ onOnline?: () => any;
838
+ onRoster?: (rosters: RosterData[]) => any;
839
+ onStatisticMessage?: () => any;
840
+ onCreateGroup?: () => any;
841
+ onBlacklistUpdate?: () => any;
842
+ onContactAgreed?: (msg: ContactMsgBody) => any;
843
+ onContactRefuse?: (msg: ContactMsgBody) => any;
844
+ onContactDeleted?: (msg: ContactMsgBody) => any;
845
+ onContactAdded?: (msg: ContactMsgBody) => any;
846
+ onTokenWillExpire?: () => any;
847
+ onTokenExpired?: () => any;
848
+ onClosed?: () => any;
849
+ }
850
+
851
+ declare class ErrorEvent {
852
+ type: Code;
853
+ message: string;
854
+ data?: any;
855
+ constructor(parameters: ErrorParameters);
856
+ static create(parameters: ErrorParameters): ErrorEvent;
857
+ }
858
+
859
+ // Logger
860
+ declare type DefaultLevel = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'SILENT';
861
+ declare type LevelNum = 0 | 1 | 2 | 3 | 4 | 5;
862
+ declare type Level = DefaultLevel | LevelNum;
863
+ declare enum Levels {
864
+ "TRACE" = 0,
865
+ "DEBUG" = 1,
866
+ "INFO" = 2,
867
+ "WARN" = 3,
868
+ "ERROR" = 4,
869
+ "SILENT" = 5
870
+ }
871
+ declare interface Config {
872
+ useCache: boolean;
873
+ maxCache: number;
874
+ color: string;
875
+ background: string;
876
+ }
877
+ declare class Logger {
878
+ name: string;
879
+ currentLevel: LevelNum;
880
+ useCookiePersist: boolean;
881
+ storageLogLevelKey: string;
882
+ levels: typeof Levels;
883
+ logMethods: string[];
884
+ methodFactory: any;
885
+ logs: string[];
886
+ config: Config;
887
+ logBytes: number;
888
+ [key: string]: any;
889
+ constructor(name: string, defaultLevel: Level, factory?: any);
890
+ setConfig(cofig: Config): void;
891
+ /**
892
+ * get current log level
893
+ */
894
+ getLevel(): LevelNum;
895
+ /**
896
+ * set log level, level: 0-5
897
+ */
898
+ setLevel(level: Level, persist: boolean, name: string): "No console available for logging" | undefined;
899
+ setDefaultLevel(level: Level): void;
900
+ /**
901
+ * Allows all levels of log output
902
+ */
903
+ enableAll(persist?: boolean): void;
904
+ /**
905
+ * Disabling Log Output
906
+ */
907
+ disableAll(persist?: boolean): void;
908
+ /**
909
+ * get logs object
910
+ */
911
+ getLogs(): string[];
912
+ /**
913
+ * down load logs
914
+ */
915
+ download(): void;
916
+ _bindMethod(obj: any, methodName: string, useCache: boolean): any;
917
+ getTime(): string;
918
+ _cacheLog(...rest: any[]): void;
919
+ _cacheLogCall(log: any): void;
920
+ _getPersistedLevel(): any;
921
+ _persistLevel(levelNum: number): void;
922
+ replaceLoggingMethods(level: LevelNum, loggerName: string): void;
923
+ defaultMethodFactory(methodName: string, level: LevelNum, loggerName: string): any;
924
+ realMethod(methodName: string): any;
925
+ enableLoggingWhenConsoleArrives(methodName: string, level: LevelNum, loggerName: string): () => void;
926
+ }
927
+ declare const defaultLogger: Logger;
928
+
929
+
930
+
931
+ declare type MessageSetParameters = ReadMsgSetParameters | DeliveryMsgSetParameters | ChannelMsgSetParameters | TextMsgSetParameters | CmdMsgSetParameters | CustomMsgSetParameters | LocationMsgSetParameters | ImgMsgSetParameters | AudioMsgSetParameters | VideoMsgSetParameters | FileMsgSetParameters;
932
+ interface CreateOldMsgOpt {
933
+ type: MessageType;
934
+ id: string;
935
+ version: '3.0';
936
+ }
937
+ declare type CreateMsgType = TextMsgBody | CreateImgOps | CmdMsgBody | FileMsgBody | VideoMsgBody | CustomMsgBody | LocationMsgBody | ChannelMsgBody | DeliveryMsgBody | ReadMsgBody | AudioMsgBody
938
+
939
+ export declare class Message {
940
+ id: string;
941
+ body: any;
942
+ constructor(type: MessageType, id?: string);
943
+ createOldMsg(options: any): any;
944
+ static create(options: CreateMsgType): CreateMsgType;
945
+ set(options: MessageSetParameters): void;
946
+ }
947
+
948
+
949
+ declare interface KVString {
950
+ [key: string]: string;
951
+ }
952
+ declare interface AjaxOptions {
953
+ url: string;
954
+ dataType?: string;
955
+ type?: string;
956
+ data?: any;
957
+ headers?: KVString;
958
+ responseType?: "arraybuffer" | "blob" | "document" | "json" | "text";
959
+ mimeType?: string;
960
+ success?: (res: any) => any;
961
+ error?: (res: any) => any;
962
+ }
963
+ declare enum PLATFORM {
964
+ WEB = "web",
965
+ WX = "wx",
966
+ ZFB = "zfb",
967
+ TT = "tt",
968
+ BAIDU = "baidu",
969
+ QUICK_APP = "quick_app",
970
+ UNI = "uni"
971
+ }
972
+ interface EnvInfo {
973
+ platform: PLATFORM;
974
+ global: any;
975
+ }
976
+ interface uri {
977
+ url: string;
978
+ filename: string;
979
+ filetype: string;
980
+ data: File | null;
981
+ }
982
+ declare interface UploadFile {
983
+ onFileUploadProgress?: (msg: any) => any;
984
+ onFileUploadComplete?: (msg: any) => any;
985
+ onFileUploadError?: (msg: any) => any;
986
+ onFileUploadCanceled?: (msg: any) => any;
987
+ accessToken: string;
988
+ appKey: string;
989
+ apiUrl: string;
990
+ uploadUrl?: string;
991
+ file: any;
992
+ }
993
+ declare interface DownloadParams {
994
+ onFileDownloadComplete: (data: any) => any;
995
+ onFileDownloadError: (error: any) => any;
996
+ id: string;
997
+ secret: string;
998
+ [key: string]: any;
999
+ }
1000
+ declare type Fns = (...args: any) => any;
1001
+ interface Utils {
1002
+ autoIncrement: number;
1003
+ getUniqueId: () => string;
1004
+ ajax: (options: AjaxOptions) => PromiseResult<any>;
1005
+ getFileUrl: (fileInputId: string | HTMLInputElement) => uri;
1006
+ uploadFile: (options: UploadFile) => void;
1007
+ flow: (fns: Fns[]) => any;
1008
+ listenNetwork: (online: () => any, offline: () => any) => void;
1009
+ getEnvInfo: () => EnvInfo;
1010
+ wxRequest: (options: AjaxOptions) => PromiseResult<any>;
1011
+ parseDownloadResponse: (res: any) => string;
1012
+ download: (params: DownloadParams) => any;
1013
+ }
1014
+
1015
+ declare enum Code {
1016
+ WEBIM_CONNCTION_USER_NOT_ASSIGN_ERROR = 0,
1017
+ WEBIM_CONNCTION_OPEN_ERROR = 1,
1018
+ WEBIM_CONNCTION_AUTH_ERROR = 2,
1019
+ WEBIM_CONNCTION_OPEN_USERGRID_ERROR = 3,
1020
+ WEBIM_CONNCTION_ATTACH_ERROR = 4,
1021
+ WEBIM_CONNCTION_ATTACH_USERGRID_ERROR = 5,
1022
+ WEBIM_CONNCTION_REOPEN_ERROR = 6,
1023
+ WEBIM_CONNCTION_SERVER_CLOSE_ERROR = 7,
1024
+ WEBIM_CONNCTION_SERVER_ERROR = 8,
1025
+ WEBIM_CONNCTION_IQ_ERROR = 9,
1026
+ WEBIM_CONNCTION_USER_REMOVED = 207,
1027
+ WEBIM_CONNCTION_USER_LOGIN_ANOTHER_DEVICE = 206,
1028
+ WEBIM_CONNCTION_USER_KICKED_BY_CHANGE_PASSWORD = 216,
1029
+ WEBIM_CONNCTION_USER_KICKED_BY_OTHER_DEVICE = 217,
1030
+ WEBIM_CONNCTION_PING_ERROR = 10,
1031
+ WEBIM_CONNCTION_NOTIFYVERSION_ERROR = 11,
1032
+ WEBIM_CONNCTION_GETROSTER_ERROR = 12,
1033
+ WEBIM_CONNCTION_CROSSDOMAIN_ERROR = 13,
1034
+ WEBIM_CONNCTION_LISTENING_OUTOF_MAXRETRIES = 14,
1035
+ WEBIM_CONNCTION_RECEIVEMSG_CONTENTERROR = 15,
1036
+ WEBIM_CONNCTION_DISCONNECTED = 16,
1037
+ WEBIM_CONNCTION_AJAX_ERROR = 17,
1038
+ WEBIM_CONNCTION_JOINROOM_ERROR = 18,
1039
+ WEBIM_CONNCTION_GETROOM_ERROR = 19,
1040
+ WEBIM_CONNCTION_GETROOMINFO_ERROR = 20,
1041
+ WEBIM_CONNCTION_GETROOMMEMBER_ERROR = 21,
1042
+ WEBIM_CONNCTION_GETROOMOCCUPANTS_ERROR = 22,
1043
+ WEBIM_CONNCTION_LOAD_CHATROOM_ERROR = 23,
1044
+ WEBIM_CONNCTION_NOT_SUPPORT_CHATROOM_ERROR = 24,
1045
+ WEBIM_CONNCTION_JOINCHATROOM_ERROR = 25,
1046
+ WEBIM_CONNCTION_QUITCHATROOM_ERROR = 26,
1047
+ WEBIM_CONNCTION_APPKEY_NOT_ASSIGN_ERROR = 27,
1048
+ WEBIM_CONNCTION_TOKEN_NOT_ASSIGN_ERROR = 28,
1049
+ WEBIM_CONNCTION_SESSIONID_NOT_ASSIGN_ERROR = 29,
1050
+ WEBIM_CONNCTION_RID_NOT_ASSIGN_ERROR = 30,
1051
+ WEBIM_CONNCTION_CALLBACK_INNER_ERROR = 31,
1052
+ WEBIM_CONNCTION_CLIENT_OFFLINE = 32,
1053
+ WEBIM_CONNCTION_CLIENT_LOGOUT = 33,
1054
+ WEBIM_CONNCTION_CLIENT_TOO_MUCH_ERROR = 34,
1055
+ WEBIM_CONNECTION_ACCEPT_INVITATION_FROM_GROUP = 35,
1056
+ WEBIM_CONNECTION_DECLINE_INVITATION_FROM_GROUP = 36,
1057
+ WEBIM_CONNECTION_ACCEPT_JOIN_GROUP = 37,
1058
+ WEBIM_CONNECTION_DECLINE_JOIN_GROUP = 38,
1059
+ WEBIM_CONNECTION_CLOSED = 39,
1060
+ WEBIM_CONNECTION_ERROR = 40,
1061
+ WEBIM_UPLOADFILE_BROWSER_ERROR = 100,
1062
+ WEBIM_UPLOADFILE_ERROR = 101,
1063
+ WEBIM_UPLOADFILE_NO_LOGIN = 102,
1064
+ WEBIM_UPLOADFILE_NO_FILE = 103,
1065
+ WEBIM_DOWNLOADFILE_ERROR = 200,
1066
+ WEBIM_DOWNLOADFILE_NO_LOGIN = 201,
1067
+ WEBIM_DOWNLOADFILE_BROWSER_ERROR = 202,
1068
+ WEBIM_MESSAGE_REC_TEXT = 300,
1069
+ WEBIM_MESSAGE_REC_TEXT_ERROR = 301,
1070
+ WEBIM_MESSAGE_REC_EMOTION = 302,
1071
+ WEBIM_MESSAGE_REC_PHOTO = 303,
1072
+ WEBIM_MESSAGE_REC_AUDIO = 304,
1073
+ WEBIM_MESSAGE_REC_AUDIO_FILE = 305,
1074
+ WEBIM_MESSAGE_REC_VEDIO = 306,
1075
+ WEBIM_MESSAGE_REC_VEDIO_FILE = 307,
1076
+ WEBIM_MESSAGE_REC_FILE = 308,
1077
+ WEBIM_MESSAGE_SED_TEXT = 309,
1078
+ WEBIM_MESSAGE_SED_EMOTION = 310,
1079
+ WEBIM_MESSAGE_SED_PHOTO = 311,
1080
+ WEBIM_MESSAGE_SED_AUDIO = 312,
1081
+ WEBIM_MESSAGE_SED_AUDIO_FILE = 313,
1082
+ WEBIM_MESSAGE_SED_VEDIO = 314,
1083
+ WEBIM_MESSAGE_SED_VEDIO_FILE = 315,
1084
+ WEBIM_MESSAGE_SED_FILE = 316,
1085
+ WEBIM_MESSAGE_SED_ERROR = 317,
1086
+ STATUS_INIT = 400,
1087
+ STATUS_DOLOGIN_USERGRID = 401,
1088
+ STATUS_DOLOGIN_IM = 402,
1089
+ STATUS_OPENED = 403,
1090
+ STATUS_CLOSING = 404,
1091
+ STATUS_CLOSED = 405,
1092
+ STATUS_ERROR = 406,
1093
+ GROUP_NOT_EXIST = 605,
1094
+ GROUP_NOT_JOINED = 602,
1095
+ MESSAGE_RECALL_TIME_LIMIT = 504,
1096
+ SERVICE_NOT_ENABLED = 505,
1097
+ SERVICE_NOT_ALLOW_MESSAGING = 506,
1098
+ SERVICE_NOT_ALLOW_MESSAGING_MUTE = 507,
1099
+ SERVER_UNKNOWN_ERROR = 503,
1100
+ MESSAGE_INCLUDE_ILLEGAL_CONTENT = 501,
1101
+ MESSAGE_EXTERNAL_LOGIC_BLOCKED = 502,
1102
+ PERMISSION_DENIED = 603,
1103
+ WEBIM_LOAD_MSG_ERROR = 604,
1104
+ REST_PARAMS_STATUS = 700,
1105
+ SDK_RUNTIME_ERROR = 999
1106
+ }
1107
+
1108
+ export {
1109
+ EasemobChat, Code, Utils, Connection, DispatchParameters, EventHandler,
1110
+ listen, ErrorEvent, DefaultLevel,
1111
+ LevelNum, Level, Levels, Config, Logger,
1112
+ Message, MessageSetParameters, CreateMsgType,
1113
+ PLATFORM, Fns, ConnectionParameters, RegisterUserParameters,
1114
+ LoginParameters, Host, ListenParameters, AudioMsgSetParameters,
1115
+ AudioMsgBody, ChannelMsgSetParameters, ChannelMsgBody, CmdMsgSetParameters, CmdMsgBody, CustomMsgSetParameters, CustomMsgBody, DeliveryMsgSetParameters,
1116
+ DeliveryMsgBody, FileMsgSetParameters, FileMsgBody, CreateOldMsgOpt, LocationMsgSetParameters, LocationMsgBody, ReadMsgSetParameters, TextMsgSetParameters, TextMsgBody, VideoMsgSetParameters, VideoMsgBody, KVString, AjaxOptions, uri, UploadFile, DownloadParams
1117
+ }
1118
+
1119
+
1120
+ // types / message
1121
+
1122
+ declare type MessageType = 'read' | 'delivery' | 'channel' | 'txt' | 'cmd' | 'custom' | 'loc' | 'img' | 'audio' | 'file' | 'video';
1123
+
1124
+ declare type ChatType = 'singleChat' | 'groupChat' | 'chatRoom';
1125
+
1126
+ declare interface ReadMsgSetParameters {
1127
+ ackId: string;
1128
+ to: string;
1129
+ from?: string;
1130
+ }
1131
+ declare interface ReadParameters {
1132
+ type: 'read';
1133
+ id?: string;
1134
+ to: string;
1135
+ from?: string;
1136
+ body?: ReadMsgSetParameters | undefined;
1137
+ }
1138
+ declare interface DeliveryMsgSetParameters {
1139
+ ackId?: string;
1140
+ to: string;
1141
+ from?: string;
1142
+ }
1143
+ declare interface DeliveryMsgBody extends DeliveryMsgSetParameters {
1144
+ id?: string;
1145
+ type: 'delivery';
1146
+ mid: string;
1147
+ }
1148
+ declare interface ChannelMsgSetParameters {
1149
+ chatType: ChatType;
1150
+ to: string;
1151
+ from?: string;
1152
+ }
1153
+ declare interface ChannelMsgBody extends ChannelMsgSetParameters {
1154
+ id?: string;
1155
+ type: 'channel';
1156
+ }
1157
+ declare interface TextMsgSetParameters {
1158
+ chatType: ChatType;
1159
+ to: string;
1160
+ msg: string;
1161
+ from?: string;
1162
+ roomType?: boolean;
1163
+ success?: () => any;
1164
+ fail?: () => any;
1165
+ ext?: {
1166
+ [key: string]: any;
1167
+ };
1168
+ time?: number;
1169
+ msgConfig?: {
1170
+ [key: string]: any;
1171
+ };
1172
+ }
1173
+ declare interface TextMsgBody extends TextMsgSetParameters {
1174
+ id?: string;
1175
+ type: 'txt';
1176
+ }
1177
+ declare interface CmdMsgSetParameters {
1178
+ chatType: ChatType;
1179
+ to: string;
1180
+ action: string;
1181
+ from?: string;
1182
+ roomType?: boolean;
1183
+ success?: () => any;
1184
+ fail?: () => any;
1185
+ ext?: {
1186
+ [key: string]: any;
1187
+ };
1188
+ time?: number;
1189
+ msgConfig?: {
1190
+ [key: string]: any;
1191
+ };
1192
+ }
1193
+ declare interface CmdMsgBody extends CmdMsgSetParameters {
1194
+ id?: string;
1195
+ type: 'cmd';
1196
+ }
1197
+ declare interface CustomMsgSetParameters {
1198
+ chatType: ChatType;
1199
+ to: string;
1200
+ customEvent: string;
1201
+ customExts: {
1202
+ [key: string]: any;
1203
+ };
1204
+ from?: string;
1205
+ roomType?: boolean;
1206
+ success?: () => any;
1207
+ fail?: () => any;
1208
+ ext?: {
1209
+ [key: string]: any;
1210
+ };
1211
+ time?: number;
1212
+ msgConfig?: {
1213
+ [key: string]: any;
1214
+ };
1215
+ }
1216
+ declare interface CustomMsgBody extends CustomMsgSetParameters {
1217
+ id?: string;
1218
+ type: 'custom';
1219
+ params: {
1220
+ [key: string]: any;
1221
+ };
1222
+ }
1223
+ declare interface LocationMsgSetParameters {
1224
+ chatType: ChatType;
1225
+ to: string;
1226
+ addr: string;
1227
+ lat: number;
1228
+ lng: number;
1229
+ from?: string;
1230
+ roomType?: boolean;
1231
+ success?: () => any;
1232
+ fail?: () => any;
1233
+ ext?: {
1234
+ [key: string]: any;
1235
+ };
1236
+ time?: number;
1237
+ msgConfig?: {
1238
+ [key: string]: any;
1239
+ };
1240
+ }
1241
+ declare interface LocationMsgBody extends LocationMsgSetParameters {
1242
+ id?: string;
1243
+ type: 'loc';
1244
+ }
1245
+ declare interface File {
1246
+ url: string;
1247
+ filetype: string;
1248
+ filename: string;
1249
+ data: any;
1250
+ }
1251
+ declare interface ImgMsgSetParameters {
1252
+ chatType: ChatType;
1253
+ to: string;
1254
+ file: File;
1255
+ width?: number;
1256
+ height?: number;
1257
+ fileInputId?: string;
1258
+ from?: string;
1259
+ roomType?: boolean;
1260
+ group?: string;
1261
+ success?: () => any;
1262
+ fail?: () => any;
1263
+ ext?: {
1264
+ [key: string]: any;
1265
+ };
1266
+ url?: string;
1267
+ onFileUploadError?: (error: any) => any;
1268
+ onFileUploadComplete?: (data: any) => any;
1269
+ onFileUploadProgress?: (data: any) => any;
1270
+ uploadError?: () => any;
1271
+ uploadComplete?: () => any;
1272
+ msgConfig?: {
1273
+ [key: string]: any;
1274
+ };
1275
+ body?: {
1276
+ url: string;
1277
+ type: string;
1278
+ filename: string;
1279
+ };
1280
+ }
1281
+ declare interface ImgMsgBody extends ImgMsgSetParameters {
1282
+ id?: string;
1283
+ type: 'img';
1284
+ time: number;
1285
+ secret?: string;
1286
+ thumb?: string;
1287
+ thumb_secret?: string;
1288
+ }
1289
+ declare interface CreateImgOps {
1290
+ type: 'img';
1291
+ chatType: ChatType;
1292
+ file: File;
1293
+ url?: string;
1294
+ width?: number;
1295
+ height?: number;
1296
+ to: string;
1297
+ onFileUploadError?: (error: any) => any;
1298
+ onFileUploadComplete?: (data: any) => any;
1299
+ onFileUploadProgress?: (data: any) => any;
1300
+ uploadError?: () => any;
1301
+ uploadComplete?: () => any;
1302
+ time?: number;
1303
+ ext?: {
1304
+ [key: string]: any;
1305
+ };
1306
+ msgConfig?: {
1307
+ [key: string]: any;
1308
+ };
1309
+ }
1310
+ declare interface AudioMsgSetParameters {
1311
+ chatType: ChatType;
1312
+ file: File;
1313
+ filename: string;
1314
+ length: number;
1315
+ file_length: number;
1316
+ fileInputId?: string;
1317
+ to: string;
1318
+ from?: string;
1319
+ roomType?: boolean;
1320
+ success?: () => any;
1321
+ fail?: () => any;
1322
+ ext?: {
1323
+ [key: string]: any;
1324
+ };
1325
+ time?: number;
1326
+ apiUrl: string;
1327
+ onFileUploadError?: () => any;
1328
+ onFileUploadComplete: () => any;
1329
+ onFileUploadProgress?: () => any;
1330
+ msgConfig?: {
1331
+ [key: string]: any;
1332
+ };
1333
+ }
1334
+ declare interface AudioMsgBody {
1335
+ id?: string;
1336
+ type: 'audio';
1337
+ chatType: ChatType;
1338
+ url: string;
1339
+ length: number;
1340
+ to: string;
1341
+ from: string;
1342
+ secret: string;
1343
+ file: any;
1344
+ filename: string;
1345
+ file_length: number;
1346
+ filetype: string;
1347
+ accessToken: string;
1348
+ time?: number;
1349
+ ext?: {
1350
+ [key: string]: any;
1351
+ };
1352
+ msgConfig?: {
1353
+ [key: string]: any;
1354
+ };
1355
+ }
1356
+ declare interface VideoMsgSetParameters {
1357
+ chatType: ChatType;
1358
+ file: File;
1359
+ filename: string;
1360
+ length: number;
1361
+ file_length: number;
1362
+ fileInputId?: string;
1363
+ to: string;
1364
+ from?: string;
1365
+ roomType?: boolean;
1366
+ success?: () => any;
1367
+ fail?: () => any;
1368
+ ext?: {
1369
+ [key: string]: any;
1370
+ };
1371
+ time?: number;
1372
+ apiUrl: string;
1373
+ onFileUploadError?: () => any;
1374
+ onFileUploadComplete: () => any;
1375
+ onFileUploadProgress?: () => any;
1376
+ msgConfig?: {
1377
+ [key: string]: any;
1378
+ };
1379
+ }
1380
+ declare interface VideoMsgBody {
1381
+ id?: string;
1382
+ type: 'video';
1383
+ chatType: ChatType;
1384
+ url: string;
1385
+ length: number;
1386
+ to: string;
1387
+ from: string;
1388
+ secret: string;
1389
+ filename: string;
1390
+ file: any;
1391
+ file_length: number;
1392
+ filetype: string;
1393
+ accessToken: string;
1394
+ time?: number;
1395
+ ext?: {
1396
+ [key: string]: any;
1397
+ };
1398
+ msgConfig?: {
1399
+ [key: string]: any;
1400
+ };
1401
+ onFileUploadCompletets?: (data: any) => any;
1402
+ }
1403
+ declare interface FileMsgSetParameters {
1404
+ chatType: ChatType;
1405
+ file: File;
1406
+ filename: string;
1407
+ fileInputId?: string;
1408
+ to: string;
1409
+ from?: string;
1410
+ roomType?: boolean;
1411
+ success?: () => any;
1412
+ fail?: () => any;
1413
+ ext?: {
1414
+ [key: string]: any;
1415
+ };
1416
+ time?: number;
1417
+ apiUrl: string;
1418
+ onFileUploadError?: () => any;
1419
+ onFileUploadComplete: () => any;
1420
+ onFileUploadProgress?: () => any;
1421
+ msgConfig?: {
1422
+ [key: string]: any;
1423
+ };
1424
+ }
1425
+ declare interface FileMsgBody {
1426
+ id?: string;
1427
+ type: 'file';
1428
+ chatType: ChatType;
1429
+ from: string;
1430
+ to: string;
1431
+ url: string;
1432
+ secret: string;
1433
+ filename: string;
1434
+ length: number;
1435
+ file: any;
1436
+ file_length: number;
1437
+ filetype: string;
1438
+ accessToken: string;
1439
+ ext?: {
1440
+ [key: string]: any;
1441
+ };
1442
+ time: number;
1443
+ msgConfig?: {
1444
+ [key: string]: any;
1445
+ };
1446
+ }
1447
+ declare interface ReceivedMsgBody {
1448
+ id: string;
1449
+ mid: string;
1450
+ to: string;
1451
+ time: number;
1452
+ }
1453
+ declare interface ReadMsgBody {
1454
+ id?: string;
1455
+ ackId?: string;
1456
+ type: 'read';
1457
+ to: string;
1458
+ from?: string;
1459
+ mid?: string;
1460
+ groupReadCount?: number;
1461
+ ackContent?: string;
1462
+ }
1463
+ declare interface RecallMsgBody {
1464
+ id?: string;
1465
+ from: string;
1466
+ to: string;
1467
+ mid: string;
1468
+ }
1469
+ declare interface MuteMsgBody {
1470
+ mid: string;
1471
+ }
1472
+ declare interface ContactMsgBody {
1473
+ to: string;
1474
+ from: string;
1475
+ status: string;
1476
+ type: 'subscribed' | 'unsubscribed' | 'subscribe';
1477
+ }
1478
+ declare type MessagesType = TextMsgBody | DeliveryMsgBody | ChannelMsgBody | CmdMsgBody | CustomMsgBody | ImgMsgBody | LocationMsgBody | AudioMsgBody | VideoMsgBody | FileMsgBody | ReadMsgBody;
1479
+ export { MessageType, ReadMsgSetParameters, ReadParameters, DeliveryMsgSetParameters, ChannelMsgSetParameters, TextMsgSetParameters, CmdMsgSetParameters, CustomMsgSetParameters, LocationMsgSetParameters, ImgMsgSetParameters, AudioMsgSetParameters, VideoMsgSetParameters, FileMsgSetParameters, ChatType, TextMsgBody, DeliveryMsgBody, ChannelMsgBody, CmdMsgBody, CustomMsgBody, ImgMsgBody, CreateImgOps, LocationMsgBody, AudioMsgBody, VideoMsgBody, FileMsgBody, ReceivedMsgBody, ReadMsgBody, RecallMsgBody, MuteMsgBody, ContactMsgBody, MessagesType };