Prepare handshake synchronization
Common * Replace LocalDateTime with Instant everywhere Client * Display message creation date with system time zone in MessageControl * LocalDB#users now strictly contains Users * lastSync time stamp in LocalDB (saved per user) * isOnline parameter in save function (lastSync updated if true) * lastSync time stamp in LoginCredentials * No ClientConfig#getLoginCredentials because of missing information, moved to LoginScene * Pass LocalDB#lastSync to LoginCredentials in LoginScene Server * Explicit lastSync parameter for PersistenceManager#getPending(Group)Messages This sends the correct time stamp to the server, however the JPQL queries have yet to be adjusted.
This commit is contained in:
@ -4,7 +4,7 @@ import static envoy.data.Message.MessageStatus.*;
|
||||
import static envoy.data.User.UserStatus.ONLINE;
|
||||
import static envoy.event.HandshakeRejection.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Instant;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -47,7 +47,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
||||
@Override
|
||||
public void process(LoginCredentials credentials, long socketID, ObjectWriteProxy writeProxy) {
|
||||
|
||||
// Cache this write proxy for user-independant notifications
|
||||
// Cache this write proxy for user-independent notifications
|
||||
UserStatusChangeProcessor.setWriteProxy(writeProxy);
|
||||
|
||||
if (!VersionUtil.verifyCompatibility(credentials.getClientVersion())) {
|
||||
@ -98,7 +98,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
||||
// Creation of a new user
|
||||
user = new User();
|
||||
user.setName(credentials.getIdentifier());
|
||||
user.setLastSeen(LocalDateTime.now());
|
||||
user.setLastSeen(Instant.now());
|
||||
user.setStatus(ONLINE);
|
||||
user.setPasswordHash(PasswordUtil.hash(credentials.getPassword()));
|
||||
user.setContacts(new HashSet<>());
|
||||
@ -117,7 +117,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
||||
// Complete the handshake
|
||||
writeProxy.write(socketID, user.toCommon());
|
||||
|
||||
final var pendingMessages = PersistenceManager.getInstance().getPendingMessages(user);
|
||||
final var pendingMessages = PersistenceManager.getInstance().getPendingMessages(user, credentials.getLastSync());
|
||||
pendingMessages.removeIf(GroupMessage.class::isInstance);
|
||||
logger.fine("Sending " + pendingMessages.size() + " pending messages to " + user + "...");
|
||||
|
||||
@ -138,7 +138,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
||||
} else writeProxy.write(socketID, new MessageStatusChange(msgCommon));
|
||||
}
|
||||
|
||||
List<GroupMessage> pendingGroupMessages = PersistenceManager.getInstance().getPendingGroupMessages(user);
|
||||
List<GroupMessage> pendingGroupMessages = PersistenceManager.getInstance().getPendingGroupMessages(user, credentials.getLastSync());
|
||||
logger.fine("Sending " + pendingGroupMessages.size() + " pending group messages to " + user + "...");
|
||||
|
||||
for (var gmsg : pendingGroupMessages) {
|
||||
@ -148,13 +148,13 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
||||
if (gmsg.getMemberMessageStatus().get(user.getID()) == SENT) {
|
||||
gmsg.getMemberMessageStatus().replace(user.getID(), RECEIVED);
|
||||
|
||||
gmsg.setLastStatusChangeDate(LocalDateTime.now());
|
||||
gmsg.setLastStatusChangeDate(Instant.now());
|
||||
|
||||
writeProxy.write(socketID, gmsgCommon);
|
||||
|
||||
// Notify all online group members about the status change
|
||||
writeProxy.writeToOnlineContacts(gmsg.getRecipient().getContacts(),
|
||||
new GroupMessageStatusChange(gmsg.getID(), RECEIVED, LocalDateTime
|
||||
new GroupMessageStatusChange(gmsg.getID(), RECEIVED, Instant
|
||||
.now(),
|
||||
connectionManager.getUserIDBySocketID(socketID)));
|
||||
|
||||
@ -163,7 +163,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
||||
|
||||
// Notify online members about the status change
|
||||
writeProxy.writeToOnlineContacts(gmsg.getRecipient().getContacts(),
|
||||
new MessageStatusChange(gmsg.getID(), gmsg.getStatus(), LocalDateTime.now()));
|
||||
new MessageStatusChange(gmsg.getID(), gmsg.getStatus(), Instant.now()));
|
||||
}
|
||||
|
||||
PersistenceManager.getInstance().updateMessage(gmsg);
|
||||
|
Reference in New Issue
Block a user