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.
This commit is contained in:
parent
43dfdc3334
commit
81d4e26cc6
@ -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: <strong>envoy-client</strong><br>
|
||||
@ -20,17 +17,12 @@ import envoy.util.EnvoyLog;
|
||||
*/
|
||||
public class ReceivedMessageProcessor implements Consumer<Message> {
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -110,10 +110,6 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
||||
logger.info(user + " successfully authenticated.");
|
||||
connectionManager.registerUser(user.getID(), socketID);
|
||||
|
||||
// Change status and notify contacts about it
|
||||
user.setStatus(ONLINE);
|
||||
UserStatusChangeProcessor.updateUserStatus(user);
|
||||
|
||||
// Complete the handshake
|
||||
writeProxy.write(socketID, user.toCommon());
|
||||
|
||||
@ -190,6 +186,10 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
|
||||
writeProxy.write(socketID, new MessageStatusChange(gmsgCommon));
|
||||
}
|
||||
}
|
||||
|
||||
// Change status and notify contacts about it
|
||||
user.setStatus(ONLINE);
|
||||
UserStatusChangeProcessor.updateUserStatus(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user