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

IReadOnlyList<string>

Methods

Execute(string)

Runs one line. An empty line does nothing and succeeds.

public AdminCommandResult Execute(string line)

Parameters

line string

Returns

AdminCommandResult

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

name string

One word, no spaces.

usage string

How to call it, for help (kick <clientId> [reason]).

description string

What it does, in a sentence.

handler Func<IReadOnlyList<string>, string>

Gets the arguments after the name; returns the text to show. Throw ArgumentException for bad arguments.

Exceptions

ArgumentException

name is empty or has spaces.

ArgumentNullException

handler is 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

line string

Returns

IReadOnlyList<string>

Unregister(string)

Removes a command. True when it existed.

public bool Unregister(string name)

Parameters

name string

Returns

bool