forked from pixtaded/crab
Port the client to RACv1.99.2
This commit is contained in:
parent
3e6aefd4d2
commit
61ddfc86d1
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user