whisper is functional in with gui. decode whisper msg added to client handler and used in JServerProtcolParser now to correctly decode the messages

This commit is contained in:
Sebastian Lenzlinger 2022-04-17 15:38:40 +02:00
parent dad2cf1cd8
commit 61697d7597
2 changed files with 9 additions and 0 deletions

View File

@ -112,6 +112,8 @@ public class ChatController implements Initializable {
l.setBackground(Background.fill(Color.LAVENDER)); l.setBackground(Background.fill(Color.LAVENDER));
vBoxChatMessages.getChildren().add(l); vBoxChatMessages.getChildren().add(l);
chatMsgField.clear(); chatMsgField.clear();
} else {
LOGGER.debug("Trying to send an empty message.");
} }
} }
}); });
@ -146,11 +148,17 @@ public class ChatController implements Initializable {
} }
}); });
//Possibly now the whisperTargetChosenProperty is obsolete
whisperTargetSelectField.textProperty().addListener(new ChangeListener<String>() { whisperTargetSelectField.textProperty().addListener(new ChangeListener<String>() {
@Override @Override
public void changed(ObservableValue<? extends String> observable, String oldValue, public void changed(ObservableValue<? extends String> observable, String oldValue,
String newValue) { String newValue) {
whisperTargetSelectField.setText(newValue); whisperTargetSelectField.setText(newValue);
if (newValue.isEmpty()) {
cmd = chatToLobby + "$";
} else {
cmd = whisper + "$" + whisperTargetSelectField.getText() + "$";
}
} }
}); });
} }

View File

@ -195,6 +195,7 @@ 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);
} }
} }