Search Results for

    Show / Hide Table of Contents

    Class CosmosConsole

    Inheritance
    Object
    CosmosConsole
    Implements
    ICredentialsValidator
    Namespace: Clavusaurus.Cosmos
    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
    Type Description
    LocalCommandSender

    RemotePort

    The network port used by the console in server-mode as specified in the configuration

    Declaration
    public readonly ushort RemotePort
    Field Value
    Type Description
    UInt16

    Properties

    Networker

    The networker instance that handles server and client back-ends

    Declaration
    public CosmosNetworker Networker { get; }
    Property Value
    Type Description
    CosmosNetworker

    Methods

    AddCommandListener(Int32, CommandCallback)

    Add listener to command with specified id

    Declaration
    public CommandCallbackHandle AddCommandListener(int commandId, CommandCallback callback)
    Parameters
    Type Name Description
    Int32 commandId
    CommandCallback callback
    Returns
    Type Description
    CommandCallbackHandle

    AddCommandListener(String, CommandCallback)

    Add listener to command with specified keyword

    Declaration
    public CommandCallbackHandle AddCommandListener(string command, CommandCallback callback)
    Parameters
    Type Name Description
    String command
    CommandCallback callback
    Returns
    Type Description
    CommandCallbackHandle

    AddNewCommand(CommandDefinition)

    Add a new command

    Declaration
    public bool AddNewCommand(CommandDefinition cmdDef)
    Parameters
    Type Name Description
    CommandDefinition cmdDef
    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)

    Add a new user

    Declaration
    public bool AddUser(UserDefinition user)
    Parameters
    Type Name Description
    UserDefinition user
    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
    Type Name Description
    CosmosConsoleConfig consoleConfig
    Returns
    Type Description
    CosmosConsole

    CreateNetworked(CosmosConsoleConfig, INetworkFactory)

    Creates CosmosConsole instance with networking features

    Declaration
    public static CosmosConsole CreateNetworked(CosmosConsoleConfig consoleConfig, INetworkFactory networkFactory)
    Parameters
    Type Name Description
    CosmosConsoleConfig consoleConfig
    INetworkFactory networkFactory
    Returns
    Type Description
    CosmosConsole

    Dispose()

    Declaration
    public void Dispose()

    GetCommandDescriptions()

    Declaration
    public IEnumerable<CommandDescription> GetCommandDescriptions()
    Returns
    Type Description
    IEnumerable<CommandDescription>

    GetCommandHints()

    Declaration
    public IEnumerable<CommandHint> GetCommandHints()
    Returns
    Type Description
    IEnumerable<CommandHint>

    GetServerSettings()

    Declaration
    public ServerSettings GetServerSettings()
    Returns
    Type Description
    ServerSettings

    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
    Type Name Description
    String message
    LogType logType

    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
    Type Name Description
    String commandString
    ICommandSender sender
    Exceptions
    Type Condition
    CommandNotDefinedException
    CommandFormatException
    CommandInvalidParametersException

    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
    Type Name Description
    CommandCallbackHandle handle

    RemoveCommandListener(Int32, CommandCallback)

    Removes listener from command with specified id

    Declaration
    public void RemoveCommandListener(int commandId, CommandCallback callback)
    Parameters
    Type Name Description
    Int32 commandId
    CommandCallback callback

    RemoveCommandListener(String, CommandCallback)

    Removes listener from command with specified keyword

    Declaration
    public void RemoveCommandListener(string command, CommandCallback callback)
    Parameters
    Type Name Description
    String command
    CommandCallback callback

    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
    Type Name Description
    IEnumerable<CommandCallbackHandle> handles

    RemoveUser(String)

    Removes the user

    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
    Type Name Description
    ICommandSender client

    SetCommandEnabled(String, Boolean)

    Set whether the command is enabled or disabled

    Declaration
    public bool SetCommandEnabled(string commandKeyword, bool enabled)
    Parameters
    Type Name Description
    String commandKeyword
    Boolean enabled
    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
    Type Name Description
    String commandKeyword
    String parameterKey
    List<String> values
    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
    Type Name Description
    String command
    CustomValidator validationFunc

    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
    Type Name Description
    String username
    String commandKeyword
    Boolean allowAccess
    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
    Type Name Description
    String username
    String category
    Boolean allowAccess
    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
    public void Update()

    Validate(UserCredentials, out UserPrivileges)

    Declaration
    public bool Validate(UserCredentials credentials, out UserPrivileges privileges)
    Parameters
    Type Name Description
    UserCredentials credentials
    UserPrivileges privileges
    Returns
    Type Description
    Boolean

    Events

    OnCommandExecutedEvent

    Event called after a command has been handled by its listeners.

    Declaration
    public event Action<Command, ICommandSender> OnCommandExecutedEvent
    Event Type
    Type Description
    Action<Command, ICommandSender>

    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
    Type Description
    Action

    OnLogEvent

    Event called when the console outputs to its log

    Declaration
    public event Action<string, LogType> OnLogEvent
    Event Type
    Type Description
    Action<String, LogType>

    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
    Type Description
    Action

    Implements

    ICredentialsValidator
    ☀
    ☾
    In This Article
    Back to top
    © Clavusaurus Game Software
    ☀
    ☾