Lightweight C# networking library for Unity.
This small library aims to provide a minimum, low-level networking layer, without additional abstraction layers like "component synchronization", or "remote procedure calls". You're just sending and receiving data (raw bytes) however you like, when you like. This library is only handling:
- Server / Client mode
- Connection handling (connect, disconnect)
- Events (on connected, on disconnected, received message, etc.)
- Simple message serialization, without using reflection
- Reliable / unreliable data transmission
The core, NetworkService
, is pretty much platform independent (except for two methods), and implements all network functionalities by wrapping around basic sockets, implementing server and client behaviour respectively, providing thread safe events (event queue), etc. It does so in a multi threaded way, meaning that every connection willl be handled by a dedicated thread and has it's dedicated receive buffer.
You'll never have to use this class manually in Unity! See next:
Wraps around NetworkService
as a Unity component (MonoBehaviour
), bringing everything together into the main thread (the only thread where it's legal to call the Unity API), providing events like OnClientConnected
or OnNetworkDataReceived
, which can thus be handled from anywhere within Unity. It also provides a NetworkData
interface, which generalizes data struct serilization. See "How to use" below.