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 CyB3RC0nN0R
parent 47e03dc4f4
commit 693ef0875d

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));