Server shouldn't be sending chat messages back to the sender now

This commit is contained in:
Sebastian Lenzlinger 2022-04-17 16:31:43 +02:00
parent ef8111553e
commit ce4d84c9d7

View File

@ -174,6 +174,9 @@ public class ClientHandler implements Runnable {
Lobby l = getLobby(); Lobby l = getLobby();
if (l != null) { if (l != null) {
for (ClientHandler client : l.getLobbyClients()) { for (ClientHandler client : l.getLobbyClients()) {
if(client.getClientUserName().equals(this.getClientUserName())){
continue;
}
client.sendMsgToClient(Protocol.printToClientChat + "$" + clientUserName + ": " + msg); client.sendMsgToClient(Protocol.printToClientChat + "$" + clientUserName + ": " + msg);
} }
} else { } else {
@ -195,7 +198,6 @@ public class ClientHandler implements Runnable {
Lobby l = getLobby(); Lobby l = getLobby();
if (l != null) { if (l != null) {
for (ClientHandler client : l.getLobbyClients()) { for (ClientHandler client : l.getLobbyClients()) {
//Todo do not send chat msg to self
client.sendMsgToClient(Protocol.printToClientChat + "$" + msg); client.sendMsgToClient(Protocol.printToClientChat + "$" + msg);
} }
} }