This commit is contained in:
Sem van der Hoeven
2020-06-07 13:43:05 +02:00
parent 7abe8e22a1
commit 1be186e113
8 changed files with 124 additions and 25 deletions

View File

@@ -29,6 +29,7 @@ public class ServerClient implements Runnable {
public void writeData(Data data) {
try {
System.out.println("[SERVERCLIENT] writing data " + data);
this.out.writeObject(data);
} catch (IOException e) {
e.printStackTrace();
@@ -40,6 +41,7 @@ public class ServerClient implements Runnable {
while (this.isConnected) {
try {
Object object = this.in.readObject();
System.out.println("[SERVERCLIENT] got object " + object);
if (object instanceof Data) {
Data data = (Data) object;
if (data.getPayload() instanceof ConnectionData) {
@@ -49,7 +51,9 @@ public class ServerClient implements Runnable {
//todo properly remove thread.
}
} else {
callback.onDataReceived((Data) this.in.readObject());
// callback.onDataReceived((Data) this.in.readObject());
System.out.println("[SERVERCLIENT] got data: " + data + ", sending callback");
callback.onDataReceived(data);
}
}
} catch (IOException e) {