use of im.actor.runtime.function.Supplier in project actor-platform by actorapp.
the class UpdateProcessor method applyDifferenceUpdate.
//
// Difference
//
public Promise<Void> applyDifferenceUpdate(List<Update> updates) {
CombinedDifference combinedDifference = GetDiffCombiner.buildDiff(updates);
ArrayList<Supplier<Promise<Void>>> pending = new ArrayList<>();
pending.add(() -> messagesProcessor.onDifferenceStart());
for (Peer peer : combinedDifference.getReceived().keySet()) {
long time = combinedDifference.getReceived().get(peer);
pending.add(() -> processUpdate(new UpdateMessageReceived(buildApiPeer(peer), time, 0)));
}
for (Peer peer : combinedDifference.getRead().keySet()) {
long time = combinedDifference.getRead().get(peer);
pending.add(() -> processUpdate(new UpdateMessageRead(buildApiPeer(peer), time, 0)));
}
for (Peer peer : combinedDifference.getReadByMe().keySet()) {
CombinedDifference.ReadByMeValue time = combinedDifference.getReadByMe().get(peer);
pending.add(() -> processUpdate(new UpdateMessageReadByMe(buildApiPeer(peer), time.getDate(), time.getCounter())));
}
for (Peer peer : combinedDifference.getMessages().keySet()) {
pending.add(() -> messagesProcessor.onDifferenceMessages(buildApiPeer(peer), combinedDifference.getMessages().get(peer)));
}
for (Update u : combinedDifference.getOtherUpdates()) {
pending.add(() -> processUpdate(u));
}
pending.add(() -> messagesProcessor.onDifferenceEnd());
return Promises.traverse(pending).map(v -> null);
}
Aggregations