Fixed incorrect error handling, upgraded appearance of this processor
This commit is contained in:
parent
334b1a2bc2
commit
99ff79b022
@ -33,24 +33,20 @@ public class MessageStatusChangeProcessor implements ObjectProcessor<MessageStat
|
|||||||
@Override
|
@Override
|
||||||
public void process(MessageStatusChangeEvent input, long socketId, ObjectWriteProxy writeProxy) throws IOException {
|
public void process(MessageStatusChangeEvent input, long socketId, ObjectWriteProxy writeProxy) throws IOException {
|
||||||
try {
|
try {
|
||||||
if (!(input.get() == MessageStatus.READ))// check that no invalid MessageStatuses are sent
|
// any other status than read is not supposed to be sent to the server
|
||||||
throw new EnvoyException("Message" + input.getId() + "has an invalid status");
|
if (!(input.get() == MessageStatus.READ)) throw new EnvoyException("Message" + input.getId() + "has an invalid status");
|
||||||
|
} catch (EnvoyException e) {
|
||||||
ConnectionManager conMan = ConnectionManager.getInstance();
|
|
||||||
PersistenceManager perMan = PersistenceManager.getPersistenceManager();
|
|
||||||
envoy.server.data.Message msg = perMan.getMessageById(input.getId());
|
|
||||||
|
|
||||||
msg.setStatus(input.get());
|
|
||||||
msg.setReadDate(input.getDate());
|
|
||||||
|
|
||||||
if (conMan.isOnline(msg.getRecipient().getId())) writeProxy.write(conMan.getSocketId(msg.getRecipient().getId()), input);
|
|
||||||
|
|
||||||
perMan.updateMessage(msg);
|
|
||||||
|
|
||||||
} catch (IOException | EnvoyException e) {
|
|
||||||
if (e.getClass() == IOException.class)
|
|
||||||
System.err.println("Recipient online. Failed to send MessageStatusChangedMessageStatusChangeEvent at message" + input.getId());
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
ConnectionManager conMan = ConnectionManager.getInstance();
|
||||||
|
PersistenceManager perMan = PersistenceManager.getPersistenceManager();
|
||||||
|
|
||||||
|
envoy.server.data.Message msg = perMan.getMessageById(input.getId());
|
||||||
|
msg.setStatus(input.get());
|
||||||
|
msg.setReadDate(input.getDate());
|
||||||
|
perMan.updateMessage(msg);
|
||||||
|
|
||||||
|
if (conMan.isOnline(msg.getRecipient().getId())) writeProxy.write(conMan.getSocketId(msg.getRecipient().getId()), input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user