Inserted formatting into parser
This commit is contained in:
parent
2263483462
commit
d6e938e87c
@ -11,15 +11,16 @@ public class JServerProtocolParser {
|
|||||||
*/
|
*/
|
||||||
public static void parse(String msg, ClientHandler h) {
|
public static void parse(String msg, ClientHandler h) {
|
||||||
String header = ""; //"header" is the first 5 characters, i.e. the protocol part
|
String header = ""; //"header" is the first 5 characters, i.e. the protocol part
|
||||||
|
String formattedMSG = MessageFormatter.formatMsg(msg);
|
||||||
try {
|
try {
|
||||||
header = msg.substring(0, 5);
|
header = formattedMSG.substring(0, 5);
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
//System.out.println(header); helpful for debugging
|
//System.out.println(header); helpful for debugging
|
||||||
switch (header) {
|
switch (header) {
|
||||||
case "CHATA":
|
case "CHATA":
|
||||||
h.broadcastMessage(msg.substring(6));
|
h.broadcastMessage(formattedMSG.substring(6));
|
||||||
break;
|
break;
|
||||||
case "CPING":
|
case "CPING":
|
||||||
h.sendMsgToClient("PINGB");
|
h.sendMsgToClient("PINGB");
|
||||||
|
|||||||
Reference in New Issue
Block a user