Class ServerStartup

Namespace
Unity.Multiplayer.Core

Loads a dedicated server's settings the way the server package promises: the defaults, then server.json, then the environment (NetEnvironment), then the command line (NetCommandLine and the package arguments below), each layer overriding the one before.

public static class ServerStartup
Inheritance
ServerStartup
Inherited Members

Remarks

Package arguments (names ignore case; the value is the next argument or follows =):

-configThe settings file to read instead of server.json in the package folder (relative to the package folder).
-healthportHealth endpoint TCP port, 0 for off (HealthPort).
-adminon or off; alone it means on (AdminCommands).
-logs / -savesLogs and saves folders (LogsDirectory, SavesDirectory).

The session arguments -port -maxPlayers -name -password and the rest are NetCommandLine's.

Fields

AdminArg

Turns the admin console on or off.

public const string AdminArg = "-admin"

Field Value

string

ConfigArg

Selects the settings file.

public const string ConfigArg = "-config"

Field Value

string

HealthPortArg

Sets the health endpoint port.

public const string HealthPortArg = "-healthport"

Field Value

string

LogsArg

Sets the logs folder.

public const string LogsArg = "-logs"

Field Value

string

SavesArg

Sets the saves folder.

public const string SavesArg = "-saves"

Field Value

string

Methods

ApplyPackageArguments(ServerSettings, IReadOnlyList<string>)

Applies the package arguments (-healthport -admin -logs -saves) to settings.

public static IReadOnlyList<string> ApplyPackageArguments(ServerSettings settings, IReadOnlyList<string> args)

Parameters

settings ServerSettings
args IReadOnlyList<string>

Returns

IReadOnlyList<string>

One message per argument with a missing or unreadable value.

Exceptions

ArgumentNullException

settings or args is null.

Load(NetConfig, IReadOnlyList<string>, string, Func<string, string>, Func<string, string>)

Applies every layer to config and returns the package settings with what went wrong.

public static ServerStartupResult Load(NetConfig config, IReadOnlyList<string> args, string packageDirectory, Func<string, string> environment = null, Func<string, string> readFile = null)

Parameters

config NetConfig

The session settings to fill (the game's defaults, from the scene's NetBootstrap).

args IReadOnlyList<string>

The process command line.

packageDirectory string

The package folder (where the executable and server.json are).

environment Func<string, string>

Reads an environment variable (null when unset); null reads the process environment.

readFile Func<string, string>

Reads a file's text, or null when it does not exist; null reads the disk.

Returns

ServerStartupResult

Exceptions

ArgumentNullException

config, args or packageDirectory is null.