master #1

Merged
bedohswe merged 27 commits from pixtaded/crab:master into master 2025-02-11 18:05:01 +00:00
2 changed files with 5 additions and 4 deletions
Showing only changes of commit 61ddfc86d1 - Show all commits

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;
}