Formatting of how chat messages are displayed, too short a protocol message doesnt print exception stack trace.
This commit is contained in:
parent
6071ea4b2f
commit
141a4783b9
@ -14,7 +14,7 @@ public class JClientProtocolParser {
|
||||
try {
|
||||
header = msg.substring(0, 5);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Received unknown command");
|
||||
}
|
||||
//System.out.println(header); helpful for debugging
|
||||
switch (header) {
|
||||
|
||||
@ -49,10 +49,8 @@ public class ClientPinger implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
isConnected = false; //in case the socket accidentally disconnects (can this happen?)
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
isConnected = false; //in case the socket accidentally disconnects (can this happen?)
|
||||
} catch (InterruptedException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,9 +50,7 @@ public class ServerPinger implements Runnable {
|
||||
}
|
||||
}
|
||||
isConnected = false; //in case the socket accidentally disconnects (can this happen?)
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
} catch (InterruptedException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,18 +94,7 @@ public class ClientHandler implements Runnable {
|
||||
|
||||
public void broadcastMessage(String msg) {
|
||||
for (ClientHandler client : connectedClients) {
|
||||
try {
|
||||
if (!client.clientUserName.equals((clientUserName))) {
|
||||
client.out.write("CHATM:" + msg);
|
||||
} else {
|
||||
client.out.write("CHATM:Message: **" + msg + "** sent!");
|
||||
}
|
||||
client.out.newLine();
|
||||
client.out.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
closeEverything(socket, in, out);
|
||||
}
|
||||
client.sendMsgToClient("CHATM:" + clientUserName + ": \"" + msg + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ public class JServerProtocolParser {
|
||||
try {
|
||||
header = msg.substring(0, 5);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Received unknown command");
|
||||
}
|
||||
//System.out.println(header); helpful for debugging
|
||||
switch (header) {
|
||||
|
||||
Reference in New Issue
Block a user