Class ServerPackageSpec
- Namespace
- Unity.Multiplayer.Core
The provider-neutral server package: what every host gets, whichever IHostingProfile it is built for. A self-contained Linux x86_64 Dedicated Server build of the game plus:
server.json: the settings, overridden by the environment and command line (ServerStartup);start.sh: starts the server with the package's settings and forwards its arguments (-port -maxPlayers -name -password); itexecs, so SIGTERM and SIGINT reach the server, which shuts down cleanly;server-package.json: the manifest a deploy tool reads (profile, executable, declared ports, health path);Logs/andSaves/: log files, and the game's persistent data;- the profile's own files (a Dockerfile, a compose file, notes).
public sealed class ServerPackageSpec
- Inheritance
-
ServerPackageSpec
- Inherited Members
Fields
ExecutableExtension
The extension Unity gives a Linux x86_64 executable.
public const string ExecutableExtension = ".x86_64"
Field Value
ManifestFileName
The manifest's name.
public const string ManifestFileName = "server-package.json"
Field Value
ManifestFormat
The manifest format version written.
public const int ManifestFormat = 1
Field Value
StartScriptName
The start script's name.
public const string StartScriptName = "start.sh"
Field Value
UnityPlayerLibrary
The Unity engine library every Linux player ships beside its executable.
public const string UnityPlayerLibrary = "UnityPlayer.so"
Field Value
Properties
Config
The settings written to server.json; the topology is always Server.
public NetConfig Config { get; }
Property Value
DataFolderName
Unity's data folder beside the executable: its name without the extension, plus _Data.
public string DataFolderName { get; }
Property Value
ExecutableName
The server executable's file name, such as MyGame.x86_64.
public string ExecutableName { get; }
Property Value
ExtraArgs
More arguments start.sh always passes, before the ones it is given.
public List<string> ExtraArgs { get; }
Property Value
Ports
The ports the server listens on: the game port (UDP, or TCP for WebSocket) and the health port when on.
public IReadOnlyList<DeclaredPort> Ports { get; }
Property Value
Profile
The profile the package is built for.
public IHostingProfile Profile { get; }
Property Value
Settings
The package settings written to server.json.
public ServerSettings Settings { get; }
Property Value
Methods
ComposeFiles()
The files the package holds besides Unity's build output, in a fixed order: server.json, start.sh,
the manifest, Logs/, Saves/, then the profile's files.
public IReadOnlyList<ServerPackageFile> ComposeFiles()
Returns
Exceptions
- InvalidOperationException
The profile adds a file the package already has.
ComposeManifest()
The manifest JSON a deploy tool reads.
public string ComposeManifest()
Returns
ComposeStartScript()
The POSIX shell start script.
public string ComposeStartScript()
Returns
ExpectedLayout()
Every path the finished package must contain: Unity's executable, data folder and engine library, then ComposeFiles()'. A build is complete when each exists.
public IReadOnlyList<ServerPackageFile> ExpectedLayout()
Returns
For(IHostingProfile, string, NetConfig, ServerSettings)
The spec profile builds: copies of config and settings
(defaults when null), switched to a dedicated server, then adjusted by Configure(ServerPackageSpec).
public static ServerPackageSpec For(IHostingProfile profile, string executableName, NetConfig config = null, ServerSettings settings = null)
Parameters
profileIHostingProfileexecutableNamestringconfigNetConfigsettingsServerSettings
Returns
Exceptions
- ArgumentNullException
profileis null.- ArgumentException
executableNameis not a safe file name.
IsInsidePackage(string)
True when directory is a relative path that stays inside the package folder.
public static bool IsInsidePackage(string directory)
Parameters
directorystring
Returns
IsSafeFileName(string)
True for a non-empty file name of letters, digits, '.', '_' and '-' that is not '.' or '..'.
public static bool IsSafeFileName(string name)
Parameters
namestring
Returns
LaunchArguments()
The arguments start.sh starts the executable with, executable first; its own arguments follow.
public IReadOnlyList<string> LaunchArguments()
Returns
ShellQuote(string)
Quotes value for a POSIX shell when it needs it.
public static string ShellQuote(string value)
Parameters
valuestring
Returns
Validate()
Lists every problem with the spec; an empty list means it can be built.
public IReadOnlyList<string> Validate()