Added Data parser call to the ServerClient class.

Added comments, helper functions and finished the framework of the SessionController.
This commit is contained in:
MickWerf
2020-05-18 15:04:22 +02:00
parent 94ecff6799
commit 7601496e40
2 changed files with 101 additions and 73 deletions

View File

@@ -1,6 +1,7 @@
package netwerkprog.game.server;
import netwerkprog.game.server.controllers.SessionController;
import netwerkprog.game.server.data.Data;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -50,12 +51,14 @@ public class ServerClient implements Runnable {
while (isConnected) {
try {
String received = this.in.readUTF();
if (received.equals("\\quit")) {
isConnected = false;
Data data = server.parseData(received);
if (data.toString().equals("\\quit")) {
this.isConnected = false;
this.server.removeClient(this);
} else {
this.server.sendToEveryoneExcept(this.name,"<" + this.name + "> : " + received);
this.out.writeUTF(data.toString());
}
} catch (IOException e) {
System.out.println("[SERVERCLIENT] caught exception - " + e.getMessage());
System.out.println("[SERVERCLIENT] terminating failing connection...");