Port the client to RACv1.99.2

This commit is contained in:
pixtaded 2025-02-09 14:47:01 +03:00
parent 3e6aefd4d2
commit 61ddfc86d1
2 changed files with 5 additions and 4 deletions

View File

@ -123,9 +123,9 @@ public class CrabClient implements Crab {
int response = in.read(buffer);
String convertedString = new String(buffer).trim();
if (!convertedString.isEmpty()) lastBufferLength = Integer.parseInt(convertedString);
} case COMMUNICATION -> {
byte[] bytes = socket.getInputStream().readNBytes(lastBufferLength);
cache = new Logs(lastBufferLength, new String(bytes, StandardCharsets.UTF_8));
} case LOGS -> {
byte[] bytes = socket.getInputStream().readNBytes(lastBufferLength - cache.sizeInBytes());
cache = new Logs(lastBufferLength, cache.content() + new String(bytes, StandardCharsets.UTF_8));
} default -> {
}
}
@ -144,7 +144,7 @@ public class CrabClient implements Crab {
private void getLogs() throws IOException {
sendPacket(LOGS_SIZE, "", true);
if (this.cache.sizeInBytes() != lastBufferLength) {
sendPacket(COMMUNICATION, "", true);
sendPacket(LOGS, String.valueOf(cache.sizeInBytes()), true);
}
closeConnection();
printLogs();

View File

@ -3,4 +3,5 @@ package net.pixtaded.crab.common;
public class PID {
public static final byte LOGS_SIZE = 0x00;
public static final byte COMMUNICATION = 0x01;
public static final byte LOGS = 0x02;
}