Fixed invalid MessageStatusChangeEvent sending

The sender got a messageStatusChangeEvent even if the status was still
sent from the server and couldn't process it.
The server does not send this unnecessary event even more
This commit is contained in:
DieGurke 2020-06-10 23:01:10 +02:00 committed by kske
parent 72da2d46ca
commit 4bf1fbbc59

View File

@ -6,6 +6,7 @@ import java.util.Date;
import javax.persistence.EntityExistsException;
import envoy.data.Message;
import envoy.data.Message.MessageStatus;
import envoy.event.MessageStatusChangeEvent;
import envoy.server.data.PersistenceManager;
import envoy.server.net.ConnectionManager;
@ -30,12 +31,14 @@ public class MessageProcessor implements ObjectProcessor<Message> {
ConnectionManager connectionManager = ConnectionManager.getInstance();
sendToUser(connectionManager, message, writeProxy);
// Sending a messageStatusChangeEvent to the sender
try {
writeProxy.write(socketID, new MessageStatusChangeEvent(message));
} catch (IOException e) {
System.err.println("Could not send messageStatusChangeEvent to the sender of this message with ID: " + message.getID());
e.printStackTrace();
if (message.getStatus() != MessageStatus.SENT) {
// Sending a messageStatusChangeEvent to the sender
try {
writeProxy.write(socketID, new MessageStatusChangeEvent(message));
} catch (IOException e) {
System.err.println("Could not send messageStatusChangeEvent to the sender of this message with ID: " + message.getID());
e.printStackTrace();
}
}
try {
PersistenceManager.getInstance().addMessage(new envoy.server.data.Message(message));