This section explains basics of a threading model used by Fenrir Multiplayer
Previous Section: Docker Setup
Fenrir allows to build high-performance multi-threaded applications with very basic understanding of multi-threading.
You can call any regular operations such as peer.SendRequest, peer.SendEvent from any thread.
NetworClient events will be invoked from a single thread, running on a default Synchronization Context:
- In Unity, it will be invoked on Unity main thread.
- In a standalone .NET app, it will be invoked on a thread pool.
You can also set NetworkClient.AutoPollEvents to false and invoke NetworkClient.PollEvents manually. This allows you to trigger NetworkClient events from any thread/whenever you want.
Each Connection Handler / Request Handler invocation happens on a separate thread, specific to a Server Peer.
Room SDK simplifies multiplayer development. Each Room has it's own event loop baked by a single thread.
However, incoming requests handlers must still be scheduled to be run on a room.
Please refer to Room Management for the further details.
Request handlers can be synchronous and asynchronous. Asynchronous request handlers will use default Synchronization Context.
Please refer to Networking Basics for further details.
Next Section: Life Cycle