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
<PackageReference Include="SetNet.Rooms.HostMigration" Version="1.2.0" />
<PackageVersion Include="SetNet.Rooms.HostMigration" Version="1.2.0" />
<PackageReference Include="SetNet.Rooms.HostMigration" />
paket add SetNet.Rooms.HostMigration --version 1.2.0
#r "nuget: SetNet.Rooms.HostMigration, 1.2.0"
#:package SetNet.Rooms.HostMigration@1.2.0
#addin nuget:?package=SetNet.Rooms.HostMigration&version=1.2.0
#tool nuget:?package=SetNet.Rooms.HostMigration&version=1.2.0
<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.HostMigrationchannel (all modules share one envelope wire type,65447) — no per-module wire ids to reserve. Serializer-agnostic: the control protocol is hand-framedbyte[], your payloads use yourSetNetSerializer.
Documentation & source
- 🐙 https://github.com/Povstalez/SetNet — full module catalog in docs/MODULES.md
License
MIT
| Product | Versions 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. |
-
.NETStandard 2.1
- SetNet.Rooms (>= 1.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.