Class ServerConfigFile

Namespace
Unity.Multiplayer.Core

Reads and writes server.json, the server package's settings file: one flat JSON object beside the server executable. The package's build writes it with every setting at its default, and the person running the server edits it; the environment and the command line still override it (ServerStartup).

public static class ServerConfigFile
Inheritance
ServerConfigFile
Inherited Members

Remarks

Keys (camelCase, matched ignoring case; every key is optional):

nameServer name (ServerName).
passwordServer password, empty for none (Password).
portGame port, 1-65535 (Port).
maxPlayersPlayer cap (MaxPlayers).
addressLocal address to bind, empty for every interface (Address).
transportudp or websocket (Transport).
tickRateTicks per second (TickRate).
reconnectGraceSecondsSeconds a dropped player's seat is held (ReconnectGraceSeconds).
joinCodesauto, none, relay or rendezvous (JoinCodes).
rendezvousUrlRendezvous service URL (RendezvousUrl). Its secret belongs in MINDATTIC_RENDEZVOUS_SECRET, never this file.
publicAddress / publicPortWhere players reach the server, when it differs (PublicAddress, PublicPort).
healthPortHealth endpoint TCP port, 0 for off (HealthPort).
adminCommandstrue to read admin commands from standard input (AdminCommands).
logsDirectory / savesDirectoryFolders for logs and persistent data (LogsDirectory, SavesDirectory).
keepLogFilesLog files kept (KeepLogFiles).
shutdownGraceSecondsSeconds a clean shutdown may take (ShutdownGraceSeconds).

A key with a value of the wrong kind is an error and leaves that setting unchanged; an unknown key is a warning, so a file written for a newer build still loads.

Fields

FileName

The settings file's name in the package folder.

public const string FileName = "server.json"

Field Value

string

Methods

Apply(string, NetConfig, ServerSettings)

Applies the settings in json to config and settings.

public static ServerConfigResult Apply(string json, NetConfig config, ServerSettings settings)

Parameters

json string
config NetConfig
settings ServerSettings

Returns

ServerConfigResult

Errors and warnings; when the text is not a JSON object nothing is applied and that is the one error.

Exceptions

ArgumentNullException

config or settings is null.

Compose(NetConfig, ServerSettings)

Writes server.json holding config's and settings's values, one key per line, in the order the remarks list them. Leaves out the rendezvous secret, always; the password is written (empty when there is none) so the file shows where it goes.

public static string Compose(NetConfig config, ServerSettings settings)

Parameters

config NetConfig
settings ServerSettings

Returns

string

Exceptions

ArgumentNullException

config or settings is null.