Make CRAB work much more smoother (clear screen only after receiving new logs)

This commit is contained in:
pixtaded 2025-01-11 19:51:38 +03:00
parent 6dace63cb0
commit 7a116c6789

View File

@ -82,9 +82,7 @@ public class CrabClient implements Crab {
private void communicate() throws IOException { private void communicate() throws IOException {
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
String message; String message;
while (true) { while (true) {
System.out.print("\033[H\033[2J");
getLogs(); getLogs();
System.out.print("Enter a message (or type '/exit' to exit): "); System.out.print("Enter a message (or type '/exit' to exit): ");
message = scanner.nextLine(); message = scanner.nextLine();
@ -114,6 +112,7 @@ public class CrabClient implements Crab {
lastBufferLength = Integer.parseInt(new String(buffer).trim()); lastBufferLength = Integer.parseInt(new String(buffer).trim());
} case LOGS -> { } case LOGS -> {
byte[] bytes = socket.getInputStream().readNBytes(lastBufferLength); byte[] bytes = socket.getInputStream().readNBytes(lastBufferLength);
System.out.print("\033[H\033[2J");
System.out.print(Sanitizer.sanitizeString(new String(bytes, StandardCharsets.UTF_8), false)); System.out.print(Sanitizer.sanitizeString(new String(bytes, StandardCharsets.UTF_8), false));
} default -> { } default -> {
} }