Skip to content

Commit 221e244

Browse files
Sync Typescript typings
1 parent a6a0eb8 commit 221e244

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

lib/index.d.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
type Recipient = "NET_SERVER" | Player | [Player];
22

3+
declare class Connection {
4+
public readonly connected: boolean;
5+
6+
public disconnect(): void;
7+
public reconnect(): void;
8+
}
9+
310
/**
411
* Allows for modification of queued packets before they're sent.
512
*/
@@ -141,6 +148,27 @@ declare namespace Net {
141148
* @param routes - An array of your routes
142149
*/
143150
function createHook(routes: { [index: string]: Route<any> }): LuaTuple<[() => void, () => void]>;
151+
152+
/**
153+
* Creates a connection to allow you to use Routes as if they were Signals.
154+
*
155+
* This method of reading data from Routes should be considered second-class.
156+
* The use of Route.query() in a loop will always be first-class.
157+
*
158+
* Connections will always be called on the end of frame when using YetAnotherNet.createHook()
159+
* or YetAnotherNet.start(), but will be called in the order they are received on the client.
160+
*
161+
* It is only suggested that you use these if you are working outside of a loop or outside
162+
* of an ECS system.
163+
*
164+
* @param route - The Route to observe
165+
* @param callback - The callback to run
166+
* @returns Connection
167+
*/
168+
function createConnection<T extends Array<any>>(
169+
route: Route<T>,
170+
callback: (i: number, sender: Player | "NET_SERVER", ...data: T) => void
171+
): Connection;
144172
}
145173

146174
export = Net;

0 commit comments

Comments
 (0)