Table of Contents

Class StateWait

Namespace
Valheim.Testing.Game
Assembly
Valheim.Testing.Game.dll
public sealed class StateWait
Inheritance
object
StateWait

Constructors

StateWait(ValheimClient)

Takes ownership of a connected client that nothing else uses.

public StateWait(ValheimClient client)

Parameters

client ValheimClient

Fields

InWorld

public const string InWorld = "InWorld"

Field Value

string

InWorldNoPlayer

public const string InWorldNoPlayer = "InWorldNoPlayer"

Field Value

string

Loading

public const string Loading = "Loading"

Field Value

string

MainMenu

public const string MainMenu = "MainMenu"

Field Value

string

Unknown

public const string Unknown = "Unknown"

Field Value

string

WorldLoaded

A world is loaded, on a dedicated server (no player) or a client.

public static readonly IReadOnlyList<string> WorldLoaded

Field Value

IReadOnlyList<string>

Properties

LastState

The latest state received, or null before the first answer.

public string? LastState { get; }

Property Value

string

Methods

Connect(string, int)

public static StateWait Connect(string host, int port)

Parameters

host string
port int

Returns

StateWait

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

WaitAsync(IReadOnlyCollection<string>, TimeSpan, IReadOnlyCollection<string>?, CancellationToken)

Waits until the game reaches one of targets and returns it. Subscribes on first use, asks the current state once, then awaits pushes. Every state seen during the wait counts, in order, including one pushed while the question was being answered. A state in failures, a closed connection or a protocol error ends the wait at once with WaitFailedException; expiry throws WaitTimeoutException. Names compare case-insensitively, as ValheimCLI's own wait does. Expiry or cancellation closes the connection (an abandoned read leaves the stream's position unknown), so later waits on this instance fail: connect a new one.

public Task<string> WaitAsync(IReadOnlyCollection<string> targets, TimeSpan timeout, IReadOnlyCollection<string>? failures = null, CancellationToken cancellation = default)

Parameters

targets IReadOnlyCollection<string>
timeout TimeSpan
failures IReadOnlyCollection<string>
cancellation CancellationToken

Returns

Task<string>