Class CosmosConsole
Inheritance
CosmosConsole
Assembly: cs.temp.dll.dll
Syntax
public class CosmosConsole : ICredentialsValidator
Fields
LocalSender
The local command sender of this console instance
Declaration
public readonly LocalCommandSender LocalSender
Field Value
RemotePort
The network port used by the console in server-mode as specified in the configuration
Declaration
public readonly ushort RemotePort
Field Value
Properties
Networker
The networker instance that handles server and client back-ends
Declaration
public CosmosNetworker Networker { get; }
Property Value
Methods
AddCommandListener(Int32, CommandCallback)
Add listener to command with specified id
Declaration
public CommandCallbackHandle AddCommandListener(int commandId, CommandCallback callback)
Parameters
Returns
AddCommandListener(String, CommandCallback)
Add listener to command with specified keyword
Declaration
public CommandCallbackHandle AddCommandListener(string command, CommandCallback callback)
Parameters
Returns
AddNewCommand(CommandDefinition)
Declaration
public bool AddNewCommand(CommandDefinition cmdDef)
Parameters
Returns
Type |
Description |
Boolean |
True if the command was added, otherwise false in case validation failed
|
AddNewCommandCategory(String)
Add new command category, which are part of the command descriptions
Declaration
public int AddNewCommandCategory(string name)
Parameters
Type |
Name |
Description |
String |
name |
|
Returns
Type |
Description |
Int32 |
Index of the new category, or -1 if an incorrect name was provided
|
AddUser(UserDefinition)
Declaration
public bool AddUser(UserDefinition user)
Parameters
Returns
Type |
Description |
Boolean |
True if user was added, false if user limit is reached, provided username is invalid, or if user already exists
|
CreateLocal(CosmosConsoleConfig)
Creates local-only CosmosConsole instance
Declaration
public static CosmosConsole CreateLocal(CosmosConsoleConfig consoleConfig)
Parameters
Returns
CreateNetworked(CosmosConsoleConfig, INetworkFactory)
Creates CosmosConsole instance with networking features
Declaration
public static CosmosConsole CreateNetworked(CosmosConsoleConfig consoleConfig, INetworkFactory networkFactory)
Parameters
Returns
Dispose()
Declaration
GetCommandDescriptions()
Declaration
public IEnumerable<CommandDescription> GetCommandDescriptions()
Returns
GetCommandHints()
Declaration
public IEnumerable<CommandHint> GetCommandHints()
Returns
GetServerSettings()
Declaration
public ServerSettings GetServerSettings()
Returns
LoadSerializedParameterValues(Byte[])
Declaration
public void LoadSerializedParameterValues(byte[] bytes)
Parameters
Type |
Name |
Description |
Byte[] |
bytes |
|
LoadSerializedRemoteConfig(Byte[])
Declaration
public void LoadSerializedRemoteConfig(byte[] bytes)
Parameters
Type |
Name |
Description |
Byte[] |
bytes |
|
Log(String, LogType)
Declaration
public void Log(string message, LogType logType = LogType.DEFAULT)
Parameters
QueueExecuteString(String, ICommandSender)
Queue command string to be executed. Parses and validates the command string, and then either queues it for execution next Update() call, or
sends the command string over the network if this is console is in client-mode.
Declaration
public void QueueExecuteString(string commandString, ICommandSender sender = null)
Parameters
Exceptions
RemoveAllListeners()
Removes all registered listeners
Declaration
public void RemoveAllListeners()
RemoveCommand(String)
Remove the command with the provided keyword
Declaration
public bool RemoveCommand(string keyword)
Parameters
Type |
Name |
Description |
String |
keyword |
|
Returns
Type |
Description |
Boolean |
True if a command was removed, otherwise false
|
RemoveCommandListener(CommandCallbackHandle)
Removes listener with specified handle from the callback list
Declaration
public void RemoveCommandListener(CommandCallbackHandle handle)
Parameters
RemoveCommandListener(Int32, CommandCallback)
Removes listener from command with specified id
Declaration
public void RemoveCommandListener(int commandId, CommandCallback callback)
Parameters
RemoveCommandListener(String, CommandCallback)
Removes listener from command with specified keyword
Declaration
public void RemoveCommandListener(string command, CommandCallback callback)
Parameters
RemoveCustomValidator(String)
Declaration
public void RemoveCustomValidator(string command)
Parameters
Type |
Name |
Description |
String |
command |
|
RemoveListeners(IEnumerable<CommandCallbackHandle>)
Remove all listeners tied to specified handles from the callback list
Declaration
public void RemoveListeners(IEnumerable<CommandCallbackHandle> handles)
Parameters
RemoveUser(String)
Declaration
public bool RemoveUser(string username)
Parameters
Type |
Name |
Description |
String |
username |
|
Returns
Type |
Description |
Boolean |
True if user was removed, false if user was not found
|
SendSerializedConfigToClient(ICommandSender)
Declaration
public void SendSerializedConfigToClient(ICommandSender client)
Parameters
SetCommandEnabled(String, Boolean)
Set whether the command is enabled or disabled
Declaration
public bool SetCommandEnabled(string commandKeyword, bool enabled)
Parameters
Returns
Type |
Description |
Boolean |
True if command state was changed, false if command was not found
|
SetCommandParameterValues(String, String, List<String>)
Set the parameter values for the specified command parameter
Declaration
public bool SetCommandParameterValues(string commandKeyword, string parameterKey, List<string> values)
Parameters
Returns
Type |
Description |
Boolean |
True if parameter values were set, or false if the command keyword or parameter key was not found, or any of the values contains invalid characters
|
SetCustomValidator(String, CustomValidator)
Set custom validate for the command with the specified keyword
Declaration
public void SetCustomValidator(string command, CustomValidator validationFunc)
Parameters
SetUserCommandAccess(String, String, Boolean)
Set whether the user is allowed to execute the specified command
Declaration
public bool SetUserCommandAccess(string username, string commandKeyword, bool allowAccess)
Parameters
Returns
Type |
Description |
Boolean |
True if access was set, false if user or command was not found
|
SetUserCommandsInCategoryAccess(String, String, Boolean)
Set whether the user is allowed to execute the commands in the specified category
Declaration
public bool SetUserCommandsInCategoryAccess(string username, string category, bool allowAccess)
Parameters
Returns
Type |
Description |
Boolean |
True if access was set, false if user or category was not found, or there are no commands in the specified category
|
UnloadRemoteConfig()
Declaration
public void UnloadRemoteConfig()
Update()
Updates console, execute queued commands, and updates network back-end
Declaration
Validate(UserCredentials, out UserPrivileges)
Declaration
public bool Validate(UserCredentials credentials, out UserPrivileges privileges)
Parameters
Returns
Events
OnCommandExecutedEvent
Event called after a command has been handled by its listeners.
Declaration
public event Action<Command, ICommandSender> OnCommandExecutedEvent
Event Type
OnLocalCommandsChangedEvent
Event called when the local config changes. This occurs when a command is added, removed, enabled or has its parameter values changed.
Declaration
public event Action OnLocalCommandsChangedEvent
Event Type
OnLogEvent
Event called when the console outputs to its log
Declaration
public event Action<string, LogType> OnLogEvent
Event Type
OnRemoteConfigChangedEvent
Event called when the remote config changes. This occurs on client consoles after connecting to a server console, or if the server console updates its
command definitions while the client is connected, or after disconnecting from a server.
Declaration
public event Action OnRemoteConfigChangedEvent
Event Type
Implements