A Type-safe Networking Library
YetAnotherNet is strictly-typed, giving you full auto-completion and type-safety.
Send arguments and Query return values of your Routes are fully typed, giving you auto-completion and type-checking when writing your Networking code.
Hassle-free Compression Included
YetAnotherNet works behind the scenes to automatically compress the data you send over the network. It features an internal Ser/Des library to serialize all Luau Datatypes and most Roblox Datatypes.
This process requires no work on the user's end besides making sure to avoid any Unsupported Datatypes.
Data-driven by Design
With it's roots in ECS, YetAnotherNet was designed to promote a Data-driven design.
YetAnotherNet's API integrates seamlessly into ECS Libraries like Matter to bring Data-driven Networking in ECS architectures.
Read more on why you should use an ECS here.
Available for Roblox Typescript
We provide Typings for Roblox Typescript users, you can get them on NPM here, or you can install using npm i @rbxts/yetanothernet
.
Routes
Routes are the way you send and receive data through YetAnotherNet. They are uniquely identified so you're encouraged to create as many as you need as if you were creating individual RemoteEvents.
Routes can be Reliable or Unreliable. Reliable events are never dropped and are always in order per frame. Unreliable events might be dropped on bad connections, but they are always received in order per frame.
You can also strictly type Routes to get autocompletion and typechecking when Sending and Querying packets.
Middleware
Middleware is another powerful feature of YetAnotherNet, allowing you to validate types before they reach your code.
To create Middleware, you set a function in your Route's Middleware that will give you the event "send" | "receive"
and the data that is about to be processed U...
, the types you specify in your type annotation Net<U...>
In the Middleware function, you can validate your types. If your data does not match your types, you can do return nil
to drop the packet. Dropped packets will never reach your code, meaning you can ensure that the types your code receives are always the types you expect.
You may want to use Middleware to Compress or Decompress your data, but YetAnotherNet has built-in buffer compression!
Hooks
Hooks are a simple and versatile way to integrate YetAnotherNet into any code architecture.
Hooks allow you to run your Route's scheduling whenever you want, such as a specific event. A Hook is simply a function that you can call which will run each Route's scheduling code to process the current frame. Data is not sent over the Network until your hook is called.
YetAnotherNet also provides a simple function that hooks your Routes to your Matter Middleware to run before/after your systems. This allows for a simple setup when using the Matter ECS, leaving you to not worry about scheduling your Routes.