Skip to content
Snippets Groups Projects
Commit 1a4210e9 authored by Alexis Durgnat's avatar Alexis Durgnat :milky_way:
Browse files

Comments

parent 176d9559
No related branches found
No related tags found
1 merge request!21*poof* final version
......@@ -16,6 +16,12 @@ public class MessageManager extends MessageQueue {
/*
* Private functions
*/
/**
* Send an event to the queue
* @param type The type of the message
* @param event The event
*/
private <T extends Serializable> void sendEvent(Message.Type type, T event) {
Message m = new Message(type, event);
try {
......@@ -25,6 +31,11 @@ public class MessageManager extends MessageQueue {
}
}
/**
* Add a consumer for a specific type of message
* @param type The type of the message
* @param eventHandler Consumer to add
*/
private <T extends Serializable> void conditionalSubscribe(Message.Type type, Consumer<T> eventHandler,
Predicate<T> condition) {
Consumer<byte[]> consumer = (bytes) -> {
......@@ -42,6 +53,11 @@ public class MessageManager extends MessageQueue {
/*
* Public functions
*/
/**
* Subscribe to all JoinedJourney events
* @param eventHandler Journey consumer
*/
public void subscribeJoinedJourney(Consumer<JoinedJourney> eventHandler) {
this.conditionalSubscribeJoinedJourney(eventHandler, (event) -> true);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment