private void Exec() { string result = string.Empty; ExecResult returnValue = ExecResult.InvalidCommand; if (this.CheckMaxCLICommandExecutions(this.countExec++) == false) { result = "Free version does not allow more than " + RemoteModule.MaxCLICommandExecutions + " remote executions.\nAwesomeness has a price. :D"; } else { returnValue = this.parser.Exec(this.command, ref result); } LogEntry log = new LogEntry(); log.condition = this.command; // Use file to display the default value from RemoteCommand while waiting for the answer. log.file = result; RemoteRow row = new RemoteRow(); row.Init(this.console, log); this.AddRow(row); if (returnValue == ExecResult.Success) { // Create a waiter to update the log when the server will answer. CommandRequest cr = new CommandRequest(++this.idCounter, row); this.pendingCommands.Add(cr); this.client.AddPacket(new ClientSendCommandPacket(cr.id, this.command), this.OnCommandAnswered); } else { row.error = result; } this.command = string.Empty; this.parser.Clear(); }
public CommandRequest(int id, RemoteRow row) { this.id = id; this.row = row; }