Package org.drasyl.pipeline.skeleton
Class SimpleInboundHandler<I,A extends Address>
- java.lang.Object
-
- org.drasyl.pipeline.skeleton.HandlerAdapter
-
- org.drasyl.pipeline.skeleton.AddressHandlerAdapter<A>
-
- org.drasyl.pipeline.skeleton.SimpleInboundEventAwareHandler<I,Event,A>
-
- org.drasyl.pipeline.skeleton.SimpleInboundHandler<I,A>
-
- All Implemented Interfaces:
Handler
- Direct Known Subclasses:
ByteBuf2MessageHandler
,InboundMessageGuard
,InvalidProofOfWorkFilter
,OtherNetworkFilter
,PortMapper
public abstract class SimpleInboundHandler<I,A extends Address> extends SimpleInboundEventAwareHandler<I,Event,A>
HandlerAdapter
which allows to explicit only handle a specific type of inbound messages.For example here is an implementation which only handle inbound
MyMessage
messages.public class MessageEventHandler extends
SimpleInboundHandler
<MyMessage
,CompressedPublicKey
> {@Override
protected void matchedRead(HandlerContext
ctx,CompressedPublicKey
sender,MyMessage
msg,CompletableFuture
<Void
> future) { System.out.println(msg); } }
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleInboundHandler()
protected
SimpleInboundHandler(Class<? extends I> inboundMessageType, Class<? extends A> addressType)
Create a new instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
eventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Gets called if aEvent
was emitted.protected void
matchedEventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Is called for each event of typeSimpleInboundEventAwareHandler
.-
Methods inherited from class org.drasyl.pipeline.skeleton.SimpleInboundEventAwareHandler
acceptEvent, acceptInbound, matchedRead, read
-
Methods inherited from class org.drasyl.pipeline.skeleton.AddressHandlerAdapter
acceptAddress
-
Methods inherited from class org.drasyl.pipeline.skeleton.HandlerAdapter
exceptionCaught, handlerAdded, handlerRemoved, write
-
-
-
-
Method Detail
-
eventTriggered
@Skip public void eventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Description copied from interface:Handler
Gets called if aEvent
was emitted.- Specified by:
eventTriggered
in interfaceHandler
- Overrides:
eventTriggered
in classSimpleInboundEventAwareHandler<I,Event,A extends Address>
- Parameters:
ctx
- handler contextevent
- the eventfuture
- a future for the message
-
matchedEventTriggered
protected void matchedEventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Description copied from class:SimpleInboundEventAwareHandler
Is called for each event of typeSimpleInboundEventAwareHandler
.- Specified by:
matchedEventTriggered
in classSimpleInboundEventAwareHandler<I,Event,A extends Address>
- Parameters:
ctx
- handler contextevent
- the eventfuture
- the future of the message
-
-