@defold-typescript/library-types 0.24.0 → 0.26.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,706 @@
1
+ /** @noSelfInFile **/
2
+
3
+ /**
4
+ * @see {@link https://github.com/heroiclabs/nakama-defold|Github Source}
5
+ * @noResolution
6
+ */
7
+ declare module 'nakama.socket' {
8
+ /**
9
+ * A connected realtime socket. `create` copies every module export but itself onto the
10
+ * instance with the socket already applied, so each call below is the module function
11
+ * of the same name minus its leading `socket` parameter. Registering a listener
12
+ * replaces the bound method of that name, which is why a listener is registered once.
13
+ */
14
+ interface Socket {
15
+ connect(callback?: (success: boolean, error?: string) => void): unknown;
16
+ send(message: unknown, callback?: (message: unknown) => void): unknown;
17
+ on_disconnect(fn: () => void): void;
18
+ channel_join(
19
+ target: string,
20
+ type: number,
21
+ persistence: boolean,
22
+ hidden: boolean,
23
+ callback?: (message: unknown) => void,
24
+ ): unknown;
25
+ channel_leave(channel_id: string, callback?: (message: unknown) => void): unknown;
26
+ channel_message_send(
27
+ channel_id: string,
28
+ content: string,
29
+ callback?: (message: unknown) => void,
30
+ ): unknown;
31
+ channel_message_remove(
32
+ channel_id: string,
33
+ message_id: string,
34
+ callback?: (message: unknown) => void,
35
+ ): unknown;
36
+ channel_message_update(
37
+ channel_id: string,
38
+ message_id: string,
39
+ content: string,
40
+ callback?: (message: unknown) => void,
41
+ ): unknown;
42
+ match_data_send(
43
+ match_id: string,
44
+ op_code: number,
45
+ data: string,
46
+ presences: unknown,
47
+ reliable: boolean,
48
+ callback?: (message: unknown) => void,
49
+ ): unknown;
50
+ match_create(name: string | undefined, callback?: (message: unknown) => void): unknown;
51
+ match_join(
52
+ match_id: string | undefined,
53
+ token: string | undefined,
54
+ metadata: unknown,
55
+ callback?: (message: unknown) => void,
56
+ ): unknown;
57
+ match_leave(match_id: string, callback?: (message: unknown) => void): unknown;
58
+ matchmaker_add(
59
+ min_count: number,
60
+ max_count: number,
61
+ query: string,
62
+ string_properties: unknown,
63
+ numeric_properties: unknown,
64
+ count_multiple: number,
65
+ callback?: (message: unknown) => void,
66
+ ): unknown;
67
+ matchmaker_remove(ticket: string, callback?: (message: unknown) => void): unknown;
68
+ party_create(
69
+ open: boolean,
70
+ max_size: number,
71
+ callback?: (message: unknown) => void,
72
+ ): unknown;
73
+ party_join(party_id: string, callback?: (message: unknown) => void): unknown;
74
+ party_leave(party_id: string, callback?: (message: unknown) => void): unknown;
75
+ party_promote(
76
+ party_id: string,
77
+ presence: unknown,
78
+ callback?: (message: unknown) => void,
79
+ ): unknown;
80
+ party_accept(
81
+ party_id: string,
82
+ presence: unknown,
83
+ callback?: (message: unknown) => void,
84
+ ): unknown;
85
+ party_remove(
86
+ party_id: string,
87
+ presence: unknown,
88
+ callback?: (message: unknown) => void,
89
+ ): unknown;
90
+ party_close(party_id: string, callback?: (message: unknown) => void): unknown;
91
+ party_join_request_list(party_id: string, callback?: (message: unknown) => void): unknown;
92
+ party_matchmaker_add(
93
+ party_id: string,
94
+ min_count: number,
95
+ max_count: number,
96
+ query: string,
97
+ string_properties: unknown,
98
+ numeric_properties: unknown,
99
+ count_multiple: number,
100
+ callback?: (message: unknown) => void,
101
+ ): unknown;
102
+ party_matchmaker_remove(
103
+ party_id: string,
104
+ ticket: string,
105
+ callback?: (message: unknown) => void,
106
+ ): unknown;
107
+ party_data_send(
108
+ party_id: string,
109
+ op_code: number,
110
+ data: string,
111
+ callback?: (message: unknown) => void,
112
+ ): unknown;
113
+ status_follow(
114
+ user_ids: string,
115
+ usernames: string,
116
+ callback?: (message: unknown) => void,
117
+ ): unknown;
118
+ status_unfollow(user_ids: string, callback?: (message: unknown) => void): unknown;
119
+ status_update(status: string, callback?: (message: unknown) => void): unknown;
120
+ on_channel_presence_event(fn: (message: unknown) => void): void;
121
+ on_match_presence_event(fn: (message: unknown) => void): void;
122
+ on_match_data(fn: (message: unknown) => void): void;
123
+ on_match(fn: (message: unknown) => void): void;
124
+ on_matchmaker_matched(fn: (message: unknown) => void): void;
125
+ on_notifications(fn: (message: unknown) => void): void;
126
+ on_party_presence_event(fn: (message: unknown) => void): void;
127
+ on_party(fn: (message: unknown) => void): void;
128
+ on_party_data(fn: (message: unknown) => void): void;
129
+ on_party_join_request(fn: (message: unknown) => void): void;
130
+ on_party_leader(fn: (message: unknown) => void): void;
131
+ on_status_presence_event(fn: (message: unknown) => void): void;
132
+ on_status(fn: (message: unknown) => void): void;
133
+ on_stream_data(fn: (message: unknown) => void): void;
134
+ on_error(fn: (message: unknown) => void): void;
135
+ on_channel_message(fn: (message: unknown) => void): void;
136
+ }
137
+
138
+ /** Unspecified channel type. The server treats it as a room. */
139
+ const CHANNELTYPE_UNSPECIFIED: 0;
140
+ /** A room anyone can join to chat in. */
141
+ const CHANNELTYPE_ROOM: 1;
142
+ /** A private channel for one-to-one chat. */
143
+ const CHANNELTYPE_DIRECT_MESSAGE: 2;
144
+ /** A channel for group chat. */
145
+ const CHANNELTYPE_GROUP: 3;
146
+
147
+ /** An unexpected result from the server. */
148
+ const ERROR_RUNTIME_EXCEPTION: 0;
149
+ /** The server received a message it does not recognise. */
150
+ const ERROR_UNRECOGNIZED_PAYLOAD: 1;
151
+ /** A message was expected but contains no content. */
152
+ const ERROR_MISSING_PAYLOAD: 2;
153
+ /** Fields in the message have an invalid format. */
154
+ const ERROR_BAD_INPUT: 3;
155
+ /** The match id was not found. */
156
+ const ERROR_MATCH_NOT_FOUND: 4;
157
+ /** The match join was rejected. */
158
+ const ERROR_MATCH_JOIN_REJECTED: 5;
159
+ /** The runtime function does not exist on the server. */
160
+ const ERROR_RUNTIME_FUNCTION_NOT_FOUND: 6;
161
+ /** The runtime function executed with an error. */
162
+ const ERROR_RUNTIME_FUNCTION_EXCEPTION: 7;
163
+
164
+ /**
165
+ * Creates a realtime socket for a client, and binds every other export of this module
166
+ * onto it. `nakama.create_socket` is the same call reached through the core module.
167
+ * @param client A client created with `nakama.create_client`.
168
+ */
169
+ function create(client: unknown): Socket;
170
+
171
+ /**
172
+ * Opens the socket's websocket connection to the server.
173
+ * @param socket A socket created with `create`.
174
+ * @param callback Receives whether the connection succeeded, and the error if it did not.
175
+ * @returns The result, when no callback is given.
176
+ */
177
+ function connect(
178
+ socket: Socket,
179
+ callback?: (success: boolean, error?: string) => void,
180
+ ): unknown;
181
+
182
+ /**
183
+ * Sends a prepared message table on the socket. The calls below build their own
184
+ * message tables and pass them through here.
185
+ * @param socket A socket created with `create`.
186
+ * @param message The message table to send.
187
+ * @param callback Receives the server's response.
188
+ * @returns The response, when no callback is given.
189
+ */
190
+ function send(socket: Socket, message: unknown, callback?: (message: unknown) => void): unknown;
191
+
192
+ /**
193
+ * Registers the function to call when the connection drops. It is called with no
194
+ * arguments, and replaces the socket's bound `on_disconnect` method.
195
+ * @param socket A socket created with `create`.
196
+ * @param fn Called on disconnect.
197
+ */
198
+ function on_disconnect(socket: Socket, fn: () => void): void;
199
+
200
+ /**
201
+ * Joins a chat channel.
202
+ * @param socket A socket created with `create`.
203
+ * @param target The room name, group id or user id to join, depending on `type`.
204
+ * @param type One of the `CHANNELTYPE_*` constants.
205
+ * @param persistence Store the channel's messages on the server.
206
+ * @param hidden Join without appearing in the channel's presence list.
207
+ * @param callback Receives the server's response.
208
+ * @returns The response, when no callback is given.
209
+ */
210
+ function channel_join(
211
+ socket: Socket,
212
+ target: string,
213
+ type: number,
214
+ persistence: boolean,
215
+ hidden: boolean,
216
+ callback?: (message: unknown) => void,
217
+ ): unknown;
218
+
219
+ /**
220
+ * Leaves a chat channel.
221
+ * @param socket A socket created with `create`.
222
+ * @param channel_id The channel to leave.
223
+ * @param callback Receives the server's response.
224
+ * @returns The response, when no callback is given.
225
+ */
226
+ function channel_leave(
227
+ socket: Socket,
228
+ channel_id: string,
229
+ callback?: (message: unknown) => void,
230
+ ): unknown;
231
+
232
+ /**
233
+ * Sends a message to a joined chat channel.
234
+ * @param socket A socket created with `create`.
235
+ * @param channel_id The channel to send to.
236
+ * @param content The message content, as a JSON string.
237
+ * @param callback Receives the server's response.
238
+ * @returns The response, when no callback is given.
239
+ */
240
+ function channel_message_send(
241
+ socket: Socket,
242
+ channel_id: string,
243
+ content: string,
244
+ callback?: (message: unknown) => void,
245
+ ): unknown;
246
+
247
+ /**
248
+ * Removes a message previously sent to a chat channel.
249
+ * @param socket A socket created with `create`.
250
+ * @param channel_id The channel the message is in.
251
+ * @param message_id The message to remove.
252
+ * @param callback Receives the server's response.
253
+ * @returns The response, when no callback is given.
254
+ */
255
+ function channel_message_remove(
256
+ socket: Socket,
257
+ channel_id: string,
258
+ message_id: string,
259
+ callback?: (message: unknown) => void,
260
+ ): unknown;
261
+
262
+ /**
263
+ * Replaces the content of a message previously sent to a chat channel.
264
+ * @param socket A socket created with `create`.
265
+ * @param channel_id The channel the message is in.
266
+ * @param message_id The message to update.
267
+ * @param content The replacement content, as a JSON string.
268
+ * @param callback Receives the server's response.
269
+ * @returns The response, when no callback is given.
270
+ */
271
+ function channel_message_update(
272
+ socket: Socket,
273
+ channel_id: string,
274
+ message_id: string,
275
+ content: string,
276
+ callback?: (message: unknown) => void,
277
+ ): unknown;
278
+
279
+ /**
280
+ * Sends data to a joined match. The data is base64-encoded on the way out and decoded
281
+ * again for the receiving `on_match_data` listener.
282
+ * @param socket A socket created with `create`.
283
+ * @param match_id The match to send to.
284
+ * @param op_code The application-defined operation code.
285
+ * @param data The payload.
286
+ * @param presences The presences to send to, or nil for everyone in the match.
287
+ * @param reliable Send over the reliable channel.
288
+ * @param callback Receives the server's response.
289
+ * @returns The response, when no callback is given.
290
+ */
291
+ function match_data_send(
292
+ socket: Socket,
293
+ match_id: string,
294
+ op_code: number,
295
+ data: string,
296
+ presences: unknown,
297
+ reliable: boolean,
298
+ callback?: (message: unknown) => void,
299
+ ): unknown;
300
+
301
+ /**
302
+ * Creates a new authoritative-relayed match.
303
+ * @param socket A socket created with `create`.
304
+ * @param name The match name, or nil to let the server generate one.
305
+ * @param callback Receives the server's response.
306
+ * @returns The response, when no callback is given.
307
+ */
308
+ function match_create(
309
+ socket: Socket,
310
+ name: string | undefined,
311
+ callback?: (message: unknown) => void,
312
+ ): unknown;
313
+
314
+ /**
315
+ * Joins a match by id, or by the token a matchmaker result carried. Exactly one of the
316
+ * two identifiers is set; the other is nil.
317
+ * @param socket A socket created with `create`.
318
+ * @param match_id The match to join.
319
+ * @param token The match token, when joining a matchmaker result.
320
+ * @param metadata Metadata to present to the match's other members.
321
+ * @param callback Receives the server's response.
322
+ * @returns The response, when no callback is given.
323
+ */
324
+ function match_join(
325
+ socket: Socket,
326
+ match_id: string | undefined,
327
+ token: string | undefined,
328
+ metadata: unknown,
329
+ callback?: (message: unknown) => void,
330
+ ): unknown;
331
+
332
+ /**
333
+ * Leaves a joined match.
334
+ * @param socket A socket created with `create`.
335
+ * @param match_id The match to leave.
336
+ * @param callback Receives the server's response.
337
+ * @returns The response, when no callback is given.
338
+ */
339
+ function match_leave(
340
+ socket: Socket,
341
+ match_id: string,
342
+ callback?: (message: unknown) => void,
343
+ ): unknown;
344
+
345
+ /**
346
+ * Joins the matchmaker pool. The ticket the server returns is what
347
+ * `matchmaker_remove` cancels with, and a match arrives through `on_matchmaker_matched`.
348
+ * @param socket A socket created with `create`.
349
+ * @param min_count The smallest acceptable match size.
350
+ * @param max_count The largest acceptable match size.
351
+ * @param query The matchmaker query to filter candidates by.
352
+ * @param string_properties This user's string properties, for other queries to match on.
353
+ * @param numeric_properties This user's numeric properties, for other queries to match on.
354
+ * @param count_multiple Only form matches whose size is a multiple of this.
355
+ * @param callback Receives the server's response.
356
+ * @returns The response, when no callback is given.
357
+ */
358
+ function matchmaker_add(
359
+ socket: Socket,
360
+ min_count: number,
361
+ max_count: number,
362
+ query: string,
363
+ string_properties: unknown,
364
+ numeric_properties: unknown,
365
+ count_multiple: number,
366
+ callback?: (message: unknown) => void,
367
+ ): unknown;
368
+
369
+ /**
370
+ * Leaves the matchmaker pool.
371
+ * @param socket A socket created with `create`.
372
+ * @param ticket The ticket `matchmaker_add` returned.
373
+ * @param callback Receives the server's response.
374
+ * @returns The response, when no callback is given.
375
+ */
376
+ function matchmaker_remove(
377
+ socket: Socket,
378
+ ticket: string,
379
+ callback?: (message: unknown) => void,
380
+ ): unknown;
381
+
382
+ /**
383
+ * Creates a party and makes this user its leader.
384
+ * @param socket A socket created with `create`.
385
+ * @param open Let users join without a join request.
386
+ * @param max_size The largest number of members the party accepts.
387
+ * @param callback Receives the server's response.
388
+ * @returns The response, when no callback is given.
389
+ */
390
+ function party_create(
391
+ socket: Socket,
392
+ open: boolean,
393
+ max_size: number,
394
+ callback?: (message: unknown) => void,
395
+ ): unknown;
396
+
397
+ /**
398
+ * Joins a party, or requests to join one that is not open.
399
+ * @param socket A socket created with `create`.
400
+ * @param party_id The party to join.
401
+ * @param callback Receives the server's response.
402
+ * @returns The response, when no callback is given.
403
+ */
404
+ function party_join(
405
+ socket: Socket,
406
+ party_id: string,
407
+ callback?: (message: unknown) => void,
408
+ ): unknown;
409
+
410
+ /**
411
+ * Leaves a party.
412
+ * @param socket A socket created with `create`.
413
+ * @param party_id The party to leave.
414
+ * @param callback Receives the server's response.
415
+ * @returns The response, when no callback is given.
416
+ */
417
+ function party_leave(
418
+ socket: Socket,
419
+ party_id: string,
420
+ callback?: (message: unknown) => void,
421
+ ): unknown;
422
+
423
+ /**
424
+ * Promotes a party member to leader.
425
+ * @param socket A socket created with `create`.
426
+ * @param party_id The party the member is in.
427
+ * @param presence The member's presence.
428
+ * @param callback Receives the server's response.
429
+ * @returns The response, when no callback is given.
430
+ */
431
+ function party_promote(
432
+ socket: Socket,
433
+ party_id: string,
434
+ presence: unknown,
435
+ callback?: (message: unknown) => void,
436
+ ): unknown;
437
+
438
+ /**
439
+ * Accepts a pending join request, as party leader.
440
+ * @param socket A socket created with `create`.
441
+ * @param party_id The party the request is for.
442
+ * @param presence The requesting user's presence.
443
+ * @param callback Receives the server's response.
444
+ * @returns The response, when no callback is given.
445
+ */
446
+ function party_accept(
447
+ socket: Socket,
448
+ party_id: string,
449
+ presence: unknown,
450
+ callback?: (message: unknown) => void,
451
+ ): unknown;
452
+
453
+ /**
454
+ * Removes a member from the party, or rejects a pending join request.
455
+ * @param socket A socket created with `create`.
456
+ * @param party_id The party to remove from.
457
+ * @param presence The member's presence.
458
+ * @param callback Receives the server's response.
459
+ * @returns The response, when no callback is given.
460
+ */
461
+ function party_remove(
462
+ socket: Socket,
463
+ party_id: string,
464
+ presence: unknown,
465
+ callback?: (message: unknown) => void,
466
+ ): unknown;
467
+
468
+ /**
469
+ * Closes the party to new members and disbands it, as party leader.
470
+ * @param socket A socket created with `create`.
471
+ * @param party_id The party to close.
472
+ * @param callback Receives the server's response.
473
+ * @returns The response, when no callback is given.
474
+ */
475
+ function party_close(
476
+ socket: Socket,
477
+ party_id: string,
478
+ callback?: (message: unknown) => void,
479
+ ): unknown;
480
+
481
+ /**
482
+ * Lists the party's pending join requests.
483
+ * @param socket A socket created with `create`.
484
+ * @param party_id The party to list requests for.
485
+ * @param callback Receives the server's response.
486
+ * @returns The response, when no callback is given.
487
+ */
488
+ function party_join_request_list(
489
+ socket: Socket,
490
+ party_id: string,
491
+ callback?: (message: unknown) => void,
492
+ ): unknown;
493
+
494
+ /**
495
+ * Joins the matchmaker pool as a whole party, as party leader.
496
+ * @param socket A socket created with `create`.
497
+ * @param party_id The party to match with.
498
+ * @param min_count The smallest acceptable match size.
499
+ * @param max_count The largest acceptable match size.
500
+ * @param query The matchmaker query to filter candidates by.
501
+ * @param string_properties The party's string properties, for other queries to match on.
502
+ * @param numeric_properties The party's numeric properties, for other queries to match on.
503
+ * @param count_multiple Only form matches whose size is a multiple of this.
504
+ * @param callback Receives the server's response.
505
+ * @returns The response, when no callback is given.
506
+ */
507
+ function party_matchmaker_add(
508
+ socket: Socket,
509
+ party_id: string,
510
+ min_count: number,
511
+ max_count: number,
512
+ query: string,
513
+ string_properties: unknown,
514
+ numeric_properties: unknown,
515
+ count_multiple: number,
516
+ callback?: (message: unknown) => void,
517
+ ): unknown;
518
+
519
+ /**
520
+ * Takes the party back out of the matchmaker pool.
521
+ * @param socket A socket created with `create`.
522
+ * @param party_id The party to cancel for.
523
+ * @param ticket The ticket `party_matchmaker_add` returned.
524
+ * @param callback Receives the server's response.
525
+ * @returns The response, when no callback is given.
526
+ */
527
+ function party_matchmaker_remove(
528
+ socket: Socket,
529
+ party_id: string,
530
+ ticket: string,
531
+ callback?: (message: unknown) => void,
532
+ ): unknown;
533
+
534
+ /**
535
+ * Sends data to every member of a party.
536
+ * @param socket A socket created with `create`.
537
+ * @param party_id The party to send to.
538
+ * @param op_code The application-defined operation code.
539
+ * @param data The payload.
540
+ * @param callback Receives the server's response.
541
+ * @returns The response, when no callback is given.
542
+ */
543
+ function party_data_send(
544
+ socket: Socket,
545
+ party_id: string,
546
+ op_code: number,
547
+ data: string,
548
+ callback?: (message: unknown) => void,
549
+ ): unknown;
550
+
551
+ /**
552
+ * Subscribes to the status updates of the given users.
553
+ * @param socket A socket created with `create`.
554
+ * @param user_ids The user ids to follow.
555
+ * @param usernames The usernames to follow.
556
+ * @param callback Receives the server's response.
557
+ * @returns The response, when no callback is given.
558
+ */
559
+ function status_follow(
560
+ socket: Socket,
561
+ user_ids: string,
562
+ usernames: string,
563
+ callback?: (message: unknown) => void,
564
+ ): unknown;
565
+
566
+ /**
567
+ * Unsubscribes from the status updates of the given users.
568
+ * @param socket A socket created with `create`.
569
+ * @param user_ids The user ids to unfollow.
570
+ * @param callback Receives the server's response.
571
+ * @returns The response, when no callback is given.
572
+ */
573
+ function status_unfollow(
574
+ socket: Socket,
575
+ user_ids: string,
576
+ callback?: (message: unknown) => void,
577
+ ): unknown;
578
+
579
+ /**
580
+ * Sets this user's status message, or clears it when the status is empty.
581
+ * @param socket A socket created with `create`.
582
+ * @param status The status message to publish to followers.
583
+ * @param callback Receives the server's response.
584
+ * @returns The response, when no callback is given.
585
+ */
586
+ function status_update(
587
+ socket: Socket,
588
+ status: string,
589
+ callback?: (message: unknown) => void,
590
+ ): unknown;
591
+
592
+ /**
593
+ * Registers the function to call when someone joins or leaves a joined chat channel.
594
+ * @param socket A socket created with `create`.
595
+ * @param fn Receives the channel presence event.
596
+ */
597
+ function on_channel_presence_event(socket: Socket, fn: (message: unknown) => void): void;
598
+
599
+ /**
600
+ * Registers the function to call when someone joins or leaves a joined match.
601
+ * @param socket A socket created with `create`.
602
+ * @param fn Receives the match presence event.
603
+ */
604
+ function on_match_presence_event(socket: Socket, fn: (message: unknown) => void): void;
605
+
606
+ /**
607
+ * Registers the function to call when match data arrives. The payload is
608
+ * base64-decoded before the listener sees it.
609
+ * @param socket A socket created with `create`.
610
+ * @param fn Receives the match data.
611
+ */
612
+ function on_match_data(socket: Socket, fn: (message: unknown) => void): void;
613
+
614
+ /**
615
+ * Registers the function to call when a match is created or joined.
616
+ * @param socket A socket created with `create`.
617
+ * @param fn Receives the match.
618
+ */
619
+ function on_match(socket: Socket, fn: (message: unknown) => void): void;
620
+
621
+ /**
622
+ * Registers the function to call when the matchmaker finds a match. Its token is what
623
+ * `match_join` takes.
624
+ * @param socket A socket created with `create`.
625
+ * @param fn Receives the matchmaker result.
626
+ */
627
+ function on_matchmaker_matched(socket: Socket, fn: (message: unknown) => void): void;
628
+
629
+ /**
630
+ * Registers the function to call when notifications arrive for this user.
631
+ * @param socket A socket created with `create`.
632
+ * @param fn Receives the notifications.
633
+ */
634
+ function on_notifications(socket: Socket, fn: (message: unknown) => void): void;
635
+
636
+ /**
637
+ * Registers the function to call when someone joins or leaves a joined party.
638
+ * @param socket A socket created with `create`.
639
+ * @param fn Receives the party presence event.
640
+ */
641
+ function on_party_presence_event(socket: Socket, fn: (message: unknown) => void): void;
642
+
643
+ /**
644
+ * Registers the function to call when a party is created or joined.
645
+ * @param socket A socket created with `create`.
646
+ * @param fn Receives the party.
647
+ */
648
+ function on_party(socket: Socket, fn: (message: unknown) => void): void;
649
+
650
+ /**
651
+ * Registers the function to call when party data arrives.
652
+ * @param socket A socket created with `create`.
653
+ * @param fn Receives the party data.
654
+ */
655
+ function on_party_data(socket: Socket, fn: (message: unknown) => void): void;
656
+
657
+ /**
658
+ * Registers the function to call when someone asks to join a party this user leads.
659
+ * @param socket A socket created with `create`.
660
+ * @param fn Receives the join request.
661
+ */
662
+ function on_party_join_request(socket: Socket, fn: (message: unknown) => void): void;
663
+
664
+ /**
665
+ * Registers the function to call when a party changes leader.
666
+ * @param socket A socket created with `create`.
667
+ * @param fn Receives the new leader.
668
+ */
669
+ function on_party_leader(socket: Socket, fn: (message: unknown) => void): void;
670
+
671
+ /**
672
+ * Registers the function to call when a followed user comes online or goes offline.
673
+ * @param socket A socket created with `create`.
674
+ * @param fn Receives the status presence event.
675
+ */
676
+ function on_status_presence_event(socket: Socket, fn: (message: unknown) => void): void;
677
+
678
+ /**
679
+ * Registers the function to call when a followed user changes their status message.
680
+ * @param socket A socket created with `create`.
681
+ * @param fn Receives the status.
682
+ */
683
+ function on_status(socket: Socket, fn: (message: unknown) => void): void;
684
+
685
+ /**
686
+ * Registers the function to call when data arrives on a subscribed stream.
687
+ * @param socket A socket created with `create`.
688
+ * @param fn Receives the stream data.
689
+ */
690
+ function on_stream_data(socket: Socket, fn: (message: unknown) => void): void;
691
+
692
+ /**
693
+ * Registers the function to call when the server reports an error. Its code is one of
694
+ * the `ERROR_*` constants.
695
+ * @param socket A socket created with `create`.
696
+ * @param fn Receives the error.
697
+ */
698
+ function on_error(socket: Socket, fn: (message: unknown) => void): void;
699
+
700
+ /**
701
+ * Registers the function to call when a message arrives on a joined chat channel.
702
+ * @param socket A socket created with `create`.
703
+ * @param fn Receives the channel message.
704
+ */
705
+ function on_channel_message(socket: Socket, fn: (message: unknown) => void): void;
706
+ }