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