Made several small adjustments:
-regarding disconnection handling -corrected import statements in GameFunctions.java
This commit is contained in:
parent
5b3af54720
commit
5010b66d4c
@ -1,8 +1,8 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.klassenstruktur.Human;
|
||||
import ch.unibas.dmi.dbis.cs108.klassenstruktur.Passenger;
|
||||
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Human;
|
||||
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ public class MessageFormatter {
|
||||
break;
|
||||
case "/q":
|
||||
stringBuilder.append("QUITS$");
|
||||
s = msg.substring(3);
|
||||
s = "";
|
||||
break;
|
||||
case "/n":
|
||||
stringBuilder.append("NAMEC$");
|
||||
|
||||
@ -89,7 +89,7 @@ public class ClientHandler implements Runnable {
|
||||
String msg;
|
||||
while (socket.isConnected()) {
|
||||
try {
|
||||
msg = in.readLine();
|
||||
msg = in.readLine(); //todo: here is where the server throws an exception when the client quits
|
||||
JServerProtocolParser.parse(msg, this);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@ -132,7 +132,7 @@ public class ClientHandler implements Runnable {
|
||||
}
|
||||
|
||||
/** Sends a given message to client
|
||||
*
|
||||
* todo: check for exception if out is closed.
|
||||
* @param msg the given message
|
||||
*/
|
||||
|
||||
|
||||
@ -9,6 +9,11 @@ public class JServerProtocolParser {
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
/**
|
||||
* jsdcjkhcsdjksdacjkn
|
||||
*/
|
||||
public static final String CHATA = "CHATA";
|
||||
|
||||
/**
|
||||
* Used by the server (i.e. ClientHandler) to parse an incoming protocol message.
|
||||
*
|
||||
@ -23,7 +28,7 @@ public class JServerProtocolParser {
|
||||
System.out.println("Received unknown command");
|
||||
}
|
||||
switch (header) {
|
||||
case "CHATA":
|
||||
case CHATA:
|
||||
//sends chat message to all connected clients
|
||||
h.broadcastMessage(msg.substring(6));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user