Package org.drasyl.pipeline
Class SimpleInboundHandler<I,E,A extends Address>  
java.lang.Object
org.drasyl.pipeline.HandlerAdapter
org.drasyl.pipeline.AddressHandlerAdapter<A>
org.drasyl.pipeline.SimpleInboundHandler<I,E,A>  
- All Implemented Interfaces:
 Handler
- Direct Known Subclasses:
 ApplicationMessage2ObjectHolderHandler,GroupsClientHandler,GroupsManagerHandler,SimpleDuplexHandler
HandlerAdapter which allows to explicit only handle a specific type of messages and
 events.
 
 For example here is an implementation which only handle MessageEvent events.
 
     public class MessageEventHandler extends
             SimpleInboundHandler<ApplicationMessage, MessageEvent,
             CompressedPublicKey> {
        @Override
         protected void matchedEventTriggered(HandlerContext ctx,
             MessageEvent event) {
             System.out.println(event);
         }
        @Override
         protected void matchedRead(HandlerContext ctx,
             CompressedPublicKey sender, ApplicationMessage msg,
             CompletableFuture<Void> future) {
             System.out.println(msg);
         }
     }
 - 
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreate a new instance which will try to detect the types to match out of the type parameter of the class.protectedSimpleInboundHandler(Class<? extends I> inboundMessageType, Class<? extends E> inboundEventType, Class<? extends A> addressType) Create a new instance - 
Method Summary
Modifier and TypeMethodDescriptionprotected booleanacceptEvent(Event msg) Returnstrueif the given event should be handled.protected booleanacceptInbound(Object msg) Returnstrueif the given message should be handled.voideventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future) Gets called if aEventwas emitted.protected abstract voidmatchedEventTriggered(HandlerContext ctx, E event, CompletableFuture<Void> future) Is called for each event of typeSimpleInboundHandler.protected abstract voidmatchedRead(HandlerContext ctx, A sender, I msg, CompletableFuture<Void> future) Is called for each message of typeSimpleInboundHandler.voidread(HandlerContext ctx, Address sender, Object msg, CompletableFuture<Void> future) Gets called if aObjectwas received.Methods inherited from class org.drasyl.pipeline.AddressHandlerAdapter
acceptAddressMethods inherited from class org.drasyl.pipeline.HandlerAdapter
exceptionCaught, handlerAdded, handlerRemoved, write 
- 
Constructor Details
- 
SimpleInboundHandler
protected SimpleInboundHandler()Create a new instance which will try to detect the types to match out of the type parameter of the class. - 
SimpleInboundHandler
protected SimpleInboundHandler(Class<? extends I> inboundMessageType, Class<? extends E> inboundEventType, Class<? extends A> addressType) Create a new instance- Parameters:
 inboundMessageType- the type of messages to matchinboundEventType- the type of events to matchaddressType- the type of the address to match
 
 - 
 - 
Method Details
- 
read
Description copied from interface:HandlerGets called if aObjectwas received.- Specified by:
 readin interfaceHandler- Overrides:
 readin classHandlerAdapter- Parameters:
 ctx- handler contextsender- the sender of the messagemsg- the messagefuture- a future for the message
 - 
eventTriggered
Description copied from interface:HandlerGets called if aEventwas emitted.- Specified by:
 eventTriggeredin interfaceHandler- Overrides:
 eventTriggeredin classHandlerAdapter- Parameters:
 ctx- handler contextevent- the eventfuture- a future for the message
 - 
acceptEvent
 - 
matchedEventTriggered
protected abstract void matchedEventTriggered(HandlerContext ctx, E event, CompletableFuture<Void> future) Is called for each event of typeSimpleInboundHandler.- Parameters:
 ctx- handler contextevent- the eventfuture- the future of the message
 - 
acceptInbound
 - 
matchedRead
protected abstract void matchedRead(HandlerContext ctx, A sender, I msg, CompletableFuture<Void> future) Is called for each message of typeSimpleInboundHandler.- Parameters:
 ctx- handler contextsender- the sender of the messagemsg- the messagefuture- the future of the message
 
 -