File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11type 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
146174export = Net ;
You can’t perform that action at this time.
0 commit comments