Class FakeOwnedServer
A scripted owned dedicated server for testing startup, readiness, identity, restart and teardown logic without a game. Launch(string) starts a FakeOwnedProcess; Connect() returns a transport that answers the session capability (token, PID, save root, complete, dedicated) and the strict pins like a server with a session adapter. Switches make each failure happen; gates hold a step open until the test releases it. Events records launch/probe/pins/stop/dispose/disconnect with the boot number, in order.
public sealed class FakeOwnedServer
- Inheritance
-
objectFakeOwnedServer
Constructors
FakeOwnedServer(string, string?)
public FakeOwnedServer(string extension = "test.mod", string? saveRoot = null)
Parameters
extensionstringThe session adapter's extension id; the capability is
{extension}/session.saveRootstring
Properties
CheatsAcknowledged
public bool CheatsAcknowledged { get; set; }
Property Value
- bool
ConnectEntered
Set when a connection or a pin check starts: synchronise failure injection with the stage under test.
public ManualResetEventSlim ConnectEntered { get; }
Property Value
- ManualResetEventSlim
ConnectGate
Held connections and pin checks wait for these gates (at most 30 s).
public ManualResetEventSlim? ConnectGate { get; set; }
Property Value
- ManualResetEventSlim
Connects
public int Connects { get; }
Property Value
- int
Devcommands
The server's test access as ValheimCLI's cli_access reports it; devcommands toggles it, confirmcheats acknowledges cheats. Each launch starts with both off, as a new game process does.
public bool Devcommands { get; set; }
Property Value
- bool
Disconnects
public int Disconnects { get; }
Property Value
- int
Events
public IReadOnlyList<string> Events { get; }
Property Value
- IReadOnlyList<string>
ExitOnLaunch
public bool ExitOnLaunch { get; set; }
Property Value
- bool
Extension
public string Extension { get; }
Property Value
- string
IgnoreConfirmCheats
Accept confirmcheats without acknowledging cheats: a server whose access never becomes ready.
public bool IgnoreConfirmCheats { get; set; }
Property Value
- bool
IgnoreQuit
A clean stop's quit request is ignored, so the process is killed after the wait (Killed).
public bool IgnoreQuit { get; set; }
Property Value
- bool
OnLaunch
Runs on every launch, for example to write the boot's log lines or exit the process.
public Action<FakeOwnedProcess>? OnLaunch { get; set; }
Property Value
- Action<FakeOwnedProcess>
PinEntered
public ManualResetEventSlim PinEntered { get; }
Property Value
- ManualResetEventSlim
PinGate
public ManualResetEventSlim? PinGate { get; set; }
Property Value
- ManualResetEventSlim
PinTimeouts
public IReadOnlyList<TimeSpan> PinTimeouts { get; }
Property Value
- IReadOnlyList<TimeSpan>
ProbeDelay
How long each readiness probe takes (blocking).
public TimeSpan ProbeDelay { get; set; }
Property Value
- TimeSpan
Ready
Whether the adapter reports its session complete (mod ready).
public bool Ready { get; set; }
Property Value
- bool
RefuseConnections
Connecting throws System.IO.IOException, as before the CLI listens.
public bool RefuseConnections { get; set; }
Property Value
- bool
RefusePins
public bool RefusePins { get; set; }
Property Value
- bool
RefuseStop
public bool RefuseStop { get; set; }
Property Value
- bool
ReportWrongPid
The session reports another PID than the launched process's.
public bool ReportWrongPid { get; set; }
Property Value
- bool
SaveRoot
public string SaveRoot { get; }
Property Value
- string
SessionCapability
public string SessionCapability { get; }
Property Value
- string
Tokens
public IReadOnlyList<string> Tokens { get; }
Property Value
- IReadOnlyList<string>
Methods
Connect()
public IGameTransport Connect()
Returns
Launch(string)
public IOwnedProcess Launch(string token)
Parameters
tokenstring
Returns
Session(TimeSpan, TimeSpan?, TimeSpan?, StartupEvents?, string)
An owned session over this server with the given deadlines (poll 1 ms by default).
public OwnedServerSession Session(TimeSpan startup, TimeSpan? command = null, TimeSpan? poll = null, StartupEvents? events = null, string expectations = "cli_expect worlduid=1")
Parameters
startupTimeSpancommandTimeSpan?pollTimeSpan?eventsStartupEventsexpectationsstring
Returns
SessionReply(string, string, int, string, bool, bool)
The session capability's reply, as a session adapter builds it.
public static JsonElement SessionReply(string extension, string token, int pid, string saveRoot, bool complete, bool dedicated = true)
Parameters
extensionstringtokenstringpidintsaveRootstringcompletebooldedicatedbool
Returns
- JsonElement