Class AdminConsole
- Namespace
- Unity.Multiplayer.Core
The server's optional admin commands: lines typed on the server's standard input (docker attach, a
terminal) when AdminCommands is on. Engine-free: the runtime registers status,
players, kick, say and stop; a game adds its own with Register(string, string, string, Func<IReadOnlyList<string>, string>).
public sealed class AdminConsole
- Inheritance
-
AdminConsole
- Inherited Members
Remarks
Command names ignore case. Arguments split on spaces; double quotes keep spaces in one argument.
Constructors
AdminConsole()
Creates a console with only help.
public AdminConsole()
Properties
Commands
The registered command names, sorted.
public IReadOnlyList<string> Commands { get; }
Property Value
Methods
Execute(string)
Runs one line. An empty line does nothing and succeeds.
public AdminCommandResult Execute(string line)
Parameters
linestring
Returns
Register(string, string, string, Func<IReadOnlyList<string>, string>)
Adds a command, replacing one with the same name.
public void Register(string name, string usage, string description, Func<IReadOnlyList<string>, string> handler)
Parameters
namestringOne word, no spaces.
usagestringHow to call it, for
help(kick <clientId> [reason]).descriptionstringWhat it does, in a sentence.
handlerFunc<IReadOnlyList<string>, string>Gets the arguments after the name; returns the text to show. Throw ArgumentException for bad arguments.
Exceptions
- ArgumentException
nameis empty or has spaces.- ArgumentNullException
handleris null.
Split(string)
Splits a command line on whitespace; double quotes group words, " is a literal quote.
public static IReadOnlyList<string> Split(string line)
Parameters
linestring
Returns
Unregister(string)
Removes a command. True when it existed.
public bool Unregister(string name)
Parameters
namestring