Listening to message status changes, sending READ status updates
This commit is contained in:
@@ -13,7 +13,9 @@ import envoy.client.Config;
|
||||
import envoy.client.database.LocalDb;
|
||||
import envoy.client.util.EnvoyLog;
|
||||
import envoy.data.*;
|
||||
import envoy.event.Event;
|
||||
import envoy.event.IdGeneratorRequest;
|
||||
import envoy.event.MessageStatusChangeEvent;
|
||||
import envoy.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@@ -42,7 +44,7 @@ public class Client implements Closeable {
|
||||
|
||||
// Configuration and logging
|
||||
private static final Config config = Config.getInstance();
|
||||
private static final Logger logger = EnvoyLog.getLogger(Client.class.getSimpleName());
|
||||
private static final Logger logger = EnvoyLog.getLogger(Client.class.getSimpleName());
|
||||
|
||||
/**
|
||||
* Enters the online mode by acquiring a user ID from the server. As a
|
||||
@@ -103,19 +105,21 @@ public class Client implements Closeable {
|
||||
// Relay cached unread messages
|
||||
cache.setProcessor(receivedMessageProcessor);
|
||||
|
||||
// TODO: Status handling
|
||||
// Process message status changes
|
||||
receiver.registerProcessor(MessageStatusChangeEvent.class, new MessageStatusChangeEventProcessor());
|
||||
|
||||
// Process message ID generation
|
||||
receiver.registerProcessor(IdGenerator.class, localDb::setIdGenerator);
|
||||
|
||||
// Request a generator if none is present
|
||||
// Request a generator if none is present or the existing one is consumed
|
||||
if (!localDb.hasIdGenerator() || !localDb.getIdGenerator().hasNext()) requestIdGenerator();
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to the server.
|
||||
* Sends a message to the server. The message's status will be incremented once
|
||||
* it was delivered successfully.
|
||||
*
|
||||
* @param message the message to send
|
||||
* @throws IOException if the message does not reach the server
|
||||
@@ -126,6 +130,14 @@ public class Client implements Closeable {
|
||||
message.nextStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an event to the server.
|
||||
*
|
||||
* @param evt the event to send
|
||||
* @throws IOException if the event did not reach the server
|
||||
*/
|
||||
public void sendEvent(Event<?> evt) throws IOException { writeObject(evt); }
|
||||
|
||||
/**
|
||||
* Requests a new {@link IdGenerator} from the server.
|
||||
*
|
||||
|
Reference in New Issue
Block a user