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):
name | Server name (ServerName). |
password | Server password, empty for none (Password). |
port | Game port, 1-65535 (Port). |
maxPlayers | Player cap (MaxPlayers). |
address | Local address to bind, empty for every interface (Address). |
transport | udp or websocket (Transport). |
tickRate | Ticks per second (TickRate). |
reconnectGraceSeconds | Seconds a dropped player's seat is held (ReconnectGraceSeconds). |
joinCodes | auto, none, relay or rendezvous (JoinCodes). |
rendezvousUrl | Rendezvous service URL (RendezvousUrl). Its secret belongs in MINDATTIC_RENDEZVOUS_SECRET, never this file. |
publicAddress / publicPort | Where players reach the server, when it differs (PublicAddress, PublicPort). |
healthPort | Health endpoint TCP port, 0 for off (HealthPort). |
adminCommands | true to read admin commands from standard input (AdminCommands). |
logsDirectory / savesDirectory | Folders for logs and persistent data (LogsDirectory, SavesDirectory). |
keepLogFiles | Log files kept (KeepLogFiles). |
shutdownGraceSeconds | Seconds 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
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
jsonstringconfigNetConfigsettingsServerSettings
Returns
- ServerConfigResult
Errors and warnings; when the text is not a JSON object nothing is applied and that is the one error.
Exceptions
- ArgumentNullException
configorsettingsis 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
configNetConfigsettingsServerSettings
Returns
Exceptions
- ArgumentNullException
configorsettingsis null.