RedGrin is an opinionated wrapper for Lidgren that attempts to simplify multiplayer networking for small indie games. Redgrin was written specifically for the FlatRedBall game engine but should be compatible with any C# game engine including MonoGame and Unity.
Redgrin defines an architecture and communication pattern that abstracts away many of the complex details of networking. Redgrin takes care of:
- Choosing the right message type
- Serializing and deserializing transfer messages
- Giving entities unique identifiers across all clients
- Keeping track of an instance role (Client or Server)
- Allowing role-based logic
- Performing dead reckoning
- Client-server architecture
Redgrin does not do partitioning, input prediction, physics interpolation, cheating detection or other logic that tends to be game-specific. The interfaces provide methods and arguments allowing developers to determine how their game should handle entity ownership, latency, and other multiplayer details.
At a high level, Redgrin works like this:
- Define transfer classes for each entity that describes its state so it can be synced across the network. Defining transfer types up front allows automatic serialization of transfer objects into network messages.
- Create a
NetworkConfiguration
instance that defines app name, port numbers, and lists the transfer class types. - Each entity that needs to sync across the network should implement the
INetworkEntity
interface. - Your game level/screen/arena should implement the
INetworkArena
interface. - Call
NetworkManager.Self.Update()
in your game loop to run the networking processes. - Call
NetworkManager.Self.Initialize
with yourNetworkConfiguration
object and an optional logger to initialize the network. - Call
NetworkManager.Self.Start
to start the network in a role (Client or Server). - Call
Connect
with an IP address to connect to a server. - The
NetworkManager
has methods to create, delete and update entities. It will automatically call methods onINetworkEntity
objects and theINetworkArena
to manage the synchronization of objects across the network.
These whitepapers/articles have been helpful for me: