Package org.drasyl.pipeline
Class SimplexDuplexHandler<I,E,O>
- java.lang.Object
-
- org.drasyl.pipeline.HandlerAdapter
-
- org.drasyl.pipeline.InboundHandlerAdapter
-
- org.drasyl.pipeline.SimpleInboundHandler<I,E>
-
- org.drasyl.pipeline.SimplexDuplexHandler<I,E,O>
-
- All Implemented Interfaces:
Handler
,InboundHandler
,OutboundHandler
public abstract class SimplexDuplexHandler<I,E,O> extends SimpleInboundHandler<I,E> implements OutboundHandler
DuplexHandler
which allows to explicit only handle a specific type of messages and events.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimplexDuplexHandler()
protected
SimplexDuplexHandler(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(ApplicationMessage msg)
Returnstrue
if the given message should be handled.protected abstract void
matchedWrite(HandlerContext ctx, O msg, CompletableFuture<Void> future)
Is called for each message of typeSimplexDuplexHandler
.void
write(HandlerContext ctx, ApplicationMessage msg, CompletableFuture<Void> future)
Gets called if aApplicationMessage
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.InboundHandlerAdapter
exceptionCaught
-
Methods inherited from class org.drasyl.pipeline.HandlerAdapter
handlerAdded, handlerRemoved
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.drasyl.pipeline.Handler
handlerAdded, handlerRemoved
-
-
-
-
Method Detail
-
write
public void write(HandlerContext ctx, ApplicationMessage msg, CompletableFuture<Void> future)
Description copied from interface:OutboundHandler
Gets called if aApplicationMessage
was send from the application to a recipient.- Specified by:
write
in interfaceOutboundHandler
- Parameters:
ctx
- handler contextmsg
- the messagefuture
- a future for the message
-
acceptOutbound
protected boolean acceptOutbound(ApplicationMessage msg)
Returnstrue
if the given message should be handled. Iffalse
it will be passed to the nextInboundHandler
in thePipeline
.
-
matchedWrite
protected abstract void matchedWrite(HandlerContext ctx, O msg, CompletableFuture<Void> future)
Is called for each message of typeSimplexDuplexHandler
.- Parameters:
ctx
- handler contextmsg
- the messagefuture
- a future for the message
-
-