SetNet.Rooms 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SetNet.Rooms --version 1.1.0
                    
NuGet\Install-Package SetNet.Rooms -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SetNet.Rooms" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SetNet.Rooms" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="SetNet.Rooms" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SetNet.Rooms --version 1.1.0
                    
#r "nuget: SetNet.Rooms, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SetNet.Rooms@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SetNet.Rooms&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=SetNet.Rooms&version=1.1.0
                    
Install as a Cake Tool

<p align="center"> <img src="https://raw.githubusercontent.com/Povstalez/SetNet/master/assets/icon.png" alt="SetNet" width="96"> </p>

SetNet.Rooms

Rooms & lobbies for SetNet — by composition, no base class.

Create and join rooms by code, broadcast within a room, and get player-joined / left / message events. Runs on a dedicated server — the server is the hub, so no relay is needed. A peer is auto-removed from its room when it disconnects.

Do I need a relay?

No. Rooms group the clients already connected to your SetNet server; the server routes messages within a room. A relay is a different topology (host-authoritative P2P, à la Among Us) where the server forwards opaque frames between a host and members — that's optional and separate. For a normal dedicated server, this package is all you need.

Install

dotnet add package SetNet
dotnet add package SetNet.MessagePack   # or your own ISerializer
dotnet add package SetNet.Rooms

At startup (once), before constructing your client/server:

using SetNet.Messaging;
using SetNet.MessagePack;
using SetNet.Rooms;

SetNetSerializer.Use(new MessagePackNetSerializer());
RoomsRuntime.Enable();   // ensures the room handlers are discovered

Server

var server = new MyServer(config);
server.UseRooms();                 // default in-memory room store
// server.UseRooms(new RedisRoomStore(...));   // or a custom IRoomStore
await server.StartAsync();

That's it — the server now handles create/join/leave/broadcast and cleans up rooms as players leave or drop.

Client

var client = new MyClient(config);
var rooms = client.UseRooms();
await client.ConnectAsync();

// Host creates a room and shares the code:
var room = await rooms.CreateAsync(new RoomOptions { MaxPlayers = 8 });
Console.WriteLine($"Join code: {room.Code}");   // e.g. "K7P2QX"

// Another player joins by code:
var joined = await rooms.JoinAsync("K7P2QX");   // throws RoomException if missing/full

// React to others:
rooms.PlayerJoined += id => Console.WriteLine($"{id} joined");
rooms.PlayerLeft   += id => Console.WriteLine($"{id} left");

// Typed broadcast: tag a message with a type id and handle it typed on the far side —
// a room can carry several message types, each routed to its own handler:
const ushort Move = 1, Chat = 2;
rooms.On<MoveMessage>(Move, (from, move) => ApplyMove(from, move));   // deserialized for you
rooms.On<ChatLine>(Chat, (from, line) => ShowChat(from, line));

await rooms.BroadcastAsync(Move, new MoveMessage { X = 1, Y = 2 });   // typed send under a type id
await rooms.BroadcastAsync(Chat, new ChatLine { Text = "gg" });

await rooms.LeaveAsync();
  • rooms.CurrentRoom gives the code, your player id, and the member list.
  • Typed broadcasts: BroadcastAsync<T>(messageType, msg) tags the message with a ushort type id; the far side routes it to the matching On<T>(messageType, …) handler, which deserializes the body for you — no raw bytes, and one room channel can multiplex many message types.
  • Raw catch-all: BroadcastAsync<T>(msg) / BroadcastAsync(byte[]) use the default type id 0; unregistered type ids fall through to MessageReceived += (from, messageType, body) => … (deserialize with SetNetSerializer.Deserialize<T>(body)). The server never touches your game types either way.

Pluggable store

Rooms live in an in-process MemoryRoomStore by default. Implement IRoomStore (async) and pass it to UseRooms(...) for custom behavior. Note: room membership is node-local (members are live connections on one server); a true multi-node/cluster room system needs a coordinator on top and is out of scope for v1.

Notes

  • Serializer-agnostic, depends only on SetNet — the room protocol is hand-framed (no MessagePack dependency); your broadcast bodies use your SetNetSerializer.
  • Uses reserved wire type ids 65526/65527/65528 — don't use those for your own messages.
  • One client per process is the norm and fully correct. Running multiple clients in one process (e.g. bots/tests) shares event routing (events are filtered by room code), so co-located clients in the same room both observe events — fine in practice, a caveat for in-process multi-client.
  • Host designation / host migration and a relay mode are planned for a future version.

Documentation & source

License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

NuGet packages (3)

Showing the top 3 NuGet packages that depend on SetNet.Rooms:

Package Downloads
SetNet.Matchmaking

Matchmaking for SetNet, on top of SetNet.Rooms: queue players into skill- or FIFO-based matches with a widening acceptance window, then drop each match into a freshly created room to join. server.UseMatchmaking(store, options) + client.UseMatchmaking().FindMatchAsync(...). Composition, no base class. Depends on SetNet + SetNet.Rooms.

SetNet.Rooms.HostMigration

Host migration for SetNet.Rooms: designates the room creator as host and promotes the next member when the host leaves/disconnects, notifying the room. server.UseHostMigration() / client.UseHostMigration(). Depends on SetNet + SetNet.Rooms.

SetNet.Redis

Redis backplane for SetNet: shared, restart-surviving implementations of ISessionStore (Auth), IBanStore (BanList) and IRoomStore (Rooms/Matchmaking) so sessions, bans and room codes work across a cluster of server nodes. Depends on SetNet.Auth + SetNet.Rooms + SetNet.BanList + StackExchange.Redis.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 173 8/5/2026
1.1.0 233 7/2/2026