Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e1d843f79 | ||
|
|
57b20f69cd |
+1
-1
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'net.pixtaded'
|
||||
version = '1.0.2'
|
||||
version = '1.0.3'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -18,6 +18,7 @@ public class CrabClient implements Crab {
|
||||
private BufferedReader in;
|
||||
private int lastBufferLength = 0;
|
||||
private String nickname;
|
||||
private Logs cache = new Logs(0, "");
|
||||
|
||||
public CrabClient() {
|
||||
this.nickname = "";
|
||||
@@ -111,9 +112,12 @@ public class CrabClient implements Crab {
|
||||
int response = in.read(buffer);
|
||||
lastBufferLength = Integer.parseInt(new String(buffer).trim());
|
||||
} case LOGS -> {
|
||||
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));
|
||||
if (cache.sizeInBytes() != lastBufferLength) {
|
||||
byte[] bytes = socket.getInputStream().readNBytes(lastBufferLength);
|
||||
cache = new Logs(lastBufferLength, new String(bytes, StandardCharsets.UTF_8));
|
||||
}
|
||||
clearScreen();
|
||||
System.out.print(Sanitizer.sanitizeString(cache.content(), false));
|
||||
} default -> {
|
||||
}
|
||||
}
|
||||
@@ -135,4 +139,9 @@ public class CrabClient implements Crab {
|
||||
sendPacket(LOGS_SIZE, "");
|
||||
sendPacket(LOGS, "");
|
||||
}
|
||||
|
||||
private void clearScreen() {
|
||||
System.out.print("\033[H\033[2J");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.pixtaded.crab.client;
|
||||
|
||||
public record Logs(int sizeInBytes, String content) {
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public class CrabServer implements Crab {
|
||||
private Socket socket;
|
||||
private boolean isStopped = false;
|
||||
private int port;
|
||||
private Database db;
|
||||
private final Database db;
|
||||
|
||||
public CrabServer() {
|
||||
this.db = new Database("data.db");
|
||||
|
||||
Reference in New Issue
Block a user