Class HostingClientActor
- Namespace
- Valheim.Testing.GameSessions
- Assembly
- Valheim.Testing.GameSessions.dll
The client of a run that hosts its own world (#258 step 8, Q2): one game process with both capabilities, a client with a local player and the server of its world (a listen server). Its plan is a ClientRunPlan with a HostWorld section; the inventory has no role for it. Its lifecycle:
- Prepare(): the plan's static preflight (Preflight(IEnumerable<string>) with HostedRounds), the native client's save directory, then the fixture world placed in its local worlds through its journalled site (HostedWorld; on this machine journalled in this machine's run journal). StartAsync() records each part as its own step, before any actor starts.
- Start(): the client to its strictly pinned menu, through its placement, once (ClientActor).
- Host(): it hosts the placed world (Start(GameActor, ClientRunPlan, string, TimeSpan, CancellationToken, bool)), protected unless ProtectPlayer is false, and an owned host's disposable character gets test access.
As the session's IOwnedServer, WaitUntilJoinable(GameActor) waits until its world is open to peers and Restart() re-hosts it: the host leaves its world (the game saves it), is re-pinned at its menu and hosts it again. Game is its in-game handle, as server and as client. A peer joins it through the session (Join(string, HeightExpectation?, bool, CrossplayLobby?); JoinHost(ClientRunPlan, GameActor, string, bool, CancellationToken)). Closing it stops only a process it started, or detaches from an operator's; the placed world is moved into the evidence only once no client can still host it (#332): it never opened, its owned process stopped, or it left its world. Otherwise the world stays in place (World is not collected; a session names it in the report).
public sealed class HostingClientActor : IOwnedServer
- Inheritance
-
objectHostingClientActor
- Implements
Properties
Game
The open host's in-game handle: the server of its world and a client with a local player.
public GameActor Game { get; }
Property Value
LiveLog
An owned host's live BepInEx log on this machine, for a scenario's in-run log reads; null for an operator's client (its logs are its operator's).
public string? LiveLog { get; }
Property Value
- string
Logs
The open's kept logs, for the teardown scan once the client is closed.
public IReadOnlyList<RunLog> Logs { get; }
Property Value
- IReadOnlyList<RunLog>
Name
The hosting client's name in the run, for example host.
public string Name { get; }
Property Value
- string
Plan
public ClientRunPlan Plan { get; }
Property Value
ProtectPlayer
Whether hosting protects the host's player (god, ghost and debug mode); default true.
public bool ProtectPlayer { get; init; }
Property Value
- bool
Session
The open client's session, or null before Start() and once it is closed.
public ClientSession? Session { get; }
Property Value
World
The fixture world placed in the client's local worlds, or null before it is placed.
public HostedWorld? World { get; }
Property Value
WorldUid
The hosted fixture's world UID (WorldUid), which every peer's join verifies.
public string WorldUid { get; }
Property Value
- string
Methods
Dispose()
Closes the client, then moves the placed world into the evidence once no client can still host it; an operator's client still in the world keeps it (CollectedTo stays null). A failed close is rethrown after that.
public void Dispose()
Host()
From its idle menu, the open client hosts the placed fixture world (Start(GameActor, ClientRunPlan, string, TimeSpan, CancellationToken, bool), within the plan's join time), protected unless ProtectPlayer is false; an owned host's disposable character then gets test access.
public SessionState Host()
Returns
OnThisMachine(string, ClientRunPlan, string, CancellationToken)
A hosting client on this machine, its evidence (command and process records, kept logs, the fixture copy and the collected
world) written to output: launched from the plan's install or attached to the operator's client, as its
mode says; the fixture is placed in this machine's client data directory (or the plan's SaveDirectory).
An owned client runs from a disposable copy of its install, made when it opens and removed when it is closed, unless its
plan runs it in place (InPlace).
public static HostingClientActor OnThisMachine(string name, ClientRunPlan plan, string output, CancellationToken cancellation = default)
Parameters
namestringplanClientRunPlanoutputstringcancellationCancellationToken
Returns
Prepare()
Before anything starts: the plan's static preflight, the client's save directory, then the fixture world placed in its local worlds (refusing a world already named for it). A wrong fixture or install stops here, before the fixture is copied.
public void Prepare()
Restart()
The host's restart: it leaves its world (the game saves it on the way out; confirm a save first with Save(string, TimeSpan) when the check is about persistence), is re-pinned at its menu and hosts the same world again, protected as ProtectPlayer says, with test access on an owned host. Peers in the world are disconnected by the leave. Returns the host's actor, the same process.
public GameActor Restart()
Returns
Start()
Opens the client to its menu, plugins pinned, once, and returns its session (Start()).
public ClientSession Start()
Returns
WaitUntilJoinable(GameActor)
Waits until host, this host's Game, is in its fixture world with its player, within the
plan's join time, and is an open server a peer can join (cli_multiplayer_identity: a server, open).
public void WaitUntilJoinable(GameActor host)
Parameters
hostGameActor