Table of Contents

Class InteractiveClientProcess

Namespace
Valheim.Testing.GameSessions
Assembly
Valheim.Testing.GameSessions.dll

A game client InteractiveClient started, identified by process ID and start time on its host: the identity an owned session checks against its adapter's reported process ID. It implements IOwnedProcess, so it can be given to the ClientSession launch that takes its process, connection and readiness as functions. Stopping it stops only that process, and only while its start time still matches: a process ID reused by another program is never touched. Disposing stops it if it was not stopped yet.

public sealed class InteractiveClientProcess : IOwnedProcess
Inheritance
object
InteractiveClientProcess
Implements

Properties

HasExited

True once a wait or a stop saw the process gone. Not a live check: use WaitForExitAsync(CancellationToken) for that.

public bool HasExited { get; }

Property Value

bool

HostName

public string HostName { get; }

Property Value

string

Id

The game's process ID on its host.

public int Id { get; }

Property Value

int

LastQuitRequest

How the last stop asked the game to quit.

public string LastQuitRequest { get; }

Property Value

string

LaunchDirectory

The launch's evidence directory on the host.

public string LaunchDirectory { get; }

Property Value

string

StartIdentity

The process's start identity as the host reports it (Windows: UTC file time; Linux: clock ticks after boot; macOS: checksum of the reported start time), which tells it from a later process with the same ID.

public string StartIdentity { get; }

Property Value

string

TaskName

Windows: the scheduled task's name. It was removed before the start returned.

public string? TaskName { get; }

Property Value

string

Methods

Dispose()

Stops the process unless it was stopped already; an unproven stop throws.

public void Dispose()

DisposeAsync()

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

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

Stop(TimeSpan)

public void Stop(TimeSpan timeout)

Parameters

timeout TimeSpan

StopAsync(TimeSpan, CancellationToken)

Kills the process if it is still the one this launch started and waits up to timeout for it to exit. Only the first successful call acts. A process that is still there afterwards, or an unproven stop, throws; a later call may try again, because the identity check makes it safe to repeat.

public Task<InteractiveStop> StopAsync(TimeSpan timeout, CancellationToken cancellation = default)

Parameters

timeout TimeSpan
cancellation CancellationToken

Returns

Task<InteractiveStop>

StopAsync(TimeSpan, TimeSpan, CancellationToken)

StopAsync(TimeSpan, CancellationToken), but first asks the game to quit (Windows: closes its main window; Linux: SIGTERM) and gives it quit to exit by itself, which it reports as Quit.

public Task<InteractiveStop> StopAsync(TimeSpan quit, TimeSpan timeout, CancellationToken cancellation = default)

Parameters

quit TimeSpan
timeout TimeSpan
cancellation CancellationToken

Returns

Task<InteractiveStop>

StopCleanly(TimeSpan, TimeSpan)

public ProcessStop StopCleanly(TimeSpan quit, TimeSpan kill)

Parameters

quit TimeSpan
kill TimeSpan

Returns

ProcessStop

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

WaitForExitAsync(CancellationToken)

Completes when the process has exited, with its exit code where the host can tell it (the launch's recorder on Linux, the process handle on Windows), otherwise -1. Waits on the host in rounds of at most 10 minutes until cancelled; a round whose reply is lost throws HostOperationException.

public Task<int> WaitForExitAsync(CancellationToken cancellation)

Parameters

cancellation CancellationToken

Returns

Task<int>