Colyseus.MonoGame
0.17.16
dotnet add package Colyseus.MonoGame --version 0.17.16
NuGet\Install-Package Colyseus.MonoGame -Version 0.17.16
<PackageReference Include="Colyseus.MonoGame" Version="0.17.16" />
<PackageVersion Include="Colyseus.MonoGame" Version="0.17.16" />
<PackageReference Include="Colyseus.MonoGame" />
paket add Colyseus.MonoGame --version 0.17.16
#r "nuget: Colyseus.MonoGame, 0.17.16"
#:package Colyseus.MonoGame@0.17.16
#addin nuget:?package=Colyseus.MonoGame&version=0.17.16
#tool nuget:?package=Colyseus.MonoGame&version=0.17.16
<div align="center"> <a href="https://colyseus.io/"> <img src="https://github.com/colyseus/colyseus/blob/master/media/logo.svg?raw=true" width="40%" /> </a> <h3>Colyseus Multiplayer SDK for MonoGame</h3> </div>
MonoGame integration for Colyseus — provides a GameComponent that automatically dispatches WebSocket events on the game loop.
Installation
dotnet add package Colyseus.MonoGame
This installs the core Colyseus SDK as a dependency.
Setup
Register the ColyseusGameComponent in your game's Initialize() method:
using Colyseus.MonoGame;
protected override void Initialize()
{
Components.Add(new ColyseusGameComponent(this));
base.Initialize();
}
This single line handles all WebSocket event dispatching on the game thread — no manual polling needed.
Quick Example
using Microsoft.Xna.Framework;
using Colyseus;
using Colyseus.Schema;
using Colyseus.MonoGame;
public class Game1 : Game
{
Client client;
Room<MyRoomState> room;
protected override void Initialize()
{
Components.Add(new ColyseusGameComponent(this));
base.Initialize();
}
protected override async void LoadContent()
{
client = new Client("ws://localhost:2567");
room = await client.JoinOrCreate<MyRoomState>("my_room");
var callbacks = Callbacks.Get(room);
callbacks.OnAdd(state => state.players, (sessionId, player) => {
System.Diagnostics.Debug.WriteLine($"Player joined: {sessionId}");
});
room.Send("move", new { x = 10f, y = 20f });
room.OnMessage<string>("chat", (message) => {
System.Diagnostics.Debug.WriteLine("Chat: " + message);
});
}
protected override void OnExiting(object sender, EventArgs args)
{
if (room != null) room.Leave();
base.OnExiting(sender, args);
}
}
Documentation
See the full documentation at https://docs.colyseus.io/getting-started/monogame
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Colyseus (>= 0.17.0 && < 0.18.0)
- Colyseus.NativeWebSocket (>= 2.0.0)
- MonoGame.Framework.DesktopGL (>= 3.8.2.1105)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.