Added CRTGM debug logger to JServerProtocolParser to see if command is reached. added "/g" as terminal command for client to issue CRTGM command. remobed respective todos from Protocol.java.
This commit is contained in:
parent
e2a400d0ca
commit
dd2beb559a
@ -47,6 +47,11 @@ public class MessageFormatter {
|
||||
s = "U.N. Owen";
|
||||
}
|
||||
break;
|
||||
case "/g":
|
||||
stringBuilder.append(Protocol.createNewGame + "$");
|
||||
s = "";
|
||||
//TODO add LOGGER msg. Find out if .info or .debug.
|
||||
break;
|
||||
default:
|
||||
s = msg;
|
||||
}
|
||||
|
||||
@ -54,10 +54,10 @@ public class Protocol {
|
||||
|
||||
/**
|
||||
* TODO: enable for client
|
||||
* TODO: add to JClientProtocolParser {@link ch.unibas.dmi.dbis.cs108.multiplayer.client.JClientProtocolParser}
|
||||
* TODO: add to JSeverProtocolParser {@link ch.unibas.dmi.dbis.cs108.multiplayer.server.JServerProtocolParser}
|
||||
* TODO: add sever response
|
||||
* Client sends this message when he wants to create a new game.
|
||||
* Client issues this command in {@link ch.unibas.dmi.dbis.cs108.multiplayer.client.MessageFormatter}
|
||||
* using "/g".
|
||||
* First a lobby {@link ch.unibas.dmi.dbis.cs108.sebaschi.Lobby} is created of which the requesting client is the admin of.
|
||||
*/
|
||||
public static final String createNewGame = "CRTGM";
|
||||
|
||||
@ -10,9 +10,10 @@ Implemented:
|
||||
* CPING Ping from client to server.
|
||||
* PINGB Pingback from client to server.
|
||||
* NAMEC$name Change name to whatever is specified
|
||||
* CRTGM Create a new game
|
||||
|
||||
Future / planned:
|
||||
* CRTGM Create a new game
|
||||
|
||||
* CHATW whisper chat
|
||||
* CHATG ghost chat
|
||||
* LEAVG leave a game
|
||||
|
||||
@ -7,6 +7,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
||||
|
||||
public class JServerProtocolParser {
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
@ -17,10 +18,9 @@ public class JServerProtocolParser {
|
||||
|
||||
|
||||
/**
|
||||
* Used by the server (i.e. ClientHandler) to parse an incoming protocol message.
|
||||
* For documentation on the individual Protocol messages, view the Protocol.java
|
||||
* class or hover over the commands (e.g. Protocol.chatMsgToAll) with your mouse
|
||||
* in this class.
|
||||
* Used by the server (i.e. ClientHandler) to parse an incoming protocol message. For
|
||||
* documentation on the individual Protocol messages, view the Protocol.java class or hover over
|
||||
* the commands (e.g. Protocol.chatMsgToAll) with your mouse in this class.
|
||||
*
|
||||
* @param msg the encoded message that needs to be parsed
|
||||
* @param h this ClientHandler (required so this method can access the ClientHandler's methods)
|
||||
@ -57,6 +57,12 @@ public class JServerProtocolParser {
|
||||
case Protocol.clientQuitRequest:
|
||||
h.removeClientOnLogout();
|
||||
break;
|
||||
case Protocol.createNewGame:
|
||||
// TODO add h.openLobby(h) method
|
||||
LOGGER.debug(Protocol.createNewGame
|
||||
+ " command reached in JServerProtocolParser. Command issued by: "
|
||||
+ h.getClientUserName());
|
||||
break;
|
||||
default:
|
||||
System.out.println("Received unknown command");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user