SetNet.Zones 1.2.0

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

Seamless player handoff between world nodes for SetNet.

A big world runs across many nodes, one per zone/region. When a player crosses a boundary, SetNet.Zones moves them without a re-login: the origin node stashes the player's carried state under a one-time token and pushes the client a migrate here instruction; the client reconnects to the destination node and claims the token to get its state back. The state travels through a pluggable IHandoffStore (share a Redis/DB store across nodes so the destination process can read what the origin wrote). Added by composition — no base class.

Install

dotnet add package SetNet
dotnet add package SetNet.Zones

Usage

Call ZonesRuntime.Enable() once at startup on both ends. Every node shares one handoff store.

Server node — hand a player off when they cross into another zone:

ZonesRuntime.Enable();
var zones = server.UseZones(sharedHandoffStore);   // same store instance/backend on every node

// game logic: player walked into the "desert" zone owned by another node
byte[] carried = SerializePlayer(player);          // position, buffs, current action…
await zones.TransferAsync(peer, new ZoneTarget("desert", "desert.game.example", 5000), carried);

Client — follow the handoff:

ZonesRuntime.Enable();
var zones = client.UseZones();

zones.TransferRequested += async transfer =>
{
    var next = new GameClient(new Configuration { Host = transfer.Target.Host, Port = transfer.Target.Port /* ... */ });
    var nextZones = next.UseZones();
    await next.ConnectAsync();

    byte[] carried = await nextZones.ClaimAsync(transfer.Token);   // state from the origin node
    RestorePlayer(carried);                                        // spawn seamlessly in the new zone
    oldClient.Disconnect();
};

API

Server: server.UseZones(IHandoffStore?, ZoneOptions?) → ZonesServer

Member Purpose
Task<string> TransferAsync(peer, ZoneTarget, byte[] carryState) stash state + push a migrate instruction; returns the token
KeyOf(peer) the peer's stable player key

Client: var zones = client.UseZones() → ZonesClient

Member Purpose
event Action<ZoneTransfer> TransferRequested server asked this client to migrate (target + token)
Task<byte[]> ClaimAsync(token) on the destination node, retrieve the carried state

Store: IHandoffStore (MemoryHandoffStore default) — PutAsync(token, handoff, ttl) / TakeAsync(token) (one-time). Options: ZoneOptions.PlayerKey, HandoffTtl (60 s).

ZonesRuntime.Enable() — one-time bootstrap.

Notes

  • Rides the unified SetNet.Protocol messaging layer on the Channels.Zones 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.
  • The store must be shared for real cross-node handoff. The default MemoryHandoffStore only works when origin and destination are the same process (co-located nodes / tests). For separate processes, back IHandoffStore with Redis/DB so the destination can read the stashed state.
  • Where's the destination node? SetNet.Zones carries state; it doesn't decide which node owns a zone. Pair it with SetNet.Sharding (ring.GetNode(zoneId)) or your own zone→node map to fill in ZoneTarget.Host/Port.
  • One-time, expiring tokens. A token is consumed on the first successful claim and swept after HandoffTtl. Carry only what the destination needs to reconstruct the player; keep durable data (inventory, progression) in shared stores like SetNet.Inventory.
  • Trust. The carried state is opaque and, if the store is shared, written by a trusted peer node — validate it on the destination and gate player connections with SetNet.Auth. Re-authenticate on the destination node like any new connection.

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

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 127 8/5/2026