Skip to main content

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.

A Data-driven Networking Library

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.

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 and even perform data compression or decompression before data is processed.

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 or compress/decompress data. 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.

To compress/decompress your data, you can use a library like Squash to serialize and deserialize your data. Simply return the types in order as a tuple, you can use the event parameter to determine whether to compress or decompress your data.

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.