Network and Frontend #10
|
@ -24,6 +24,11 @@ public class AsyncSocket {
|
|||
|
||||
this.checkerThread = new Thread(() -> {
|
||||
while (!this.shouldStop) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (!this.in.ready()) continue;
|
||||
if (this.handler == null) continue;
|
||||
|
@ -31,16 +36,11 @@ public class AsyncSocket {
|
|||
String message = this.in.readLine();
|
||||
if (message.length() <= 0) continue;
|
||||
|
||||
// TODO: remove \r\n
|
||||
this.handler.receive(message);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.checkerThread.start();
|
||||
|
|
Loading…
Reference in New Issue