Table of Contents

Class TestExtension

Namespace
Valheim.Testing.Adapter
Assembly
Valheim.Testing.Adapter.CompileCheck.dll

Registers a mod's test extension with ValheimCLI once ValheimCLI's extension API is ready, together with the session capability that OwnedServerSession uses to prove it started this very server: the token from the runner's environment variable, this process's ID, the save root, whether it is dedicated, the raw devcommands flag, whether it accepts game connections yet, and whether the world and the mod are ready. Run it as a coroutine from the adapter plugin's Start:

private IEnumerator Start() => TestExtension.Register("mymod.testing", "0.1.0", "MYMOD_TEST_SESSION_TOKEN",
    () => MyMod.Ready, registration => _registration = registration, Logger.LogError, extraCommands);

and dispose the registration in OnDestroy.

public static class TestExtension
Inheritance
object
TestExtension

Fields

ApiWaitSeconds

How long to wait for ValheimCLI's extension API before giving up; the adapter then stays inert.

public static float ApiWaitSeconds

Field Value

float

Methods

AcceptingConnections()

Whether this server has opened its game socket (ZNet.OpenServer, logged as "Opened Steam server" or "Opened PlayFab server"), so a client can join. The field is private in the shipped game; a missing field fails loudly.

public static bool AcceptingConnections()

Returns

bool

Register(string, string, string, Func<bool>, Action<ExtensionRegistration>, Action<string>, params ExtensionCommand[])

Waits for ValheimCLI's extension API, then registers the session identity and the mod's commands; a timeout logs an error and leaves the adapter inert.

public static IEnumerator Register(string id, string version, string tokenVariable, Func<bool> modReady, Action<ExtensionRegistration> registered, Action<string> logError, params ExtensionCommand[] commands)

Parameters

id string
version string
tokenVariable string
modReady Func<bool>
registered Action<ExtensionRegistration>
logError Action<string>
commands ExtensionCommand[]

Returns

IEnumerator