A class in Root.Township, the global namespace.
Game mode for running as the server: loads the server's scene and starts it here, or launches a separate headless process.
Constructors
| Member | What it is |
|---|
ServerHostingGameMode(IServerAccess server, bool isHeadless, bool isExternalLaunch = false, int port = 1757, bool isRunningLocally = true) | Creates a ServerHostingGameMode from server, isHeadless, isExternalLaunch, port and isRunningLocally. |
Fields
5 private and internal fields
| Member | What it is |
|---|
private bool isExternalLaunch | Launch a separate server process instead of starting here. |
private bool isHeadless | Run the server without graphics. |
private bool isRunningLocally | Passed to the server start as whether it runs locally. Default true. |
private int port | Port to host on. Default 1757. |
private IServerAccess server | Access to the server being hosted. |
Properties
| Member | What it is |
|---|
override bool IsClient { get; } | Always false. |
static bool IsRelaunchingTheGame { get; set; } | Static flag for relaunching the game. Not set in this class. |
override bool IsServer { get; } | Always true. |
Methods
| Member | What it is |
|---|
override async Task<bool> ActivateAsync() | Loads the scene and starts the server (headless or not), or launches an external server. Goes back to the main menu on failure. |
override void OnStartSucceeded() | Stops the active VR or desktop platform once the server is up. |
override async Task StopModeAsync(string reason) | Stops the mode, then shuts down the ServerHandler with an expected shutdown reason. |
4 private and internal methods
| Member | What it is |
|---|
private void RestartAsHeadless() | Launches a headless server process and quits this one. Needs /login or /login_hash on the command line. |
private void StartExternalServer() | Starts a new game process in batch mode with /start_server, the port and the user's tokens on the command line, logging to the server's logs folder. |
private async Task<bool> StartHeadlessServer() | Starts the server here if already headless, otherwise restarts as a headless process. |
private async Task<bool> StartServer() | Starts the server through ServerLifetimePipeline.AttemptToStartServer. |