SetNet.Rooms.HostMigration 1.2.0

dotnet add package SetNet.Rooms.HostMigration --version 1.2.0
                    
NuGet\Install-Package SetNet.Rooms.HostMigration -Version 1.2.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.HostMigration" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SetNet.Rooms.HostMigration" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="SetNet.Rooms.HostMigration" />
                    
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.HostMigration --version 1.2.0
                    
#r "nuget: SetNet.Rooms.HostMigration, 1.2.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.HostMigration@1.2.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.HostMigration&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=SetNet.Rooms.HostMigration&version=1.2.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.HostMigration

Host migration for SetNet.Rooms.

In a room-based game one member is often the host — the authority that owns the match state, drives the simulation, or decides when to start. If that player leaves or drops, the room shouldn't die with them. This package adds host migration on top of SetNet.Rooms: it designates the room's creator (first member) as host and, when the host leaves or disconnects, automatically promotes the next remaining member and notifies everyone in the room.

You get one event — HostChanged(roomCode, newHostPlayerId) — and you decide what "being host" means for your game.

Added by composition on the same server node as your rooms; no relay, no base class.

Install

dotnet add package SetNet
dotnet add package SetNet.Rooms
dotnet add package SetNet.Rooms.HostMigration

Setup

HostMigrationRuntime.Enable();     // once at startup, both ends, before creating client/server

Server

Host migration builds on rooms, so enable rooms first, then host migration:

server.UseRooms();            // required — host migration hooks into the room lifecycle
server.UseHostMigration();    // designates a host per room + promotes on host loss

Under the hood it subscribes to the public server.RoomHooks() room-lifecycle events (peer joined / peer left) — no extra wiring needed.

Client

var rooms = client.UseRooms();
var hm    = client.UseHostMigration();

hm.HostChanged += (roomCode, newHostPlayerId) =>
{
    bool iAmHost = newHostPlayerId == rooms.CurrentRoom?.OwnPlayerId;
    if (iAmHost)
        TakeOverHostDuties();          // e.g. start driving the simulation
    else
        Log($"{newHostPlayerId} is now host of {roomCode}");
};

Compare newHostPlayerId against rooms.CurrentRoom?.OwnPlayerId to tell whether you were just promoted.

API

Client — HostMigrationClient (client.UseHostMigration()):

Member Purpose
event Action<string,string> HostChanged a room's host changed — (roomCode, newHostPlayerId)

Server — server.UseHostMigration() returns a HostMigrationServer; installs the host-tracking + promotion logic. Requires server.UseRooms(...).

Notes

  • First joiner is host. The creator of a room is its initial host. There's no explicit "claim host" call — it's implied by join order.
  • Promotion picks the next remaining member. When the host leaves or disconnects, the first of the remaining members becomes host and every remaining member receives HostChanged. If a non-host leaves, nothing is emitted. When the last member leaves, the room's host state is discarded.
  • Reliable delivery. The host-changed notification rides DeliveryMethod.Reliable.
  • Node-local, matching Rooms — hosts and members are live peers on one server node. A multi-node deployment would coordinate through a shared store.
  • Rides the unified SetNet.Protocol messaging layer on the Channels.HostMigration channel (all modules share one envelope wire type, 65447) — no per-module wire ids to reserve. Serializer-agnostic: the control protocol is hand-framed byte[], your payloads use your SetNetSerializer.

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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 149 8/5/2026
1.1.0 115 7/2/2026