mezon-js 2.7.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +244 -0
- package/api.gen.ts +4351 -0
- package/build.mjs +45 -0
- package/client.ts +1848 -0
- package/dist/api.gen.d.ts +735 -0
- package/dist/client.d.ts +527 -0
- package/dist/index.d.ts +24 -0
- package/dist/mezon-js.cjs.js +5204 -0
- package/dist/mezon-js.esm.mjs +5184 -0
- package/dist/session.d.ts +58 -0
- package/dist/socket.d.ts +673 -0
- package/dist/utils.d.ts +3 -0
- package/dist/web_socket_adapter.d.ts +83 -0
- package/index.ts +27 -0
- package/package.json +54 -0
- package/rollup.config.js +40 -0
- package/session.ts +114 -0
- package/socket.ts +1303 -0
- package/tsconfig.json +10 -0
- package/utils.ts +49 -0
- package/web_socket_adapter.ts +159 -0
package/dist/socket.d.ts
ADDED
@@ -0,0 +1,673 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright 2020 The Mezon Authors
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
import { ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiRpc } from "./api.gen";
|
17
|
+
import { Session } from "./session";
|
18
|
+
import { Notification } from "./client";
|
19
|
+
import { WebSocketAdapter } from "./web_socket_adapter";
|
20
|
+
/** An object which represents a connected user in the server. */
|
21
|
+
export interface Presence {
|
22
|
+
/** The id of the user. */
|
23
|
+
user_id: string;
|
24
|
+
/** The session id of the user. */
|
25
|
+
session_id: string;
|
26
|
+
/** The username of the user. */
|
27
|
+
username: string;
|
28
|
+
/** The node the user is connected to. */
|
29
|
+
node: string;
|
30
|
+
}
|
31
|
+
/** A response from a channel join operation. */
|
32
|
+
export interface Channel {
|
33
|
+
/** The server-assigned channel id. */
|
34
|
+
id: string;
|
35
|
+
chanel_label: string;
|
36
|
+
/** The presences visible on the chat channel. */
|
37
|
+
presences: Presence[];
|
38
|
+
/** The presence of the current user, i.e. yourself. */
|
39
|
+
self: Presence;
|
40
|
+
user_id_one: string;
|
41
|
+
user_id_two: string;
|
42
|
+
}
|
43
|
+
/** Join a realtime chat channel. */
|
44
|
+
interface ChannelJoin {
|
45
|
+
channel_join: {
|
46
|
+
/** The id of the channel to join. */
|
47
|
+
target_id: string;
|
48
|
+
/** The name of the channel to join. */
|
49
|
+
target: string;
|
50
|
+
/** The channel type: 1 = Channel, 2 = Direct Message, 3 = Group. */
|
51
|
+
type: number;
|
52
|
+
/** Whether channel messages are persisted in the database. */
|
53
|
+
persistence: boolean;
|
54
|
+
/** Whether the user's channel presence is hidden when joining. */
|
55
|
+
hidden: boolean;
|
56
|
+
};
|
57
|
+
}
|
58
|
+
/** Leave a realtime chat channel. */
|
59
|
+
interface ChannelLeave {
|
60
|
+
channel_leave: {
|
61
|
+
/** The id of the channel to leave. */
|
62
|
+
channel_id: string;
|
63
|
+
mode: number;
|
64
|
+
channel_label: string;
|
65
|
+
};
|
66
|
+
}
|
67
|
+
/** Last seen message by user */
|
68
|
+
export interface LastSeenMessageEvent {
|
69
|
+
/** The channel this message belongs to. */
|
70
|
+
channel_id: string;
|
71
|
+
mode: number;
|
72
|
+
channel_label: string;
|
73
|
+
/** The unique ID of this message. */
|
74
|
+
message_id: string;
|
75
|
+
}
|
76
|
+
/** User is react to message */
|
77
|
+
export interface MessageReactionEvent {
|
78
|
+
id: string;
|
79
|
+
/** The channel this message belongs to. */
|
80
|
+
channel_id: string;
|
81
|
+
mode: number;
|
82
|
+
channel_label: string;
|
83
|
+
/** The message that user react */
|
84
|
+
message_id: string;
|
85
|
+
/** Message sender, usually a user ID. */
|
86
|
+
sender_id: string;
|
87
|
+
sender_name?: string;
|
88
|
+
sender_avatar?: string;
|
89
|
+
/** Emoji list. */
|
90
|
+
emoji: string;
|
91
|
+
count: number;
|
92
|
+
action: boolean;
|
93
|
+
}
|
94
|
+
/** User is react to message */
|
95
|
+
export interface MessageMentionEvent {
|
96
|
+
/** The channel this message belongs to. */
|
97
|
+
channel_id: string;
|
98
|
+
mode: number;
|
99
|
+
channel_label: string;
|
100
|
+
/** The message that user react */
|
101
|
+
message_id: string;
|
102
|
+
/** Message sender, usually a user ID. */
|
103
|
+
sender_id: string;
|
104
|
+
user_id: string;
|
105
|
+
username: string;
|
106
|
+
}
|
107
|
+
/** User is react to message */
|
108
|
+
export interface MessageAttachmentEvent {
|
109
|
+
/** The channel this message belongs to. */
|
110
|
+
channel_id: string;
|
111
|
+
mode: number;
|
112
|
+
channel_label: string;
|
113
|
+
/** The message that user react */
|
114
|
+
message_id: string;
|
115
|
+
/** Message sender, usually a user ID. */
|
116
|
+
sender_id: string;
|
117
|
+
filename: string;
|
118
|
+
size: number;
|
119
|
+
url: string;
|
120
|
+
filetype: string;
|
121
|
+
width?: number;
|
122
|
+
height?: number;
|
123
|
+
}
|
124
|
+
/** User is delete to message */
|
125
|
+
export interface MessageDeletedEvent {
|
126
|
+
/** The channel this message belongs to. */
|
127
|
+
channel_id: string;
|
128
|
+
mode: number;
|
129
|
+
channel_label: string;
|
130
|
+
/** The message that user react */
|
131
|
+
message_id: string;
|
132
|
+
/** Message sender, usually a user ID. */
|
133
|
+
deletor: string;
|
134
|
+
}
|
135
|
+
/** User is delete to message */
|
136
|
+
export interface MessageRefEvent {
|
137
|
+
/** The channel this message belongs to. */
|
138
|
+
channel_id: string;
|
139
|
+
mode: number;
|
140
|
+
channel_label: string;
|
141
|
+
/** The message that user react */
|
142
|
+
message_id: string;
|
143
|
+
/** Message reference ID. */
|
144
|
+
message_ref_id: string;
|
145
|
+
/** reference type */
|
146
|
+
ref_type: number;
|
147
|
+
}
|
148
|
+
/** User is typing */
|
149
|
+
export interface MessageTypingEvent {
|
150
|
+
/** The channel this message belongs to. */
|
151
|
+
channel_id: string;
|
152
|
+
mode: number;
|
153
|
+
channel_label: string;
|
154
|
+
/** Message sender, usually a user ID. */
|
155
|
+
sender_id: string;
|
156
|
+
}
|
157
|
+
/** An incoming message on a realtime chat channel. */
|
158
|
+
export interface ChannelMessageEvent {
|
159
|
+
avatar?: string;
|
160
|
+
channel_id: string;
|
161
|
+
mode: number;
|
162
|
+
channel_label: string;
|
163
|
+
clan_id?: string;
|
164
|
+
code: number;
|
165
|
+
content: string;
|
166
|
+
create_time: string;
|
167
|
+
id: string;
|
168
|
+
persistent?: boolean;
|
169
|
+
sender_id: string;
|
170
|
+
update_time: string;
|
171
|
+
user_id_one: string;
|
172
|
+
user_id_two: string;
|
173
|
+
username: string;
|
174
|
+
reactions?: Array<ApiMessageReaction>;
|
175
|
+
mentions?: Array<ApiMessageMention>;
|
176
|
+
attachments?: Array<ApiMessageAttachment>;
|
177
|
+
references?: Array<ApiMessageRef>;
|
178
|
+
referenced_message?: ChannelMessageEvent;
|
179
|
+
}
|
180
|
+
/** An acknowledgement received in response to sending a message on a chat channel. */
|
181
|
+
export interface ChannelMessageAck {
|
182
|
+
/** The server-assigned channel ID. */
|
183
|
+
channel_id: string;
|
184
|
+
mode: number;
|
185
|
+
/** A unique ID for the chat message. */
|
186
|
+
message_id: string;
|
187
|
+
/** A user-defined code for the chat message. */
|
188
|
+
code: number;
|
189
|
+
/** The username of the sender of the message. */
|
190
|
+
username: string;
|
191
|
+
/** The UNIX time when the message was created. */
|
192
|
+
create_time: string;
|
193
|
+
/** The UNIX time when the message was updated. */
|
194
|
+
update_time: string;
|
195
|
+
/** True if the chat message has been stored in history. */
|
196
|
+
persistence: boolean;
|
197
|
+
}
|
198
|
+
/** Send a message to a realtime chat channel. */
|
199
|
+
interface ChannelMessageSend {
|
200
|
+
channel_message_send: {
|
201
|
+
/** Clan Id */
|
202
|
+
clan_id: string;
|
203
|
+
/** The server-assigned channel ID. */
|
204
|
+
channel_id: string;
|
205
|
+
mode: number;
|
206
|
+
channel_label: string;
|
207
|
+
/** The content payload. */
|
208
|
+
content: any;
|
209
|
+
mentions?: Array<MessageMentionEvent>;
|
210
|
+
attachments?: Array<MessageAttachmentEvent>;
|
211
|
+
};
|
212
|
+
}
|
213
|
+
/** Update a message previously sent to a realtime chat channel. */
|
214
|
+
interface ChannelMessageUpdate {
|
215
|
+
channel_message_update: {
|
216
|
+
/** The server-assigned channel ID. */
|
217
|
+
channel_id: string;
|
218
|
+
/** The server-assigned channel label. */
|
219
|
+
channel_label: string;
|
220
|
+
/** A unique ID for the chat message to be updated. */
|
221
|
+
message_id: string;
|
222
|
+
/** The content payload. */
|
223
|
+
content: any;
|
224
|
+
/** The mode payload. */
|
225
|
+
mode: number;
|
226
|
+
};
|
227
|
+
}
|
228
|
+
/** Remove a message previously sent to a realtime chat channel. */
|
229
|
+
interface ChannelMessageRemove {
|
230
|
+
channel_message_remove: {
|
231
|
+
/** The server-assigned channel ID. */
|
232
|
+
channel_id: string;
|
233
|
+
mode: number;
|
234
|
+
channel_label: string;
|
235
|
+
/** A unique ID for the chat message to be removed. */
|
236
|
+
message_id: string;
|
237
|
+
};
|
238
|
+
}
|
239
|
+
/** Presence update for a particular realtime chat channel. */
|
240
|
+
export interface ChannelPresenceEvent {
|
241
|
+
/** The unique identifier of the chat channel. */
|
242
|
+
channel_id: string;
|
243
|
+
channel_label: string;
|
244
|
+
mode: number;
|
245
|
+
/** Presences of the users who joined the channel. */
|
246
|
+
joins: Presence[];
|
247
|
+
/** Presences of users who left the channel. */
|
248
|
+
leaves: Presence[];
|
249
|
+
}
|
250
|
+
export interface VoiceLeavedEvent {
|
251
|
+
id: string;
|
252
|
+
clan_id: string;
|
253
|
+
voice_channel_id: string;
|
254
|
+
last_participant: boolean;
|
255
|
+
}
|
256
|
+
export interface VoiceJoinedEvent {
|
257
|
+
/** The unique identifier of the chat channel. */
|
258
|
+
clan_id: string;
|
259
|
+
clan_name: string;
|
260
|
+
id: string;
|
261
|
+
participant: string;
|
262
|
+
user_id: string;
|
263
|
+
voice_channel_label: string;
|
264
|
+
voice_channel_id: string;
|
265
|
+
last_screenshot: string;
|
266
|
+
}
|
267
|
+
/** Stream identifier */
|
268
|
+
export interface StreamId {
|
269
|
+
/** The type of stream (e.g. chat). */
|
270
|
+
mode: number;
|
271
|
+
/** The primary stream subject, usually a user id. */
|
272
|
+
subject: string;
|
273
|
+
/** A secondary stream subject, for example for a direct chat. */
|
274
|
+
descriptor: string;
|
275
|
+
/** Meta-information (e.g. chat room name). */
|
276
|
+
label: string;
|
277
|
+
}
|
278
|
+
/** Stream data. */
|
279
|
+
export interface StreamData {
|
280
|
+
/** The stream identifier. */
|
281
|
+
stream: StreamId;
|
282
|
+
/** A reference to the user presence that sent this data, if any. */
|
283
|
+
sender?: Presence;
|
284
|
+
/** Arbitrary contents of the data message. */
|
285
|
+
data: string;
|
286
|
+
/** True if this data was delivered reliably. */
|
287
|
+
reliable?: boolean;
|
288
|
+
}
|
289
|
+
/** Presence updates. */
|
290
|
+
export interface StreamPresenceEvent {
|
291
|
+
/** The stream identifier. */
|
292
|
+
stream: StreamId;
|
293
|
+
/** Presences of users who joined the stream. */
|
294
|
+
joins: Presence[];
|
295
|
+
/** Presences of users who left the stream. */
|
296
|
+
leaves: Presence[];
|
297
|
+
}
|
298
|
+
/** Incoming information about a party. */
|
299
|
+
export interface Party {
|
300
|
+
/** The unique party identifier. */
|
301
|
+
party_id: string;
|
302
|
+
/** True, if the party is open to join. */
|
303
|
+
open: boolean;
|
304
|
+
/** The maximum number of party members. */
|
305
|
+
max_size: number;
|
306
|
+
/** The current user in this party, i.e. yourself. */
|
307
|
+
self: Presence;
|
308
|
+
/** The current party leader. */
|
309
|
+
leader: Presence;
|
310
|
+
/** All members currently in the party. */
|
311
|
+
presences: Presence[];
|
312
|
+
}
|
313
|
+
/** Create a party. */
|
314
|
+
export interface PartyCreate {
|
315
|
+
party_create: {
|
316
|
+
/** True, if the party is open to join. */
|
317
|
+
open: boolean;
|
318
|
+
/** The maximum number of party members. */
|
319
|
+
max_size: number;
|
320
|
+
};
|
321
|
+
}
|
322
|
+
/** Join a party. */
|
323
|
+
interface PartyJoin {
|
324
|
+
party_join: {
|
325
|
+
/** The unique party identifier. */
|
326
|
+
party_id: string;
|
327
|
+
};
|
328
|
+
}
|
329
|
+
/** Leave a party. */
|
330
|
+
interface PartyLeave {
|
331
|
+
party_leave: {
|
332
|
+
/** The unique party identifier. */
|
333
|
+
party_id: string;
|
334
|
+
};
|
335
|
+
}
|
336
|
+
/** Promote a new party leader. */
|
337
|
+
interface PartyPromote {
|
338
|
+
party_promote: {
|
339
|
+
/** The unique party identifier. */
|
340
|
+
party_id: string;
|
341
|
+
/** The user presence being promoted to leader. */
|
342
|
+
presence: Presence;
|
343
|
+
};
|
344
|
+
}
|
345
|
+
/** Announcement of a new party leader. */
|
346
|
+
export interface PartyLeader {
|
347
|
+
/** The unique party identifier. */
|
348
|
+
party_id: string;
|
349
|
+
/** The presence of the new party leader. */
|
350
|
+
presence: Presence;
|
351
|
+
}
|
352
|
+
/** Accept a request to join. */
|
353
|
+
interface PartyAccept {
|
354
|
+
party_accept: {
|
355
|
+
/** The unique party identifier. */
|
356
|
+
party_id: string;
|
357
|
+
/** The presence being accepted to join the party. */
|
358
|
+
presence: Presence;
|
359
|
+
};
|
360
|
+
}
|
361
|
+
/** End a party, kicking all party members and closing it. */
|
362
|
+
interface PartyClose {
|
363
|
+
party_close: {
|
364
|
+
/** The unique party identifier. */
|
365
|
+
party_id: string;
|
366
|
+
};
|
367
|
+
}
|
368
|
+
/** Incoming party data delivered from the server. */
|
369
|
+
export interface PartyData {
|
370
|
+
/** The unique party identifier. */
|
371
|
+
party_id: string;
|
372
|
+
/** A reference to the user presence that sent this data, if any. */
|
373
|
+
presence: Presence;
|
374
|
+
/** The operation code the message was sent with. */
|
375
|
+
op_code: number;
|
376
|
+
/** Data payload, if any. */
|
377
|
+
data: Uint8Array;
|
378
|
+
}
|
379
|
+
/** A client to server request to send data to a party. */
|
380
|
+
interface PartyDataSend {
|
381
|
+
party_data_send: {
|
382
|
+
/** The unique party identifier. */
|
383
|
+
party_id: string;
|
384
|
+
/** The operation code the message was sent with. */
|
385
|
+
op_code: number;
|
386
|
+
/** Data payload, if any. */
|
387
|
+
data: string | Uint8Array;
|
388
|
+
};
|
389
|
+
}
|
390
|
+
/** Incoming notification for one or more new presences attempting to join the party. */
|
391
|
+
export interface PartyJoinRequest {
|
392
|
+
/** The ID of the party to get a list of join requests for. */
|
393
|
+
party_id: string;
|
394
|
+
/** Presences attempting to join, or who have joined. */
|
395
|
+
presences: Presence[];
|
396
|
+
}
|
397
|
+
/** Request a list of pending join requests for a party. */
|
398
|
+
export interface PartyJoinRequestList {
|
399
|
+
party_join_request_list: {
|
400
|
+
/** The ID of the party to get a list of join requests for. */
|
401
|
+
party_id: string;
|
402
|
+
};
|
403
|
+
}
|
404
|
+
/** Begin matchmaking as a party. */
|
405
|
+
interface PartyMatchmakerAdd {
|
406
|
+
party_matchmaker_add: {
|
407
|
+
/** The ID of the party to create a matchmaker ticket for. */
|
408
|
+
party_id: string;
|
409
|
+
/** Minimum total user count to match together. */
|
410
|
+
min_count: number;
|
411
|
+
/** Maximum total user count to match together. */
|
412
|
+
max_count: number;
|
413
|
+
/** Filter query used to identify suitable users. */
|
414
|
+
query: string;
|
415
|
+
/** String properties describing the party (e.g. region). */
|
416
|
+
string_properties?: Record<string, string>;
|
417
|
+
/** Numeric properties describing the party (e.g. rank). */
|
418
|
+
numeric_properties?: Record<string, number>;
|
419
|
+
};
|
420
|
+
}
|
421
|
+
/** Cancel a party matchmaking process using a ticket. */
|
422
|
+
interface PartyMatchmakerRemove {
|
423
|
+
party_matchmaker_remove: {
|
424
|
+
/** The ID of the party to cancel a matchmaker ticket for. */
|
425
|
+
party_id: string;
|
426
|
+
/** The ticket to remove. */
|
427
|
+
ticket: string;
|
428
|
+
};
|
429
|
+
}
|
430
|
+
/** A response from starting a new party matchmaking process. */
|
431
|
+
export interface PartyMatchmakerTicket {
|
432
|
+
/** The ID of the party. */
|
433
|
+
party_id: string;
|
434
|
+
/** The matchmaker ticket created. */
|
435
|
+
ticket: string;
|
436
|
+
}
|
437
|
+
/** Presence update for a particular party. */
|
438
|
+
export interface PartyPresenceEvent {
|
439
|
+
/** The ID of the party. */
|
440
|
+
party_id: string;
|
441
|
+
/** The user presences that have just joined the party. */
|
442
|
+
joins: Presence[];
|
443
|
+
/** The user presences that have just left the party. */
|
444
|
+
leaves: Presence[];
|
445
|
+
}
|
446
|
+
/** Kick a party member, or decline a request to join. */
|
447
|
+
interface PartyRemove {
|
448
|
+
party_remove: {
|
449
|
+
/** The ID of the party to remove/reject from. */
|
450
|
+
party_id: string;
|
451
|
+
/** The presence to remove/reject. */
|
452
|
+
presence: Presence;
|
453
|
+
};
|
454
|
+
}
|
455
|
+
/** Execute an Lua function on the server. */
|
456
|
+
interface Rpc {
|
457
|
+
rpc: ApiRpc;
|
458
|
+
}
|
459
|
+
/** Application-level heartbeat ping. */
|
460
|
+
interface Ping {
|
461
|
+
}
|
462
|
+
/** A snapshot of statuses for some set of users. */
|
463
|
+
export interface Status {
|
464
|
+
/** The user presences to view statuses of. */
|
465
|
+
presences: Presence[];
|
466
|
+
}
|
467
|
+
/** Start receiving status updates for some set of users. */
|
468
|
+
interface StatusFollow {
|
469
|
+
/** The IDs of the users to follow. */
|
470
|
+
status_follow: {
|
471
|
+
user_ids: string[];
|
472
|
+
};
|
473
|
+
}
|
474
|
+
/** A batch of status updates for a given user. */
|
475
|
+
export interface StatusPresenceEvent {
|
476
|
+
/** This join information is in response to a subscription made to be notified when a user comes online. */
|
477
|
+
joins: Presence[];
|
478
|
+
/** This join information is in response to a subscription made to be notified when a user goes offline. */
|
479
|
+
leaves: Presence[];
|
480
|
+
}
|
481
|
+
/** Stop receiving status updates for some set of users. */
|
482
|
+
interface StatusUnfollow {
|
483
|
+
/** The IDs of user to unfollow. */
|
484
|
+
status_unfollow: {
|
485
|
+
user_ids: string[];
|
486
|
+
};
|
487
|
+
}
|
488
|
+
/** Set the user's own status. */
|
489
|
+
interface StatusUpdate {
|
490
|
+
/** Status string to set, if not present the user will appear offline. */
|
491
|
+
status_update: {
|
492
|
+
status?: string;
|
493
|
+
};
|
494
|
+
}
|
495
|
+
/** A socket connection to Mezon server. */
|
496
|
+
export interface Socket {
|
497
|
+
/** Connect to the server. */
|
498
|
+
connect(session: Session, createStatus: boolean): Promise<Session>;
|
499
|
+
/** Disconnect from the server. */
|
500
|
+
disconnect(fireDisconnectEvent: boolean): void;
|
501
|
+
/** Accept a request to join. */
|
502
|
+
acceptPartyMember(party_id: string, presence: Presence): Promise<void>;
|
503
|
+
/** End a party, kicking all party members and closing it. */
|
504
|
+
closeParty(party_id: string): Promise<void>;
|
505
|
+
/** Create a party. */
|
506
|
+
createParty(open: boolean, max_size: number): Promise<Party>;
|
507
|
+
/** Subscribe to one or more users for their status updates. */
|
508
|
+
followUsers(user_ids: string[]): Promise<Status>;
|
509
|
+
/** Join a chat channel on the server. */
|
510
|
+
joinChat(channel_id: string, channel_label: string, mode: number, type: number, persistence: boolean, hidden: boolean): Promise<Channel>;
|
511
|
+
/** Join a party. */
|
512
|
+
joinParty(party_id: string): Promise<void>;
|
513
|
+
/** Leave a chat channel on the server. */
|
514
|
+
leaveChat(channel_id: string, channel_label: string, mode: number): Promise<void>;
|
515
|
+
/** Leave a multiplayer match on the server. */
|
516
|
+
leaveMatch(matchId: string): Promise<void>;
|
517
|
+
/** Leave a party. */
|
518
|
+
leaveParty(party_id: string): Promise<void>;
|
519
|
+
/** Request a list of pending join requests for a party. */
|
520
|
+
listPartyJoinRequests(party_id: string): Promise<PartyJoinRequest>;
|
521
|
+
/** Promote a new party leader. */
|
522
|
+
promotePartyMember(party_id: string, party_member: Presence): Promise<PartyLeader>;
|
523
|
+
/** Remove a chat message from a chat channel on the server. */
|
524
|
+
removeChatMessage(channel_id: string, channel_label: string, mode: number, message_id: string): Promise<ChannelMessageAck>;
|
525
|
+
/** Kick a party member, or decline a request to join. */
|
526
|
+
removePartyMember(party_id: string, presence: Presence): Promise<void>;
|
527
|
+
/** Execute an RPC function to the server. */
|
528
|
+
rpc(id?: string, payload?: string, http_key?: string): Promise<ApiRpc>;
|
529
|
+
/** Send data to a party. */
|
530
|
+
sendPartyData(party_id: string, opcode: number, data: string | Uint8Array): Promise<void>;
|
531
|
+
/** Unfollow one or more users from their status updates. */
|
532
|
+
unfollowUsers(user_ids: string[]): Promise<void>;
|
533
|
+
/** Update a chat message on a chat channel in the server. */
|
534
|
+
updateChatMessage(channel_id: string, channel_label: string, mode: number, message_id: string, content: any): Promise<ChannelMessageAck>;
|
535
|
+
/** Update the status for the current user online. */
|
536
|
+
updateStatus(status?: string): Promise<void>;
|
537
|
+
/** Send a chat message to a chat channel on the server. */
|
538
|
+
writeChatMessage(clan_id: string, channel_id: string, channel_label: string, mode: number, content?: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, references?: Array<ApiMessageRef>): Promise<ChannelMessageAck>;
|
539
|
+
/** Send message typing */
|
540
|
+
writeMessageTyping(channel_id: string, channel_label: string, mode: number): Promise<MessageTypingEvent>;
|
541
|
+
/** Send message reaction */
|
542
|
+
writeMessageReaction(id: string, channel_id: string, channel_label: string, mode: number, message_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<MessageReactionEvent>;
|
543
|
+
/** Send message mention */
|
544
|
+
writeMessageDeleted(channel_id: string, channel_label: string, mode: number, message_id: string, deletor: string): Promise<MessageDeletedEvent>;
|
545
|
+
/** Send last seen message */
|
546
|
+
writeLastSeenMessage(channel_id: string, channel_label: string, mode: number, message_id: string, timestamp: string): Promise<LastSeenMessageEvent>;
|
547
|
+
/** send voice joined */
|
548
|
+
writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent>;
|
549
|
+
/** send voice leaved */
|
550
|
+
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, lastParticipant: boolean): Promise<VoiceLeavedEvent>;
|
551
|
+
/** Handle disconnect events received from the socket. */
|
552
|
+
ondisconnect: (evt: Event) => void;
|
553
|
+
/** Handle error events received from the socket. */
|
554
|
+
onerror: (evt: Event) => void;
|
555
|
+
/** Receive notifications from the socket. */
|
556
|
+
onnotification: (notification: Notification) => void;
|
557
|
+
/** Receive party events. */
|
558
|
+
onparty: (party: Party) => void;
|
559
|
+
/** Receive party close events. */
|
560
|
+
onpartyclose: (partyClose: PartyClose) => void;
|
561
|
+
/** Receive party data updates. */
|
562
|
+
onpartydata: (partyData: PartyData) => void;
|
563
|
+
/** Receive party join requests, if party leader. */
|
564
|
+
onpartyjoinrequest: (partyJoinRequest: PartyJoinRequest) => void;
|
565
|
+
/** Receive announcements of a new party leader. */
|
566
|
+
onpartyleader: (partyLeader: PartyLeader) => void;
|
567
|
+
/** Receive a presence update for a party. */
|
568
|
+
onpartypresence: (partyPresence: PartyPresenceEvent) => void;
|
569
|
+
/** Receive status presence updates. */
|
570
|
+
onstatuspresence: (statusPresence: StatusPresenceEvent) => void;
|
571
|
+
/** Receive stream presence updates. */
|
572
|
+
onstreampresence: (streamPresence: StreamPresenceEvent) => void;
|
573
|
+
/** Receive stream data. */
|
574
|
+
onstreamdata: (streamData: StreamData) => void;
|
575
|
+
/**
|
576
|
+
* An application-level heartbeat timeout that fires after the client does not receive a pong from the server after the heartbeat interval.
|
577
|
+
* Most browsers maintain an internal heartbeat, in which case its unlikely you'll need to use this callback. However, Chrome does not implement an internal heartbeat.
|
578
|
+
* We fire this separately from `onclose` because heartbeats fail when there's no connectivity, and many browsers don't fire `onclose` until the closing handshake either succeeds or fails.
|
579
|
+
* In any case, be aware that `onclose` will still fire if there is a heartbeat timeout in a potentially delayed manner.
|
580
|
+
*/
|
581
|
+
onheartbeattimeout: () => void;
|
582
|
+
/** Receive channel message. */
|
583
|
+
onchannelmessage: (channelMessage: ChannelMessageEvent) => void;
|
584
|
+
/** Receive typing event */
|
585
|
+
onmessagetyping: (messageTypingEvent: MessageTypingEvent) => void;
|
586
|
+
/** Receive reaction event */
|
587
|
+
onmessagereaction: (messageReactionEvent: MessageReactionEvent) => void;
|
588
|
+
/** Receive deleted message */
|
589
|
+
onmessagedeleted: (messageDeletedEvent: MessageDeletedEvent) => void;
|
590
|
+
/** Receive channel presence updates. */
|
591
|
+
onchannelpresence: (channelPresence: ChannelPresenceEvent) => void;
|
592
|
+
onvoicejoined: (voiceParticipant: VoiceJoinedEvent) => void;
|
593
|
+
onvoiceleaved: (voiceParticipant: VoiceLeavedEvent) => void;
|
594
|
+
setHeartbeatTimeoutMs(ms: number): void;
|
595
|
+
getHeartbeatTimeoutMs(): number;
|
596
|
+
}
|
597
|
+
/** Reports an error received from a socket message. */
|
598
|
+
export interface SocketError {
|
599
|
+
/** The error code. */
|
600
|
+
code: number;
|
601
|
+
/** A message in English to help developers debug the response. */
|
602
|
+
message: string;
|
603
|
+
}
|
604
|
+
/** A socket connection to Mezon server implemented with the DOM's WebSocket API. */
|
605
|
+
export declare class DefaultSocket implements Socket {
|
606
|
+
readonly host: string;
|
607
|
+
readonly port: string;
|
608
|
+
readonly useSSL: boolean;
|
609
|
+
verbose: boolean;
|
610
|
+
readonly adapter: WebSocketAdapter;
|
611
|
+
readonly sendTimeoutMs: number;
|
612
|
+
static readonly DefaultHeartbeatTimeoutMs = 10000;
|
613
|
+
static readonly DefaultSendTimeoutMs = 10000;
|
614
|
+
static readonly DefaultConnectTimeoutMs = 30000;
|
615
|
+
private readonly cIds;
|
616
|
+
private nextCid;
|
617
|
+
private _heartbeatTimeoutMs;
|
618
|
+
constructor(host: string, port: string, useSSL?: boolean, verbose?: boolean, adapter?: WebSocketAdapter, sendTimeoutMs?: number);
|
619
|
+
generatecid(): string;
|
620
|
+
connect(session: Session, createStatus?: boolean, connectTimeoutMs?: number): Promise<Session>;
|
621
|
+
disconnect(fireDisconnectEvent?: boolean): void;
|
622
|
+
setHeartbeatTimeoutMs(ms: number): void;
|
623
|
+
getHeartbeatTimeoutMs(): number;
|
624
|
+
ondisconnect(evt: Event): void;
|
625
|
+
onerror(evt: Event): void;
|
626
|
+
onmessagetyping(messagetyping: MessageTypingEvent): void;
|
627
|
+
onmessagereaction(messagereaction: MessageReactionEvent): void;
|
628
|
+
onmessagedeleted(messagedeleted: MessageDeletedEvent): void;
|
629
|
+
onchannelmessage(channelMessage: ChannelMessageEvent): void;
|
630
|
+
onchannelpresence(channelPresence: ChannelPresenceEvent): void;
|
631
|
+
onnotification(notification: Notification): void;
|
632
|
+
onparty(party: Party): void;
|
633
|
+
onpartyclose(close: PartyClose): void;
|
634
|
+
onpartyjoinrequest(partyJoinRequest: PartyJoinRequest): void;
|
635
|
+
onpartydata(partyData: PartyData): void;
|
636
|
+
onpartyleader(partyLeader: PartyLeader): void;
|
637
|
+
onpartymatchmakerticket(partyMatched: PartyMatchmakerTicket): void;
|
638
|
+
onpartypresence(partyPresence: PartyPresenceEvent): void;
|
639
|
+
onstatuspresence(statusPresence: StatusPresenceEvent): void;
|
640
|
+
onvoicejoined(voiceParticipant: VoiceJoinedEvent): void;
|
641
|
+
onvoiceleaved(voiceParticipant: VoiceLeavedEvent): void;
|
642
|
+
onstreampresence(streamPresence: StreamPresenceEvent): void;
|
643
|
+
onstreamdata(streamData: StreamData): void;
|
644
|
+
onheartbeattimeout(): void;
|
645
|
+
send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | PartyAccept | PartyClose | PartyCreate | PartyDataSend | PartyJoin | PartyJoinRequestList | PartyLeave | PartyMatchmakerAdd | PartyMatchmakerRemove | PartyPromote | PartyRemove | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout?: number): Promise<any>;
|
646
|
+
acceptPartyMember(party_id: string, presence: Presence): Promise<void>;
|
647
|
+
closeParty(party_id: string): Promise<void>;
|
648
|
+
createParty(open: boolean, max_size: number): Promise<Party>;
|
649
|
+
followUsers(userIds: string[]): Promise<Status>;
|
650
|
+
joinChat(channel_id: string, channel_label: string, mode: number, type: number, persistence: boolean, hidden: boolean): Promise<Channel>;
|
651
|
+
joinParty(party_id: string): Promise<void>;
|
652
|
+
leaveChat(channel_id: string, channel_label: string, mode: number): Promise<void>;
|
653
|
+
leaveMatch(matchId: string): Promise<void>;
|
654
|
+
leaveParty(party_id: string): Promise<void>;
|
655
|
+
listPartyJoinRequests(party_id: string): Promise<PartyJoinRequest>;
|
656
|
+
promotePartyMember(party_id: string, party_member: Presence): Promise<PartyLeader>;
|
657
|
+
removeChatMessage(channel_id: string, channel_label: string, mode: number, message_id: string): Promise<ChannelMessageAck>;
|
658
|
+
removePartyMember(party_id: string, member: Presence): Promise<void>;
|
659
|
+
rpc(id?: string, payload?: string, http_key?: string): Promise<ApiRpc>;
|
660
|
+
sendPartyData(party_id: string, op_code: number, data: string | Uint8Array): Promise<void>;
|
661
|
+
unfollowUsers(user_ids: string[]): Promise<void>;
|
662
|
+
updateChatMessage(channel_id: string, channel_label: string, mode: number, message_id: string, content: any): Promise<ChannelMessageAck>;
|
663
|
+
updateStatus(status?: string): Promise<void>;
|
664
|
+
writeChatMessage(clan_id: string, channel_id: string, channel_label: string, mode: number, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, references?: Array<ApiMessageRef>): Promise<ChannelMessageAck>;
|
665
|
+
writeMessageReaction(id: string, channel_id: string, channel_label: string, mode: number, message_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<MessageReactionEvent>;
|
666
|
+
writeMessageDeleted(channel_id: string, channel_label: string, mode: number, message_id: string): Promise<MessageDeletedEvent>;
|
667
|
+
writeMessageTyping(channel_id: string, channel_label: string, mode: number): Promise<MessageTypingEvent>;
|
668
|
+
writeLastSeenMessage(channel_id: string, channel_label: string, mode: number, message_id: string, timestamp: string): Promise<LastSeenMessageEvent>;
|
669
|
+
writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent>;
|
670
|
+
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, lastParticipant: boolean): Promise<VoiceLeavedEvent>;
|
671
|
+
private pingPong;
|
672
|
+
}
|
673
|
+
export {};
|
package/dist/utils.d.ts
ADDED