From 8826d0c3d3bb4b6d372bc5a498373d758a8de1d0 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Fri, 12 Jun 2020 23:50:52 +0200 Subject: [PATCH 1/9] Added support for sending groupMessages * Implemented distinguishing between regular messages and groupMessages when sending messages to the server (and sends the right object obviously) --- .../envoy/client/ui/controller/ChatScene.java | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index 8f7b487..cc6b018 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -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(); From 7a11b556d99b850db1d26158b8eea47b555445c2 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sat, 13 Jun 2020 10:40:47 +0200 Subject: [PATCH 2/9] Added ReceivedGroupMessageProcessor Receiving groupMessages works now properly(only if online) --- src/main/java/envoy/client/net/Client.java | 3 ++ .../net/ReceivedGroupMessageProcessor.java | 33 +++++++++++++++++++ .../envoy/client/ui/controller/ChatScene.java | 16 +++++++-- 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 src/main/java/envoy/client/net/ReceivedGroupMessageProcessor.java diff --git a/src/main/java/envoy/client/net/Client.java b/src/main/java/envoy/client/net/Client.java index 9f9dad7..f7f38a6 100644 --- a/src/main/java/envoy/client/net/Client.java +++ b/src/main/java/envoy/client/net/Client.java @@ -139,6 +139,9 @@ public class Client implements Closeable { final ReceivedMessageProcessor receivedMessageProcessor = new ReceivedMessageProcessor(); final MessageStatusChangeEventProcessor messageStatusChangeEventProcessor = new MessageStatusChangeEventProcessor(); + // TODO: Define a cache + receiver.registerProcessor(GroupMessage.class, new ReceivedGroupMessageProcessor()); + receiver.registerProcessor(Message.class, receivedMessageProcessor); // Relay cached unread messages diff --git a/src/main/java/envoy/client/net/ReceivedGroupMessageProcessor.java b/src/main/java/envoy/client/net/ReceivedGroupMessageProcessor.java new file mode 100644 index 0000000..877d0f0 --- /dev/null +++ b/src/main/java/envoy/client/net/ReceivedGroupMessageProcessor.java @@ -0,0 +1,33 @@ +package envoy.client.net; + +import java.util.function.Consumer; +import java.util.logging.Logger; + +import envoy.client.event.MessageCreationEvent; +import envoy.data.GroupMessage; +import envoy.data.Message.MessageStatus; +import envoy.event.EventBus; +import envoy.util.EnvoyLog; + +/** + * Project: envoy-client
+ * File: ReceivedGroupMessageProcessor.java
+ * Created: 13.06.2020
+ * + * @author Maximilian Käfer + * @since Envoy Client v0.1-beta + */ +public class ReceivedGroupMessageProcessor implements Consumer { + + private static final Logger logger = EnvoyLog.getLogger(ReceivedGroupMessageProcessor.class); + + @Override + public void accept(GroupMessage groupMessage) { + if (groupMessage.getStatus() == MessageStatus.WAITING || groupMessage.getStatus() == MessageStatus.READ) + logger.warning("The groupMessage has the unexpected status " + groupMessage.getStatus()); + + // Dispatch event + EventBus.getInstance().dispatch(new MessageCreationEvent(groupMessage)); + } + +} diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index cc6b018..48347e7 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -88,13 +88,23 @@ public final class ChatScene { // Listen to received messages eventBus.register(MessageCreationEvent.class, e -> { final var message = e.get(); - localDB.getChat(message.getSenderID()).ifPresent(chat -> { - chat.getMessages().add(message); + if (message.getClass().equals(Message.class)) { + localDB.getChat(message.getSenderID()).ifPresent(chat -> { + chat.getMessages().add(message); // Update UI if in current chat if (chat == currentChat) Platform.runLater(messageList::refresh); - }); + }); + } else { + localDB.getChat(message.getRecipientID()).ifPresent(chat -> { + chat.getMessages().add(message); + + // Update UI if in current chat + if (chat == currentChat) + Platform.runLater(messageList::refresh); + }); + } }); // Listen to message status changes From 7723db672be32e8e89c7b6a76ab3a41b734f0206 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sun, 28 Jun 2020 13:20:10 +0200 Subject: [PATCH 3/9] Implemented pendingMessage processing using an extra cache --- src/main/java/envoy/client/net/Client.java | 24 +++++++++++++++---- src/main/java/envoy/client/net/Receiver.java | 3 ++- src/main/java/envoy/client/ui/Startup.java | 5 +++- .../client/ui/controller/LoginScene.java | 15 +++++++----- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/main/java/envoy/client/net/Client.java b/src/main/java/envoy/client/net/Client.java index b4b1ed0..cf41d93 100644 --- a/src/main/java/envoy/client/net/Client.java +++ b/src/main/java/envoy/client/net/Client.java @@ -59,6 +59,12 @@ public class Client implements Closeable { * from the server that can be relayed * after * initialization + * @param receivedGroupMessageCache a groupMessage cache containing all + * unread + * groupMessages + * from the server that can be relayed + * after + * initialization * @param receivedMessageStatusChangeCache an event cache containing all * received messageStatusChangeEvents * from the server that can be relayed @@ -68,7 +74,7 @@ public class Client implements Closeable { * @throws InterruptedException if the current thread is interrupted while * waiting for the handshake response */ - public void performHandshake(LoginCredentials credentials, Cache receivedMessageCache, + public void performHandshake(LoginCredentials credentials, Cache receivedMessageCache, Cache receivedGroupMessageCache, Cache receivedMessageStatusChangeCache) throws TimeoutException, IOException, InterruptedException { if (online) throw new IllegalStateException("Handshake has already been performed successfully"); @@ -83,6 +89,7 @@ public class Client implements Closeable { // Register user creation processor, contact list processor and message cache receiver.registerProcessor(User.class, sender -> this.sender = sender); receiver.registerProcessor(Message.class, receivedMessageCache); + receiver.registerProcessor(GroupMessage.class, receivedGroupMessageCache); receiver.registerProcessor(MessageStatusChange.class, receivedMessageStatusChangeCache); receiver.registerProcessor(HandshakeRejection.class, evt -> { rejected = true; eventBus.dispatch(evt); }); @@ -130,6 +137,12 @@ public class Client implements Closeable { * from the server that can be relayed * after * initialization + * @param receivedGroupMessageCache a groupMessage cache containing all + * unread + * groupMessages + * from the server that can be relayed + * after + * initialization * @param receivedMessageStatusChangeCache an event cache containing all * received messageStatusChangeEvents * from the server that can be relayed @@ -138,21 +151,24 @@ public class Client implements Closeable { * requested from the server * @since Envoy Client v0.2-alpha */ - public void initReceiver(LocalDB localDB, Cache receivedMessageCache, Cache receivedMessageStatusChangeCache) + public void initReceiver(LocalDB localDB, Cache receivedMessageCache, Cache receivedGroupMessageCache, + Cache receivedMessageStatusChangeCache) throws IOException { checkOnline(); // Process incoming messages final ReceivedMessageProcessor receivedMessageProcessor = new ReceivedMessageProcessor(); + final ReceivedGroupMessageProcessor receivedGroupMessageProcessor = new ReceivedGroupMessageProcessor(); final MessageStatusChangeProcessor messageStatusChangeEventProcessor = new MessageStatusChangeProcessor(); // TODO: Define a cache - receiver.registerProcessor(GroupMessage.class, new ReceivedGroupMessageProcessor()); + receiver.registerProcessor(GroupMessage.class, receivedGroupMessageProcessor); receiver.registerProcessor(Message.class, receivedMessageProcessor); - // Relay cached unread messages + // Relay cached unread messages and unread groupMessages receivedMessageCache.setProcessor(receivedMessageProcessor); + receivedGroupMessageCache.setProcessor(receivedGroupMessageProcessor); // Process message status changes receiver.registerProcessor(MessageStatusChange.class, messageStatusChangeEventProcessor); diff --git a/src/main/java/envoy/client/net/Receiver.java b/src/main/java/envoy/client/net/Receiver.java index c71e5ed..dbcca32 100644 --- a/src/main/java/envoy/client/net/Receiver.java +++ b/src/main/java/envoy/client/net/Receiver.java @@ -71,7 +71,8 @@ public class Receiver extends Thread { final Consumer processor = processors.get(obj.getClass()); if (processor == null) logger.log(Level.WARNING, String.format( - "The received object has the class %s for which no processor is defined.", obj.getClass())); + "The received object has the %s for which no processor is defined.", + obj.getClass())); else processor.accept(obj); } } diff --git a/src/main/java/envoy/client/ui/Startup.java b/src/main/java/envoy/client/ui/Startup.java index f57b22e..b8882e6 100644 --- a/src/main/java/envoy/client/ui/Startup.java +++ b/src/main/java/envoy/client/ui/Startup.java @@ -15,6 +15,7 @@ import envoy.client.data.*; import envoy.client.net.Client; import envoy.client.ui.SceneContext.SceneInfo; import envoy.client.ui.controller.LoginScene; +import envoy.data.GroupMessage; import envoy.data.Message; import envoy.event.MessageStatusChange; import envoy.exception.EnvoyException; @@ -43,6 +44,7 @@ public final class Startup extends Application { private LocalDB localDB; private Client client; private Cache messageCache; + private Cache groupMessageCache; private Cache messageStatusCache; private static final ClientConfig config = ClientConfig.getInstance(); @@ -99,6 +101,7 @@ public final class Startup extends Application { // Initialize client and unread message cache client = new Client(); messageCache = new Cache<>(); + groupMessageCache = new Cache<>(); messageStatusCache = new Cache<>(); stage.setTitle("Envoy"); @@ -106,7 +109,7 @@ public final class Startup extends Application { final var sceneContext = new SceneContext(stage); sceneContext.load(SceneInfo.LOGIN_SCENE); - sceneContext.getController().initializeData(client, localDB, messageCache, messageStatusCache, sceneContext); + sceneContext.getController().initializeData(client, localDB, messageCache, groupMessageCache, messageStatusCache, sceneContext); } /** diff --git a/src/main/java/envoy/client/ui/controller/LoginScene.java b/src/main/java/envoy/client/ui/controller/LoginScene.java index 380842a..95350c7 100644 --- a/src/main/java/envoy/client/ui/controller/LoginScene.java +++ b/src/main/java/envoy/client/ui/controller/LoginScene.java @@ -15,9 +15,7 @@ import envoy.client.data.*; import envoy.client.net.Client; import envoy.client.ui.SceneContext; import envoy.client.ui.Startup; -import envoy.data.LoginCredentials; -import envoy.data.Message; -import envoy.data.User; +import envoy.data.*; import envoy.data.User.UserStatus; import envoy.event.EventBus; import envoy.event.HandshakeRejection; @@ -58,6 +56,7 @@ public final class LoginScene { private Client client; private LocalDB localDB; private Cache receivedMessageCache; + private Cache receivedGroupMessageCache; private Cache receivedMessageStatusChangeCache; private SceneContext sceneContext; @@ -83,6 +82,8 @@ public final class LoginScene { * @param receivedMessageCache the cache storing messages received * during * the handshake + * @param receivedGroupMessageCache the cache storing groupMessages + * received during the handshake * @param receivedMessageStatusChangeCache the cache storing * messageStatusChangeEvents received * during handshake @@ -91,11 +92,12 @@ public final class LoginScene { * scene * @since Envoy Client v0.1-beta */ - public void initializeData(Client client, LocalDB localDB, Cache receivedMessageCache, + public void initializeData(Client client, LocalDB localDB, Cache receivedMessageCache, Cache receivedGroupMessageCache, Cache receivedMessageStatusChangeCache, SceneContext sceneContext) { this.client = client; this.localDB = localDB; this.receivedMessageCache = receivedMessageCache; + this.receivedGroupMessageCache = receivedGroupMessageCache; this.receivedMessageStatusChangeCache = receivedMessageStatusChangeCache; this.sceneContext = sceneContext; @@ -145,9 +147,9 @@ public final class LoginScene { private void performHandshake(LoginCredentials credentials) { try { - client.performHandshake(credentials, receivedMessageCache, receivedMessageStatusChangeCache); + client.performHandshake(credentials, receivedMessageCache, receivedGroupMessageCache, receivedMessageStatusChangeCache); if (client.isOnline()) { - client.initReceiver(localDB, receivedMessageCache, receivedMessageStatusChangeCache); + client.initReceiver(localDB, receivedMessageCache, receivedGroupMessageCache, receivedMessageStatusChangeCache); loadChatScene(); } } catch (IOException | InterruptedException | TimeoutException e) { @@ -212,6 +214,7 @@ public final class LoginScene { // Relay unread messages from cache if (receivedMessageCache != null && client.isOnline()) receivedMessageCache.relay(); + if (receivedGroupMessageCache != null && client.isOnline()) receivedGroupMessageCache.relay(); if (receivedMessageStatusChangeCache != null && client.isOnline()) receivedMessageStatusChangeCache.relay(); } } From 289f2b70328b19f3c067b1a4db61bc6774266a30 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Fri, 3 Jul 2020 13:47:40 +0200 Subject: [PATCH 4/9] Implemented GroupMessage reading (sending the right event) Note: changed a lambda expression in LocalDB and not 100% sure if it is correct --- src/main/java/envoy/client/data/Chat.java | 33 +++++++++++++++---- src/main/java/envoy/client/data/LocalDB.java | 2 +- .../envoy/client/ui/controller/ChatScene.java | 2 +- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/main/java/envoy/client/data/Chat.java b/src/main/java/envoy/client/data/Chat.java index 7ca11ce..207fb1f 100644 --- a/src/main/java/envoy/client/data/Chat.java +++ b/src/main/java/envoy/client/data/Chat.java @@ -2,6 +2,7 @@ package envoy.client.data; import java.io.IOException; import java.io.Serializable; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -9,6 +10,7 @@ import java.util.Objects; import envoy.client.net.WriteProxy; import envoy.data.*; import envoy.data.Message.MessageStatus; +import envoy.event.GroupMessageStatusChange; import envoy.event.MessageStatusChange; /** @@ -27,18 +29,25 @@ import envoy.event.MessageStatusChange; public final class Chat implements Serializable { private final Contact recipient; + private final Contact sender; private final List messages = new ArrayList<>(); private static final long serialVersionUID = 1L; /** - * Provides the list of messages that the recipient receives.

+ * Provides the list of messages that the recipient receives. + *

* Saves the Messages in the corresponding chat at that Point. * * @param recipient the user who receives the messages + * @param sender the user who is logged in as sender on this instance of + * envoy.client * @since Envoy Client v0.1-alpha */ - public Chat(Contact recipient) { this.recipient = recipient; } + public Chat(Contact recipient, Contact sender) { + this.recipient = recipient; + this.sender = sender; + } @Override public String toString() { return String.format("Chat[recipient=%s,messages=%d]", recipient, messages.size()); } @@ -78,10 +87,22 @@ public final class Chat implements Serializable { public void read(WriteProxy writeProxy) throws IOException { for (int i = messages.size() - 1; i >= 0; --i) { final Message m = messages.get(i); - if (m.getSenderID() == recipient.getID()) if (m.getStatus() == MessageStatus.READ) break; - else { - m.setStatus(MessageStatus.READ); - writeProxy.writeMessageStatusChange(new MessageStatusChange(m)); + if(m.getClass().equals(GroupMessage.class)) { + GroupMessage g = (GroupMessage) m; + if (g.getSenderID() != sender.getID()) { + if (g.getMemberStatuses().get(sender.getID()) == MessageStatus.READ) break; + else { + g.getMemberStatuses().replace(sender.getID(), MessageStatus.READ); + writeProxy.writeMessageStatusChange( + new GroupMessageStatusChange(g.getID(), MessageStatus.READ, LocalDateTime.now(), sender.getID())); + } + } + }else { + if (m.getSenderID() == recipient.getID()) if (m.getStatus() == MessageStatus.READ) break; + else { + m.setStatus(MessageStatus.READ); + writeProxy.writeMessageStatusChange(new MessageStatusChange(m)); + } } } } diff --git a/src/main/java/envoy/client/data/LocalDB.java b/src/main/java/envoy/client/data/LocalDB.java index d8993f5..315b27d 100644 --- a/src/main/java/envoy/client/data/LocalDB.java +++ b/src/main/java/envoy/client/data/LocalDB.java @@ -82,7 +82,7 @@ public abstract class LocalDB { getChat(contact.getID()).ifPresent(chat -> { ((User) chat.getRecipient()).setStatus(((User) contact).getStatus()); }); // Create missing chats - user.getContacts().stream().filter(u -> !u.equals(user) && getChat(u.getID()).isEmpty()).map(Chat::new).forEach(chats::add); + user.getContacts().stream().filter(u -> !u.equals(user) && getChat(u.getID()).isEmpty()).map(u -> new Chat(u, user)).forEach(chats::add); } /** diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index a092234..c3aa608 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -146,7 +146,7 @@ public final class ChatScene { switch (e.getOperationType()) { case ADD: localDB.getUsers().put(contact.getName(), contact); - localDB.getChats().add(new Chat(contact)); + localDB.getChats().add(new Chat(contact, client.getSender())); Platform.runLater(() -> userList.getItems().add(contact)); break; case REMOVE: From 96fc06a8e5112ee54ebb8a2873a29217d3c0e905 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sat, 4 Jul 2020 15:43:46 +0200 Subject: [PATCH 5/9] Implemented GroupMessageStatusChangeProcessor and a Cache for those --- src/main/java/envoy/client/net/Client.java | 17 +++++++---- .../GroupMessageStatusChangeProcessor.java | 29 +++++++++++++++++++ src/main/java/envoy/client/ui/Startup.java | 6 +++- .../envoy/client/ui/controller/ChatScene.java | 12 +++++--- .../client/ui/controller/LoginScene.java | 22 ++++++++++---- 5 files changed, 69 insertions(+), 17 deletions(-) create mode 100644 src/main/java/envoy/client/net/GroupMessageStatusChangeProcessor.java diff --git a/src/main/java/envoy/client/net/Client.java b/src/main/java/envoy/client/net/Client.java index cf41d93..fb4f114 100644 --- a/src/main/java/envoy/client/net/Client.java +++ b/src/main/java/envoy/client/net/Client.java @@ -75,7 +75,8 @@ public class Client implements Closeable { * waiting for the handshake response */ public void performHandshake(LoginCredentials credentials, Cache receivedMessageCache, Cache receivedGroupMessageCache, - Cache receivedMessageStatusChangeCache) throws TimeoutException, IOException, InterruptedException { + Cache receivedMessageStatusChangeCache, Cache receivedGroupMessageStatusChangeCache) + throws TimeoutException, IOException, InterruptedException { if (online) throw new IllegalStateException("Handshake has already been performed successfully"); // Establish TCP connection @@ -91,6 +92,7 @@ public class Client implements Closeable { receiver.registerProcessor(Message.class, receivedMessageCache); receiver.registerProcessor(GroupMessage.class, receivedGroupMessageCache); receiver.registerProcessor(MessageStatusChange.class, receivedMessageStatusChangeCache); + receiver.registerProcessor(GroupMessageStatusChange.class, receivedGroupMessageStatusChangeCache); receiver.registerProcessor(HandshakeRejection.class, evt -> { rejected = true; eventBus.dispatch(evt); }); rejected = false; @@ -152,27 +154,30 @@ public class Client implements Closeable { * @since Envoy Client v0.2-alpha */ public void initReceiver(LocalDB localDB, Cache receivedMessageCache, Cache receivedGroupMessageCache, - Cache receivedMessageStatusChangeCache) + Cache receivedMessageStatusChangeCache, Cache receivedGroupMessageStatusChangeCache) throws IOException { checkOnline(); // Process incoming messages final ReceivedMessageProcessor receivedMessageProcessor = new ReceivedMessageProcessor(); final ReceivedGroupMessageProcessor receivedGroupMessageProcessor = new ReceivedGroupMessageProcessor(); - final MessageStatusChangeProcessor messageStatusChangeEventProcessor = new MessageStatusChangeProcessor(); + final MessageStatusChangeProcessor messageStatusChangeProcessor = new MessageStatusChangeProcessor(); + final GroupMessageStatusChangeProcessor groupMessageStatusChangeProcessor = new GroupMessageStatusChangeProcessor(); - // TODO: Define a cache receiver.registerProcessor(GroupMessage.class, receivedGroupMessageProcessor); receiver.registerProcessor(Message.class, receivedMessageProcessor); + receiver.registerProcessor(MessageStatusChange.class, messageStatusChangeProcessor); + + receiver.registerProcessor(GroupMessageStatusChange.class, groupMessageStatusChangeProcessor); // Relay cached unread messages and unread groupMessages receivedMessageCache.setProcessor(receivedMessageProcessor); receivedGroupMessageCache.setProcessor(receivedGroupMessageProcessor); // Process message status changes - receiver.registerProcessor(MessageStatusChange.class, messageStatusChangeEventProcessor); - receivedMessageStatusChangeCache.setProcessor(messageStatusChangeEventProcessor); + receivedMessageStatusChangeCache.setProcessor(messageStatusChangeProcessor); + receivedGroupMessageStatusChangeCache.setProcessor(groupMessageStatusChangeProcessor); // Process user status changes receiver.registerProcessor(UserStatusChange.class, eventBus::dispatch); diff --git a/src/main/java/envoy/client/net/GroupMessageStatusChangeProcessor.java b/src/main/java/envoy/client/net/GroupMessageStatusChangeProcessor.java new file mode 100644 index 0000000..ce3dc73 --- /dev/null +++ b/src/main/java/envoy/client/net/GroupMessageStatusChangeProcessor.java @@ -0,0 +1,29 @@ +package envoy.client.net; + +import java.util.function.Consumer; +import java.util.logging.Logger; + +import envoy.data.Message.MessageStatus; +import envoy.event.EventBus; +import envoy.event.GroupMessageStatusChange; +import envoy.util.EnvoyLog; + +/** + * Project: envoy-client
+ * File: GroupMessageStatusChangePocessor.java
+ * Created: 03.07.2020
+ * + * @author Maximilian Käfer + * @since Envoy Client v0.1-beta + */ +public class GroupMessageStatusChangeProcessor implements Consumer { + + private static final Logger logger = EnvoyLog.getLogger(GroupMessageStatusChangeProcessor.class); + + @Override + public void accept(GroupMessageStatusChange evt) { + if (evt.get().ordinal() < MessageStatus.RECEIVED.ordinal()) logger.warning("Received invalid group message status change " + evt); + else EventBus.getInstance().dispatch(evt); + } + +} diff --git a/src/main/java/envoy/client/ui/Startup.java b/src/main/java/envoy/client/ui/Startup.java index b8882e6..de3289f 100644 --- a/src/main/java/envoy/client/ui/Startup.java +++ b/src/main/java/envoy/client/ui/Startup.java @@ -17,6 +17,7 @@ import envoy.client.ui.SceneContext.SceneInfo; import envoy.client.ui.controller.LoginScene; import envoy.data.GroupMessage; import envoy.data.Message; +import envoy.event.GroupMessageStatusChange; import envoy.event.MessageStatusChange; import envoy.exception.EnvoyException; import envoy.util.EnvoyLog; @@ -46,6 +47,7 @@ public final class Startup extends Application { private Cache messageCache; private Cache groupMessageCache; private Cache messageStatusCache; + private Cache groupMessageStatusCache; private static final ClientConfig config = ClientConfig.getInstance(); private static final Logger logger = EnvoyLog.getLogger(Startup.class); @@ -103,13 +105,15 @@ public final class Startup extends Application { messageCache = new Cache<>(); groupMessageCache = new Cache<>(); messageStatusCache = new Cache<>(); + groupMessageStatusCache = new Cache<>(); stage.setTitle("Envoy"); stage.getIcons().add(IconUtil.load("/icons/envoy_logo.png")); final var sceneContext = new SceneContext(stage); sceneContext.load(SceneInfo.LOGIN_SCENE); - sceneContext.getController().initializeData(client, localDB, messageCache, groupMessageCache, messageStatusCache, sceneContext); + sceneContext.getController() + .initializeData(client, localDB, messageCache, groupMessageCache, messageStatusCache, groupMessageStatusCache, sceneContext); } /** diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index c3aa608..f5f454b 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -26,9 +26,7 @@ import envoy.client.net.Client; import envoy.client.net.WriteProxy; import envoy.client.ui.*; import envoy.data.*; -import envoy.event.EventBus; -import envoy.event.MessageStatusChange; -import envoy.event.UserStatusChange; +import envoy.event.*; import envoy.event.contact.ContactOperation; import envoy.util.EnvoyLog; @@ -127,10 +125,16 @@ public final class ChatScene { // Listen to message status changes eventBus.register(MessageStatusChange.class, e -> localDB.getMessage(e.getID()).ifPresent(message -> { message.setStatus(e.get()); - // Update UI if in current chat if (currentChat != null && message.getSenderID() == currentChat.getRecipient().getID()) Platform.runLater(messageList::refresh); })); + + eventBus.register(GroupMessageStatusChange.class, e -> localDB.getMessage(e.getID()).ifPresent(groupMessage -> { + ((GroupMessage) groupMessage).getMemberStatuses().replace(e.getMemberID(), e.get()); + + // Update UI id in current chat + if (currentChat != null && groupMessage.getRecipientID() == currentChat.getRecipient().getID()) Platform.runLater(messageList::refresh); + })); // Listen to user status changes eventBus.register(UserStatusChange.class, diff --git a/src/main/java/envoy/client/ui/controller/LoginScene.java b/src/main/java/envoy/client/ui/controller/LoginScene.java index 95350c7..f3dec05 100644 --- a/src/main/java/envoy/client/ui/controller/LoginScene.java +++ b/src/main/java/envoy/client/ui/controller/LoginScene.java @@ -17,9 +17,7 @@ import envoy.client.ui.SceneContext; import envoy.client.ui.Startup; import envoy.data.*; import envoy.data.User.UserStatus; -import envoy.event.EventBus; -import envoy.event.HandshakeRejection; -import envoy.event.MessageStatusChange; +import envoy.event.*; import envoy.exception.EnvoyException; import envoy.util.Bounds; import envoy.util.EnvoyLog; @@ -58,6 +56,7 @@ public final class LoginScene { private Cache receivedMessageCache; private Cache receivedGroupMessageCache; private Cache receivedMessageStatusChangeCache; + private Cache receivedGroupMessageStatusChangeCache; private SceneContext sceneContext; private static final Logger logger = EnvoyLog.getLogger(LoginScene.class); @@ -93,12 +92,14 @@ public final class LoginScene { * @since Envoy Client v0.1-beta */ public void initializeData(Client client, LocalDB localDB, Cache receivedMessageCache, Cache receivedGroupMessageCache, - Cache receivedMessageStatusChangeCache, SceneContext sceneContext) { + Cache receivedMessageStatusChangeCache, Cache receivedGroupMessageStatusChangeCache, + SceneContext sceneContext) { this.client = client; this.localDB = localDB; this.receivedMessageCache = receivedMessageCache; this.receivedGroupMessageCache = receivedGroupMessageCache; this.receivedMessageStatusChangeCache = receivedMessageStatusChangeCache; + this.receivedGroupMessageStatusChangeCache = receivedGroupMessageStatusChangeCache; this.sceneContext = sceneContext; // Prepare handshake @@ -147,9 +148,17 @@ public final class LoginScene { private void performHandshake(LoginCredentials credentials) { try { - client.performHandshake(credentials, receivedMessageCache, receivedGroupMessageCache, receivedMessageStatusChangeCache); + client.performHandshake(credentials, + receivedMessageCache, + receivedGroupMessageCache, + receivedMessageStatusChangeCache, + receivedGroupMessageStatusChangeCache); if (client.isOnline()) { - client.initReceiver(localDB, receivedMessageCache, receivedGroupMessageCache, receivedMessageStatusChangeCache); + client.initReceiver(localDB, + receivedMessageCache, + receivedGroupMessageCache, + receivedMessageStatusChangeCache, + receivedGroupMessageStatusChangeCache); loadChatScene(); } } catch (IOException | InterruptedException | TimeoutException e) { @@ -216,5 +225,6 @@ public final class LoginScene { if (receivedMessageCache != null && client.isOnline()) receivedMessageCache.relay(); if (receivedGroupMessageCache != null && client.isOnline()) receivedGroupMessageCache.relay(); if (receivedMessageStatusChangeCache != null && client.isOnline()) receivedMessageStatusChangeCache.relay(); + if (receivedGroupMessageStatusChangeCache != null && client.isOnline()) receivedGroupMessageStatusChangeCache.relay(); } } From c5ab36d5ea89e34fe289108a1eadada6fff2af69 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sun, 5 Jul 2020 13:28:17 +0200 Subject: [PATCH 6/9] Fixed bug regarding adding new Message to wrong chats --- src/main/java/envoy/client/ui/controller/ChatScene.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index 0705b0f..d89a28c 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -102,7 +102,7 @@ public final class ChatScene implements Restorable { // Listen to received messages eventBus.register(MessageCreationEvent.class, e -> { final var message = e.get(); - localDB.getChat(message instanceof GroupMessage ? message.getSenderID() : message.getRecipientID()).ifPresent(chat -> { + localDB.getChat(message instanceof GroupMessage ? message.getRecipientID() : message.getSenderID()).ifPresent(chat -> { chat.insert(message); if (chat.equals(currentChat)) { try { From 85e7f288395d07b3b8c0a71ff86560f5009640ba Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sun, 5 Jul 2020 13:53:00 +0200 Subject: [PATCH 7/9] Fixed display type of messages in all chats --- src/main/java/envoy/client/ui/listcell/MessageControl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/envoy/client/ui/listcell/MessageControl.java b/src/main/java/envoy/client/ui/listcell/MessageControl.java index d68acdd..a2632e8 100644 --- a/src/main/java/envoy/client/ui/listcell/MessageControl.java +++ b/src/main/java/envoy/client/ui/listcell/MessageControl.java @@ -42,12 +42,14 @@ public class MessageControl extends VBox { textLabel.setWrapText(true); getChildren().add(textLabel); // Setting the message status icon and background color - if (message.getRecipientID() != client.getID()) { + if (message.getSenderID() == client.getID()) { final var statusIcon = new ImageView(statusImages.get(message.getStatus())); statusIcon.setPreserveRatio(true); getChildren().add(statusIcon); getStyleClass().add("own-message"); - } else getStyleClass().add("received-message"); + } else { + getStyleClass().add("received-message"); + } // Adjusting height and weight of the cell to the corresponding ListView paddingProperty().setValue(new Insets(5, 20, 5, 20)); } From dd8e88d28cb5d49789c5e234e4f9578590331771 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sun, 5 Jul 2020 14:38:19 +0200 Subject: [PATCH 8/9] Implemented GroupChat as subclass of Chat and adjusted calls of such --- src/main/java/envoy/client/data/Chat.java | 34 +++---------- .../java/envoy/client/data/GroupChat.java | 51 +++++++++++++++++++ src/main/java/envoy/client/data/LocalDB.java | 6 ++- .../envoy/client/ui/controller/ChatScene.java | 6 +-- 4 files changed, 66 insertions(+), 31 deletions(-) create mode 100644 src/main/java/envoy/client/data/GroupChat.java diff --git a/src/main/java/envoy/client/data/Chat.java b/src/main/java/envoy/client/data/Chat.java index 318cf24..739d335 100644 --- a/src/main/java/envoy/client/data/Chat.java +++ b/src/main/java/envoy/client/data/Chat.java @@ -2,7 +2,6 @@ package envoy.client.data; import java.io.IOException; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -10,7 +9,6 @@ import java.util.Objects; import envoy.client.net.WriteProxy; import envoy.data.*; import envoy.data.Message.MessageStatus; -import envoy.event.GroupMessageStatusChange; import envoy.event.MessageStatusChange; /** @@ -26,11 +24,10 @@ import envoy.event.MessageStatusChange; * @author Kai S. K. Engelbart * @since Envoy Client v0.1-alpha */ -public final class Chat implements Serializable { +public class Chat implements Serializable { - private final Contact recipient; - private final Contact sender; - private final List messages = new ArrayList<>(); + protected final Contact recipient; + protected final List messages = new ArrayList<>(); private static final long serialVersionUID = 1L; @@ -40,13 +37,10 @@ public final class Chat implements Serializable { * Saves the Messages in the corresponding chat at that Point. * * @param recipient the user who receives the messages - * @param sender the user who is logged in as sender on this instance of - * envoy.client * @since Envoy Client v0.1-alpha */ - public Chat(Contact recipient, Contact sender) { + public Chat(Contact recipient) { this.recipient = recipient; - this.sender = sender; } @Override @@ -87,22 +81,10 @@ public final class Chat implements Serializable { public void read(WriteProxy writeProxy) throws IOException { for (int i = messages.size() - 1; i >= 0; --i) { final Message m = messages.get(i); - if(m.getClass().equals(GroupMessage.class)) { - GroupMessage g = (GroupMessage) m; - if (g.getSenderID() != sender.getID()) { - if (g.getMemberStatuses().get(sender.getID()) == MessageStatus.READ) break; - else { - g.getMemberStatuses().replace(sender.getID(), MessageStatus.READ); - writeProxy.writeMessageStatusChange( - new GroupMessageStatusChange(g.getID(), MessageStatus.READ, LocalDateTime.now(), sender.getID())); - } - } - }else { - if (m.getSenderID() == recipient.getID()) if (m.getStatus() == MessageStatus.READ) break; - else { - m.setStatus(MessageStatus.READ); - writeProxy.writeMessageStatusChange(new MessageStatusChange(m)); - } + if (m.getSenderID() == recipient.getID()) if (m.getStatus() == MessageStatus.READ) break; + else { + m.setStatus(MessageStatus.READ); + writeProxy.writeMessageStatusChange(new MessageStatusChange(m)); } } } diff --git a/src/main/java/envoy/client/data/GroupChat.java b/src/main/java/envoy/client/data/GroupChat.java new file mode 100644 index 0000000..4f29eb6 --- /dev/null +++ b/src/main/java/envoy/client/data/GroupChat.java @@ -0,0 +1,51 @@ +package envoy.client.data; + +import java.io.IOException; +import java.time.LocalDateTime; + +import envoy.client.net.WriteProxy; +import envoy.data.Contact; +import envoy.data.GroupMessage; +import envoy.data.Message.MessageStatus; +import envoy.data.User; +import envoy.event.GroupMessageStatusChange; + +/** + * Project: envoy-client
+ * File: GroupChat.java
+ * Created: 05.07.2020
+ * + * @author Maximilian Käfer + * @since Envoy Client v0.1-beta + */ +public class GroupChat extends Chat { + + private final User sender; + + private static final long serialVersionUID = 1L; + + /** + * @param sender the user sending the messages + * @param recipient the user who receives the messages + * @since Envoy Client v0.1-beta + */ + public GroupChat(User sender, Contact recipient) { + super(recipient); + this.sender = sender; + } + + @Override + public void read(WriteProxy writeProxy) throws IOException { + for (int i = messages.size() - 1; i >= 0; --i) { + final GroupMessage g = (GroupMessage) messages.get(i); + if (g.getSenderID() != sender.getID()) { + if (g.getMemberStatuses().get(sender.getID()) == MessageStatus.READ) break; + else { + g.getMemberStatuses().replace(sender.getID(), MessageStatus.READ); + writeProxy + .writeMessageStatusChange(new GroupMessageStatusChange(g.getID(), MessageStatus.READ, LocalDateTime.now(), sender.getID())); + } + } + } + } +} diff --git a/src/main/java/envoy/client/data/LocalDB.java b/src/main/java/envoy/client/data/LocalDB.java index 315b27d..7899510 100644 --- a/src/main/java/envoy/client/data/LocalDB.java +++ b/src/main/java/envoy/client/data/LocalDB.java @@ -82,7 +82,11 @@ public abstract class LocalDB { getChat(contact.getID()).ifPresent(chat -> { ((User) chat.getRecipient()).setStatus(((User) contact).getStatus()); }); // Create missing chats - user.getContacts().stream().filter(u -> !u.equals(user) && getChat(u.getID()).isEmpty()).map(u -> new Chat(u, user)).forEach(chats::add); + user.getContacts() + .stream() + .filter(c -> !c.equals(user) && getChat(c.getID()).isEmpty()) + .map(c -> c instanceof User ? new Chat(c) : new GroupChat(user, c)) + .forEach(chats::add); } /** diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index d89a28c..68449b4 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -17,9 +17,7 @@ import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.paint.Color; -import envoy.client.data.Chat; -import envoy.client.data.LocalDB; -import envoy.client.data.Settings; +import envoy.client.data.*; import envoy.client.event.MessageCreationEvent; import envoy.client.net.Client; import envoy.client.net.WriteProxy; @@ -143,7 +141,7 @@ public final class ChatScene implements Restorable { switch (e.getOperationType()) { case ADD: localDB.getUsers().put(contact.getName(), contact); - localDB.getChats().add(new Chat(contact, client.getSender())); + localDB.getChats().add(contact instanceof User ? new Chat(contact) : new GroupChat(client.getSender(), contact)); Platform.runLater(() -> userList.getItems().add(contact)); break; case REMOVE: From a8443e6a50db9ee520b6e59080e9bbbe00eb731d Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Wed, 8 Jul 2020 14:15:44 +0200 Subject: [PATCH 9/9] Applied suggestions from @delvh --- .../java/envoy/client/data/GroupChat.java | 15 ++-- src/main/java/envoy/client/net/Client.java | 88 +++++++++++-------- .../envoy/client/ui/controller/ChatScene.java | 9 +- .../client/ui/controller/LoginScene.java | 38 ++++---- 4 files changed, 88 insertions(+), 62 deletions(-) diff --git a/src/main/java/envoy/client/data/GroupChat.java b/src/main/java/envoy/client/data/GroupChat.java index 4f29eb6..3c1e98d 100644 --- a/src/main/java/envoy/client/data/GroupChat.java +++ b/src/main/java/envoy/client/data/GroupChat.java @@ -11,6 +11,9 @@ import envoy.data.User; import envoy.event.GroupMessageStatusChange; /** + * Represents a chat between a user and a group + * as a list of messages. + *

* Project: envoy-client
* File: GroupChat.java
* Created: 05.07.2020
@@ -26,7 +29,7 @@ public class GroupChat extends Chat { /** * @param sender the user sending the messages - * @param recipient the user who receives the messages + * @param recipient the group whose members receive the messages * @since Envoy Client v0.1-beta */ public GroupChat(User sender, Contact recipient) { @@ -37,13 +40,13 @@ public class GroupChat extends Chat { @Override public void read(WriteProxy writeProxy) throws IOException { for (int i = messages.size() - 1; i >= 0; --i) { - final GroupMessage g = (GroupMessage) messages.get(i); - if (g.getSenderID() != sender.getID()) { - if (g.getMemberStatuses().get(sender.getID()) == MessageStatus.READ) break; + final GroupMessage gmsg = (GroupMessage) messages.get(i); + if (gmsg.getSenderID() != sender.getID()) { + if (gmsg.getMemberStatuses().get(sender.getID()) == MessageStatus.READ) break; else { - g.getMemberStatuses().replace(sender.getID(), MessageStatus.READ); + gmsg.getMemberStatuses().replace(sender.getID(), MessageStatus.READ); writeProxy - .writeMessageStatusChange(new GroupMessageStatusChange(g.getID(), MessageStatus.READ, LocalDateTime.now(), sender.getID())); + .writeMessageStatusChange(new GroupMessageStatusChange(gmsg.getID(), MessageStatus.READ, LocalDateTime.now(), sender.getID())); } } } diff --git a/src/main/java/envoy/client/net/Client.java b/src/main/java/envoy/client/net/Client.java index fb4f114..7348abe 100644 --- a/src/main/java/envoy/client/net/Client.java +++ b/src/main/java/envoy/client/net/Client.java @@ -53,22 +53,26 @@ public class Client implements Closeable { * will block for up to 5 seconds. If the handshake does exceed this time limit, * an exception is thrown. * - * @param credentials the login credentials of the user - * @param receivedMessageCache a message cache containing all unread - * messages - * from the server that can be relayed - * after - * initialization - * @param receivedGroupMessageCache a groupMessage cache containing all - * unread - * groupMessages - * from the server that can be relayed - * after - * initialization - * @param receivedMessageStatusChangeCache an event cache containing all - * received messageStatusChangeEvents - * from the server that can be relayed - * after initialization + * @param credentials the login credentials of the + * user + * @param receivedMessageCache a message cache containing all + * unread messages from the server + * that can be relayed after + * initialization + * @param receivedGroupMessageCache a groupMessage cache containing + * all unread groupMessages from + * the server that can be relayed + * after initialization + * @param receivedMessageStatusChangeCache an event cache containing all + * received + * messageStatusChangeEvents from + * the server that can be relayed + * after initialization + * @param receivedGroupMessageStatusChangeCache an event cache containing all + * received + * groupMessageStatusChangeEvents + * from the server that can be + * relayed after initialization * @throws TimeoutException if the server could not be reached * @throws IOException if the login credentials could not be written * @throws InterruptedException if the current thread is interrupted while @@ -131,24 +135,36 @@ public class Client implements Closeable { * Initializes the {@link Receiver} used to process data sent from the server to * this client. * - * @param localDB the local database used to persist - * the current - * {@link IDGenerator} - * @param receivedMessageCache a message cache containing all unread - * messages - * from the server that can be relayed - * after - * initialization - * @param receivedGroupMessageCache a groupMessage cache containing all - * unread - * groupMessages - * from the server that can be relayed - * after - * initialization - * @param receivedMessageStatusChangeCache an event cache containing all - * received messageStatusChangeEvents - * from the server that can be relayed - * after initialization + * @param localDB the local database used to + * persist + * the current + * {@link IDGenerator} + * @param receivedMessageCache a message cache containing all + * unread + * messages + * from the server that can be + * relayed + * after + * initialization + * @param receivedGroupMessageCache a groupMessage cache containing + * all + * unread + * groupMessages + * from the server that can be + * relayed + * after + * initialization + * @param receivedMessageStatusChangeCache an event cache containing all + * received + * messageStatusChangeEvents + * from the server that can be + * relayed + * after initialization + * @param receivedGroupMessageStatusChangeCache an event cache containing all + * received + * groupMessageStatusChangeEvents + * from the server that can be + * relayed after initialization * @throws IOException if no {@link IDGenerator} is present and none could be * requested from the server * @since Envoy Client v0.2-alpha @@ -159,8 +175,8 @@ public class Client implements Closeable { checkOnline(); // Process incoming messages - final ReceivedMessageProcessor receivedMessageProcessor = new ReceivedMessageProcessor(); - final ReceivedGroupMessageProcessor receivedGroupMessageProcessor = new ReceivedGroupMessageProcessor(); + final ReceivedMessageProcessor receivedMessageProcessor = new ReceivedMessageProcessor(); + final ReceivedGroupMessageProcessor receivedGroupMessageProcessor = new ReceivedGroupMessageProcessor(); final MessageStatusChangeProcessor messageStatusChangeProcessor = new MessageStatusChangeProcessor(); final GroupMessageStatusChangeProcessor groupMessageStatusChangeProcessor = new GroupMessageStatusChangeProcessor(); diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java index ccc9380..8b05221 100644 --- a/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -29,8 +29,8 @@ import envoy.client.ui.listcell.ContactListCellFactory; import envoy.client.ui.listcell.MessageControl; import envoy.client.ui.listcell.MessageListCellFactory; import envoy.data.*; -import envoy.event.*; import envoy.data.Attachment.AttachmentType; +import envoy.event.*; import envoy.event.contact.ContactOperation; import envoy.exception.EnvoyException; import envoy.util.EnvoyLog; @@ -135,7 +135,7 @@ public final class ChatScene implements Restorable { eventBus.register(GroupMessageStatusChange.class, e -> localDB.getMessage(e.getID()).ifPresent(groupMessage -> { ((GroupMessage) groupMessage).getMemberStatuses().replace(e.getMemberID(), e.get()); - // Update UI id in current chat + // Update UI if in current chat if (currentChat != null && groupMessage.getRecipientID() == currentChat.getRecipient().getID()) Platform.runLater(messageList::refresh); })); @@ -355,9 +355,8 @@ public final class ChatScene implements Restorable { } /** - * Sends a new message or groupMessage to the server based on the text entered - * in the - * messageTextArea. + * Sends a new {@link Message} or {@link GroupMessage} to the server based on + * the text entered in the {@code messageTextArea} and the given attachment. * * @since Envoy Client v0.1-beta */ diff --git a/src/main/java/envoy/client/ui/controller/LoginScene.java b/src/main/java/envoy/client/ui/controller/LoginScene.java index c59dc4b..897cd08 100644 --- a/src/main/java/envoy/client/ui/controller/LoginScene.java +++ b/src/main/java/envoy/client/ui/controller/LoginScene.java @@ -75,21 +75,29 @@ public final class LoginScene { /** * Loads the login dialog using the FXML file {@code LoginDialog.fxml}. * - * @param client the client used to perform the - * handshake - * @param localDB the local database used for offline - * login - * @param receivedMessageCache the cache storing messages received - * during - * the handshake - * @param receivedGroupMessageCache the cache storing groupMessages - * received during the handshake - * @param receivedMessageStatusChangeCache the cache storing - * messageStatusChangeEvents received - * during handshake - * @param sceneContext the scene context used to initialize - * the chat - * scene + * @param client the client used to perform the + * handshake + * @param localDB the local database used for + * offline + * login + * @param receivedMessageCache the cache storing messages + * received + * during + * the handshake + * @param receivedGroupMessageCache the cache storing groupMessages + * received during the handshake + * @param receivedMessageStatusChangeCache the cache storing + * messageStatusChangeEvents + * received + * during handshake + * @param receivedGroupMessageStatusChangeCache the cache storing + * groupMessageStatusChangeEvents + * received + * during handshake + * @param sceneContext the scene context used to + * initialize + * the chat + * scene * @since Envoy Client v0.1-beta */ public void initializeData(Client client, LocalDB localDB, Cache receivedMessageCache, Cache receivedGroupMessageCache,