public void StartRemoteCLI() { if (_client.Connected) { using (DataStringPacket _packet = new DataStringPacket(_stream)) { _packet.data = Convert.ToString(Console.BufferWidth); _packet.SendPacket(_aes); _packet.ReceivePacket(_aes); CLIOutput.WriteToConsole(_packet.data + "\n"); } using (CLIPacket _cliP = new CLIPacket(_stream)) { _cliP.serverAnswer = ""; while (true) { // write cursor Console.ForegroundColor = ConsoleColor.Cyan; Console.Write(cursor); Console.ForegroundColor = ConsoleColor.White; // read input _cliInput = CLIInput.ReadInput(cursor.Length); if (_cliInput != "") { _cliP.consoleWidth = Console.BufferWidth; _cliP.cliInput = _cliInput; _cliP.SendPacket(_aes); _cliP.ReceivePacket(_aes); if (_cliP.serverAnswer == "EXIT_CLI") { break; } CLIOutput.WriteToConsole(_cliP.serverAnswer + "\n"); } } } } else { throw new Exception("Not connected!"); } }
public void Start() { CLIOutput.WriteToConsole(GetBanner(Console.BufferWidth) + "\n"); while (true) { Command _command = null; Console.ForegroundColor = _cursorColor; Console.Write(_cursor); Console.ForegroundColor = _inputColor; string _cliInput = CLIInput.ReadInput(Console.CursorLeft); string _response; // This is the old method to read input from cli. //string _cliInput = Console.ReadLine(); _cliInput = _cliInput.Trim(); if (_cliInput != "") { _response = CLIInterpreter(ref _command, _cliInput); if (_response == "VALID_PARAMETERS") { try { _response = _command.Execute(Console.BufferWidth); if (_response == "EXIT_CLI") { break; } } catch (Exception e) { _response = "<color><red>" + e.Message; } } CLIOutput.WriteToConsole(_response + "\n"); } } }