From 75dc563a07826fa3ffe70d7b4109704959690bae Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Fri, 3 Jul 2020 17:46:37 +0200 Subject: [PATCH] Implemented sending RECEIVED GroupMessageStatusChanges If a member logs in and receives pending groupMessages, there are now groupMessageStatusChanges sent to all other members, that are online and have already received the groupMessage. --- .../processors/LoginCredentialProcessor.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/envoy/server/processors/LoginCredentialProcessor.java b/src/main/java/envoy/server/processors/LoginCredentialProcessor.java index 86ccdfb..b562950 100755 --- a/src/main/java/envoy/server/processors/LoginCredentialProcessor.java +++ b/src/main/java/envoy/server/processors/LoginCredentialProcessor.java @@ -19,6 +19,7 @@ import javax.persistence.NoResultException; import enovy.server.util.VersionUtils; import envoy.data.LoginCredentials; import envoy.data.Message.MessageStatus; +import envoy.event.GroupMessageStatusChange; import envoy.event.HandshakeRejection; import envoy.event.MessageStatusChange; import envoy.server.data.GroupMessage; @@ -149,7 +150,22 @@ public final class LoginCredentialProcessor implements ObjectProcessor (gmsg.getMemberMessageStatus().get(k) == MessageStatus.RECEIVED + || gmsg.getMemberMessageStatus().get(k) == MessageStatus.READ) && connectionManager.getUserIdBySocketID(socketID) != k) + .forEach(k -> { + if (connectionManager.isOnline(k)) try { + writeProxy.write(connectionManager.getSocketID(k), + (new GroupMessageStatusChange(gmsg.getID(), MessageStatus.RECEIVED, LocalDateTime.now(), + connectionManager.getUserIdBySocketID(socketID)))); + } catch (IOException e) { + // TODO Maybe Try Catch block is not necessarily needed but if so write proper + // logger statement here. + e.printStackTrace(); + } + }); if (!gmsg.getMemberMessageStatus().containsValue(MessageStatus.SENT)) { gmsg.received(); // Sending MessageStatusChangeEvent to all other members