ServerConsoleManager
A class in Root.Township, the global namespace.
Singleton that runs the server's admin consoles: a local console window and the remote TCP and WebSocket consoles. It only starts them when the logged-in account has the debug_features permission.
- Listed in Global namespace: S
- Inherits or implements
SingletonBehaviour<ServerConsoleManager> - Derived types
ServerConsoleManager - Documented in Remote console, Startup and app state
Constructors
| Member | What it is |
|---|---|
ServerConsoleManager() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
6 private and internal fields
| Member | What it is |
|---|---|
private ServerConsole console | The local console window, if open. |
private IKeyBoardTriggerHandler keyboardHandler | Handle for the backquote key registration. |
private static Logger logger | NLog logger for this class. |
private IRemoteConsole remoteConsole | The TCP remote console. |
private IRemoteConsole remoteConsoleWS | The WebSocket remote console. |
private IUnityUpdateMethod updateConsole | Update loop registration for UpdateConsole. |
Properties
| Member | What it is |
|---|---|
static HashSet<IRemoteConsoleHandler> ConnectedHandlers { get; } | Remote console connections currently open. |
Events
| Member | What it is |
|---|---|
static event Action<UserInfoWithPermissions, IRemoteConsoleHandler> ConsoleConnected | Fired with the user and handler when a remote console connects. |
static event Action<UserInfoWithPermissions, IRemoteConsoleHandler> ConsoleDisconnected | Fired with the user and handler when a remote console disconnects. |
Methods
| Member | What it is |
|---|---|
void StartRemoteConsole() | Starts the TCP (ServerRemoteConsole) and WebSocket remote consoles, unless already started. |
static async Task<bool> ValidateConsoleToken(JwtSecurityToken token) | Checks a remote console's JWT. As decompiled, it returns false whenever a server is running (with or without a server_id claim) and true only when none is. |
protected override void Awake() | Checks permissions now if logged in, and again whenever the login changes. |
12 private and internal methods
| Member | What it is |
|---|---|
private void CheckForConsoleStart(Key key) | Backquote key handler: opens the local console window if the account has debug_features. |
private void CheckPermissions() | If the account has debug_features, opens the local console when /console is on the command line, registers the backquote key and starts the remote consoles. |
private void CloseConsole(IRemoteConsole console) | Closes one remote console and unhooks its events. |
private void HandleConsoleConnected(UserInfoWithPermissions user, IRemoteConsoleHandler remoteConsole) | Adds the handler to ConnectedHandlers and raises ConsoleConnected. |
private void HandleConsoleDisconnected(UserInfoWithPermissions user, IRemoteConsoleHandler remoteConsole) | Removes the handler from ConnectedHandlers and raises ConsoleDisconnected. |
private async void HandleInput(string command) | Runs a line typed in the local console through CommandService and logs the result. |
private void OnApplicationQuit() | Shuts down all consoles. |
private void OnDestroy() | Shuts down all consoles. |
private void ShutdownConsole() | Closes the remote consoles, shuts the local console window and stops its update. |
private void StartNewConsole(IRemoteConsole console) | Starts a remote console and hooks its connect and disconnect events. |
private void StartUp() | Opens the local console window, feeds it the server log and registers its input processing on the update loop. |
private void UpdateConsole() | Processes queued input from the local console each frame. |