Added support for sending groupMessages
* Implemented distinguishing between regular messages and groupMessages when sending messages to the server (and sends the right object obviously)
This commit is contained in:
parent
40a38e77dd
commit
ee79ef1c66
@ -241,7 +241,8 @@ public final class ChatScene {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a new message to the server based on the text entered in the
|
||||
* Sends a new message or groupMessage to the server based on the text entered
|
||||
* in the
|
||||
* messageTextArea.
|
||||
*
|
||||
* @since Envoy Client v0.1-beta
|
||||
@ -249,16 +250,29 @@ public final class ChatScene {
|
||||
@FXML
|
||||
private void postMessage() {
|
||||
try {
|
||||
// Create and send message
|
||||
final var message = new MessageBuilder(localDB.getUser().getID(), currentChat.getRecipient().getID(), localDB.getIDGenerator())
|
||||
.setText(messageTextArea.getText().strip())
|
||||
.build();
|
||||
if (currentChat.getRecipient().getClass().equals(Group.class)) {
|
||||
// Create and send groupMessage
|
||||
final var groupMessage = new MessageBuilder(localDB.getUser().getID(), currentChat.getRecipient().getID(), localDB.getIDGenerator())
|
||||
.setText(messageTextArea.getText().strip())
|
||||
.buildGroupMessage((Group) currentChat.getRecipient());
|
||||
|
||||
// Send message
|
||||
writeProxy.writeMessage(message);
|
||||
// Send groupMessage
|
||||
writeProxy.writeMessage(groupMessage);
|
||||
|
||||
// Add message to LocalDB and update UI
|
||||
messageList.getItems().add(message);
|
||||
// Add message to LocalDB and update UI
|
||||
messageList.getItems().add(groupMessage);
|
||||
} else {
|
||||
// Create and send message
|
||||
final var message = new MessageBuilder(localDB.getUser().getID(), currentChat.getRecipient().getID(), localDB.getIDGenerator())
|
||||
.setText(messageTextArea.getText().strip())
|
||||
.build();
|
||||
|
||||
// Send message
|
||||
writeProxy.writeMessage(message);
|
||||
|
||||
// Add message to LocalDB and update UI
|
||||
messageList.getItems().add(message);
|
||||
}
|
||||
|
||||
// Request a new ID generator if all IDs were used
|
||||
if (!localDB.getIDGenerator().hasNext() && client.isOnline()) client.requestIdGenerator();
|
||||
|
Reference in New Issue
Block a user