forked from pixtaded/crab
master #1
@ -123,9 +123,9 @@ public class CrabClient implements Crab {
|
|||||||
int response = in.read(buffer);
|
int response = in.read(buffer);
|
||||||
String convertedString = new String(buffer).trim();
|
String convertedString = new String(buffer).trim();
|
||||||
if (!convertedString.isEmpty()) lastBufferLength = Integer.parseInt(convertedString);
|
if (!convertedString.isEmpty()) lastBufferLength = Integer.parseInt(convertedString);
|
||||||
} case COMMUNICATION -> {
|
} case LOGS -> {
|
||||||
byte[] bytes = socket.getInputStream().readNBytes(lastBufferLength);
|
byte[] bytes = socket.getInputStream().readNBytes(lastBufferLength - cache.sizeInBytes());
|
||||||
cache = new Logs(lastBufferLength, new String(bytes, StandardCharsets.UTF_8));
|
cache = new Logs(lastBufferLength, cache.content() + new String(bytes, StandardCharsets.UTF_8));
|
||||||
} default -> {
|
} default -> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ public class CrabClient implements Crab {
|
|||||||
private void getLogs() throws IOException {
|
private void getLogs() throws IOException {
|
||||||
sendPacket(LOGS_SIZE, "", true);
|
sendPacket(LOGS_SIZE, "", true);
|
||||||
if (this.cache.sizeInBytes() != lastBufferLength) {
|
if (this.cache.sizeInBytes() != lastBufferLength) {
|
||||||
sendPacket(COMMUNICATION, "", true);
|
sendPacket(LOGS, String.valueOf(cache.sizeInBytes()), true);
|
||||||
}
|
}
|
||||||
closeConnection();
|
closeConnection();
|
||||||
printLogs();
|
printLogs();
|
||||||
|
@ -3,4 +3,5 @@ package net.pixtaded.crab.common;
|
|||||||
public class PID {
|
public class PID {
|
||||||
public static final byte LOGS_SIZE = 0x00;
|
public static final byte LOGS_SIZE = 0x00;
|
||||||
public static final byte COMMUNICATION = 0x01;
|
public static final byte COMMUNICATION = 0x01;
|
||||||
|
public static final byte LOGS = 0x02;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user