/// <summary> /// execute commands /// </summary> /// <param name="commandLine">command received from the user</param> /// <param name="client">that requested the command</param> /// <returns>the status returned from the command executed</returns> public Status ExecuteCommand(string commandLine, TcpClient client) { // split command string[] arr = commandLine.Split(' '); string commandKey = arr[0]; // check that the command is valid if (!commands.ContainsKey(commandKey)) { Statues stat = new Statues(); stat.SetStatues(Status.Disconnect, "Command not found"); view.SendToClient(stat.ToJson(), client); return(Status.Disconnect); } // get command and execute it string[] args = arr.Skip(1).ToArray(); ICommand command = commands[commandKey]; return(command.Execute(args, client)); }
/// <summary> /// Not in use right now. Avaliable for future to pass log by event /// </summary> /// <param name="e">args for the event</param> public void PassLog(object sender, CommandRecievedEventArgs e) { m_ch.SendToClient(m_currentLog.GetCurrentRunLog, e); }