From afcf1e48a41a96f9438a06cb7d7805f0c5e61e9c Mon Sep 17 00:00:00 2001 From: kske Date: Thu, 16 Jul 2020 21:14:37 +0200 Subject: [PATCH] Remove filter from ReceivedMessageProcessor, improve handshake The user is sent after the messages to avoid receiving messages on the client while switching from handshake to normal mode. --- .../client/net/ReceivedMessageProcessor.java | 16 ++++------------ .../envoy/client/ui/controller/ChatScene.java | 4 +++- .../processors/LoginCredentialProcessor.java | 8 ++++---- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/client/src/main/java/envoy/client/net/ReceivedMessageProcessor.java b/client/src/main/java/envoy/client/net/ReceivedMessageProcessor.java index f83815c..84aa7dc 100644 --- a/client/src/main/java/envoy/client/net/ReceivedMessageProcessor.java +++ b/client/src/main/java/envoy/client/net/ReceivedMessageProcessor.java @@ -1,14 +1,11 @@ package envoy.client.net; import java.util.function.Consumer; -import java.util.logging.Level; -import java.util.logging.Logger; import envoy.client.event.MessageCreationEvent; import envoy.data.Message; import envoy.data.Message.MessageStatus; import envoy.event.EventBus; -import envoy.util.EnvoyLog; /** * Project: envoy-client
@@ -20,17 +17,12 @@ import envoy.util.EnvoyLog; */ public class ReceivedMessageProcessor implements Consumer { - private static final Logger logger = EnvoyLog.getLogger(ReceivedMessageProcessor.class); - @Override public void accept(Message message) { - if (message.getStatus() != MessageStatus.SENT) logger.log(Level.WARNING, "The message has the unexpected status " + message.getStatus()); - else { - // Update status to RECEIVED - message.nextStatus(); + // Update status to RECEIVED + if (message.getStatus() == MessageStatus.SENT) message.nextStatus(); - // Dispatch event - EventBus.getInstance().dispatch(new MessageCreationEvent(message)); - } + // Dispatch event + EventBus.getInstance().dispatch(new MessageCreationEvent(message)); } } diff --git a/client/src/main/java/envoy/client/ui/controller/ChatScene.java b/client/src/main/java/envoy/client/ui/controller/ChatScene.java index c8c9062..ef4e38f 100644 --- a/client/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/client/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -1,5 +1,7 @@ package envoy.client.ui.controller; +import static envoy.data.Message.MessageStatus.RECEIVED; + import java.awt.Toolkit; import java.awt.datatransfer.StringSelection; import java.io.ByteArrayInputStream; @@ -145,7 +147,7 @@ public final class ChatScene implements Restorable { logger.log(Level.WARNING, "Could not read current chat: ", e1); } Platform.runLater(() -> { messageList.refresh(); scrollToMessageListEnd(); }); - } else chat.incrementUnreadAmount(); + } else if (message.getRecipientID() == chat.getRecipient().getID() && message.getStatus() == RECEIVED) chat.incrementUnreadAmount(); // Moving chat with most recent unreadMessages to the top Platform.runLater(() -> { chatList.getItems().remove(chat); diff --git a/server/src/main/java/envoy/server/processors/LoginCredentialProcessor.java b/server/src/main/java/envoy/server/processors/LoginCredentialProcessor.java index f7ee34e..391dab0 100755 --- a/server/src/main/java/envoy/server/processors/LoginCredentialProcessor.java +++ b/server/src/main/java/envoy/server/processors/LoginCredentialProcessor.java @@ -110,10 +110,6 @@ public final class LoginCredentialProcessor implements ObjectProcessor