@rbxts/tether 1.4.0 → 1.4.2

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.
@@ -1,128 +0,0 @@
1
- import { Modding } from "@flamework/core";
2
- import Destroyable from "@rbxts/destroyable";
3
- import { MiddlewareProvider } from "./middleware";
4
- import type { ClientMessageCallback, ServerMessageCallback, BaseMessage, MessageEmitterMetadata, ClientMessageFunctionCallback, ServerMessageFunctionCallback } from "./structs";
5
- interface MessageEmitterOptions {
6
- readonly batchRemotes: boolean;
7
- readonly batchRate: number;
8
- }
9
- export declare class MessageEmitter<MessageData> extends Destroyable {
10
- private readonly options;
11
- readonly middleware: MiddlewareProvider<MessageData>;
12
- private readonly guards;
13
- private serializers;
14
- private clientCallbacks;
15
- private clientFunctions;
16
- private serverCallbacks;
17
- private serverFunctions;
18
- private serverQueue;
19
- private clientBroadcastQueue;
20
- private clientQueue;
21
- /** @metadata macro */
22
- static create<MessageData>(options?: Partial<MessageEmitterOptions>, meta?: Modding.Many<MessageEmitterMetadata<MessageData>>): MessageEmitter<MessageData>;
23
- private constructor();
24
- readonly server: {
25
- /**
26
- * @returns A destructor function that disconnects the callback from the message
27
- */
28
- on: <Kind extends keyof MessageData>(message: Kind & BaseMessage, callback: ServerMessageCallback<MessageData[Kind]>) => () => void;
29
- /**
30
- * Disconnects the callback as soon as it is called for the first time
31
- *
32
- * @returns A destructor function that disconnects the callback from the message
33
- */
34
- once: <Kind extends keyof MessageData>(message: Kind & BaseMessage, callback: ServerMessageCallback<MessageData[Kind]>) => () => void;
35
- /**
36
- * Emits a message to the server
37
- *
38
- * @param message The message kind to be sent
39
- * @param data The data associated with the message
40
- * @param unreliable Whether the message should be sent unreliably
41
- */
42
- emit: <Kind extends keyof MessageData>(message: Kind & BaseMessage, data?: MessageData[Kind], unreliable?: boolean) => void;
43
- /**
44
- * Simulates a remote function invocation.
45
- *
46
- * @param message The message kind to be sent
47
- * @param data The data associated with the message
48
- * @param unreliable Whether the message should be sent unreliably
49
- */
50
- invoke: <Kind extends keyof MessageData, ReturnKind extends keyof MessageData>(message: Kind & BaseMessage, returnMessage: ReturnKind & BaseMessage, data?: MessageData[Kind], unreliable?: boolean) => Promise<MessageData[ReturnKind]>;
51
- /**
52
- * Sets a callback for a simulated remote function
53
- *
54
- * @returns A destructor function that disconnects the callback from the message
55
- */
56
- setCallback: <Kind extends keyof MessageData, ReturnKind extends keyof MessageData>(message: Kind & BaseMessage, returnMessage: ReturnKind & BaseMessage, callback: ServerMessageFunctionCallback<MessageData[Kind], MessageData[ReturnKind]>) => () => void;
57
- };
58
- readonly client: {
59
- /**
60
- * @returns A destructor function that disconnects the callback from the message
61
- */
62
- on: <Kind extends keyof MessageData>(message: Kind & BaseMessage, callback: ClientMessageCallback<MessageData[Kind]>) => () => void;
63
- /**
64
- * Disconnects the callback as soon as it is called for the first time
65
- *
66
- * @returns A destructor function that disconnects the callback from the message
67
- */
68
- once: <Kind extends keyof MessageData>(message: Kind & BaseMessage, callback: ClientMessageCallback<MessageData[Kind]>) => () => void;
69
- /**
70
- * Emits a message to a specific client or multiple clients
71
- *
72
- * @param player The player(s) to whom the message is sent
73
- * @param message The message kind to be sent
74
- * @param data The data associated with the message
75
- * @param unreliable Whether the message should be sent unreliably
76
- */
77
- emit: <Kind extends keyof MessageData>(player: Player | Player[], message: Kind & BaseMessage, data?: MessageData[Kind], unreliable?: boolean) => void;
78
- /**
79
- * Emits a message to all clients except the specified client(s)
80
- *
81
- * @param player The player(s) to whom the message is not sent
82
- * @param message The message kind to be sent
83
- * @param data The data associated with the message
84
- * @param unreliable Whether the message should be sent unreliably
85
- */
86
- emitExcept: <Kind extends keyof MessageData>(player: Player | Player[], message: Kind & BaseMessage, data?: MessageData[Kind], unreliable?: boolean) => void;
87
- /**
88
- * Emits a message to all connected clients
89
- *
90
- * @param message The message kind to be sent
91
- * @param data The data associated with the message
92
- * @param unreliable Whether the message should be sent unreliably
93
- */
94
- emitAll: <Kind extends keyof MessageData>(message: Kind & BaseMessage, data?: MessageData[Kind], unreliable?: boolean) => void;
95
- /**
96
- * Simulates a remote function invocation.
97
- *
98
- * @param message The message kind to be sent
99
- * @param data The data associated with the message
100
- * @param unreliable Whether the message should be sent unreliably
101
- */
102
- invoke: <Kind extends keyof MessageData, ReturnKind extends keyof MessageData>(message: Kind & BaseMessage, returnMessage: ReturnKind & BaseMessage, player: Player, data?: MessageData[Kind], unreliable?: boolean) => Promise<MessageData[ReturnKind]>;
103
- /**
104
- * Sets a callback for a simulated remote function
105
- *
106
- * @returns A destructor function that disconnects the callback from the message
107
- */
108
- setCallback: <Kind extends keyof MessageData, ReturnKind extends keyof MessageData>(message: Kind & BaseMessage, returnMessage: ReturnKind & BaseMessage, callback: ClientMessageFunctionCallback<MessageData[Kind], MessageData[ReturnKind]>) => () => void;
109
- };
110
- private initialize;
111
- private update;
112
- private runClientMiddlewares;
113
- private runServerMiddlewares;
114
- private validateData;
115
- private onRemoteFire;
116
- private executeFunctions;
117
- private executeEventCallbacks;
118
- private deserializeAndValidate;
119
- private once;
120
- private on;
121
- private getPacket;
122
- /** @metadata macro */
123
- private addSerializer;
124
- /** @metadata macro */
125
- private createMessageSerializer;
126
- private getSerializer;
127
- }
128
- export {};