Package org.drasyl.pipeline
Class SimpleDuplexHandler<I,E,O>
- java.lang.Object
-
- org.drasyl.pipeline.HandlerAdapter
-
- org.drasyl.pipeline.SimpleInboundHandler<I,E>
-
- org.drasyl.pipeline.SimpleDuplexHandler<I,E,O>
-
- All Implemented Interfaces:
Handler
- Direct Known Subclasses:
Codec
public abstract class SimpleDuplexHandler<I,E,O> extends SimpleInboundHandler<I,E>
HandlerAdapter
which allows to explicit only handle a specific type of messages and events.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleDuplexHandler()
protected
SimpleDuplexHandler(Class<? extends I> inboundMessageType, Class<? extends E> inboundEventType, Class<? extends O> outboundMessageType)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
acceptOutbound(Object msg)
Returnstrue
if the given message should be handled.protected abstract void
matchedWrite(HandlerContext ctx, CompressedPublicKey recipient, O msg, CompletableFuture<Void> future)
Is called for each message of typeSimpleDuplexHandler
.void
write(HandlerContext ctx, CompressedPublicKey recipient, Object msg, CompletableFuture<Void> future)
Gets called if aObject
was send from the application to a recipient.-
Methods inherited from class org.drasyl.pipeline.SimpleInboundHandler
acceptEvent, acceptInbound, eventTriggered, matchedEventTriggered, matchedRead, read
-
Methods inherited from class org.drasyl.pipeline.HandlerAdapter
exceptionCaught, handlerAdded, handlerRemoved
-
-
-
-
Method Detail
-
write
public void write(HandlerContext ctx, CompressedPublicKey recipient, Object msg, CompletableFuture<Void> future)
Description copied from interface:Handler
Gets called if aObject
was send from the application to a recipient.- Specified by:
write
in interfaceHandler
- Overrides:
write
in classHandlerAdapter
- Parameters:
ctx
- handler contextrecipient
- the recipient of the messagemsg
- the messagefuture
- a future for the message
-
acceptOutbound
protected boolean acceptOutbound(Object msg)
-
matchedWrite
protected abstract void matchedWrite(HandlerContext ctx, CompressedPublicKey recipient, O msg, CompletableFuture<Void> future)
Is called for each message of typeSimpleDuplexHandler
.- Parameters:
ctx
- handler contextrecipient
- the recipient of the messagemsg
- the messagefuture
- a future for the message
-
-