Route
A Networking Library, inspired by BridgeNet2 & Bevy_Renet, made for ECS.
See the Intro to get started.
Types
Configuration
interface
Configuration {
Channel:
(
"Reliable"
|
"Unreliable"
)
?
--
Default: Reliable
Event:
string?
--
The event to schedule the Route on in your Matter Loop -- Default: "default"
Ratelimit:
number?
--
Amount of allowed invocations a frame
}
NOTE
Ratelimiting is not implemented yet. This feature will come in future versions.
Channel
Reliable: All packets will be sent and received per frame in order. Unreliable: Packets may be dropped but will be received in order.
Functions
new
Creates a new Route with a unique identifier, channel, and event.
NOTE
All Routes with the same Channel will share a single Remote. It's recommended that you run all your Net scheduling code on a single event.
query
Allows for iteration of all packets of the previous frame.
You can filter by Senders by chaining the QueryResult:from()
method onto the query method.
NOTE
Due to certain limitations with the Luau Type System, iterating over the QueryResult Object
will not return typed values. In order to fix this, call :__iter()
on the QueryResult Object.
For example:
for i, sender, ... in route:query():__iter() do
-- Do something
end
See Querying Data for more information.
send
Sends data to all clients or to specific recipients from the Route's identifier.
By default, Route:send will send the data to all Clients. You can specify which
Clients to receive the data by chaining SendRequest:to and passing
{ Player }
, Player
, or Route.Server
.
See Sending Data for more information.
addIncomingMiddleware
Route:
addIncomingMiddleware
(
(...any):
→
(
...any?
)
) →
(
)
Sets a function to be ran on Incoming packets before they are processed.
For example, this would run after the Client receives a Packet from the Server over the network:
after calling Route:send()
on the Server and before calling Route:query()
on the Client.
See Middleware for more information.
addOutgoingMiddleware
Route:
addOutgoingMiddleware
(
(...any):
→
(
...any?
)
) →
(
)
Sets a function to be ran on Outgoing packets before they are sent over the network.
For example, this would run before the Server sends a Packet to the Client over the network:
after calling Route:send()
on the Server and before the Client ever receives the Packet.
See Middleware for more information.