Package org.drasyl.pipeline.codec
Class Codec<E,D,A extends Address>
java.lang.Object
org.drasyl.pipeline.HandlerAdapter
org.drasyl.pipeline.AddressHandlerAdapter<A>
org.drasyl.pipeline.SimpleInboundHandler<I,E,A>
org.drasyl.pipeline.SimpleDuplexHandler<E,Event,D,A>
org.drasyl.pipeline.codec.Codec<E,D,A>
- All Implemented Interfaces:
Handler
- Direct Known Subclasses:
DefaultCodec
Standard interface for all codecs of the
A codec can be used to encode/decode a given set of objects into the correct format to process the object in the ongoing steps.
A codec must have a symmetrical construction.
Pipeline
.
A codec can be used to encode/decode a given set of objects into the correct format to process the object in the ongoing steps.
A codec must have a symmetrical construction.
encode(HandlerContext, Object, Consumer)
converts an object of type D into type E and decode(HandlerContext, Object, Consumer)
vice versa.
Note: You can use the HandlerContext.inboundValidator()
} or HandlerContext.outboundValidator()
} to check if a given
Class
is allowed to be encode/decode.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
matchedEventTriggered
(HandlerContext ctx, Event event, CompletableFuture<Void> future) Is called for each event of typeSimpleInboundHandler
.protected void
matchedRead
(HandlerContext ctx, A sender, E msg, CompletableFuture<Void> future) Is called for each message of typeSimpleInboundHandler
.protected void
matchedWrite
(HandlerContext ctx, A recipient, D msg, CompletableFuture<Void> future) Is called for each message of typeSimpleDuplexHandler
.Methods inherited from class org.drasyl.pipeline.SimpleDuplexHandler
acceptOutbound, write
Methods inherited from class org.drasyl.pipeline.SimpleInboundHandler
acceptEvent, acceptInbound, eventTriggered, read
Methods inherited from class org.drasyl.pipeline.AddressHandlerAdapter
acceptAddress
Methods inherited from class org.drasyl.pipeline.HandlerAdapter
exceptionCaught, handlerAdded, handlerRemoved
-
Constructor Details
-
Codec
public Codec()
-
-
Method Details
-
matchedEventTriggered
protected void matchedEventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future) Description copied from class:SimpleInboundHandler
Is called for each event of typeSimpleInboundHandler
.- Specified by:
matchedEventTriggered
in classSimpleInboundHandler<E,
Event, A extends Address> - Parameters:
ctx
- handler contextevent
- the eventfuture
- the future of the message
-
matchedRead
Description copied from class:SimpleInboundHandler
Is called for each message of typeSimpleInboundHandler
.- Specified by:
matchedRead
in classSimpleInboundHandler<E,
Event, A extends Address> - Parameters:
ctx
- handler contextsender
- the sender of the messagemsg
- the messagefuture
- the future of the message
-
matchedWrite
Description copied from class:SimpleDuplexHandler
Is called for each message of typeSimpleDuplexHandler
.- Specified by:
matchedWrite
in classSimpleDuplexHandler<E,
Event, D, A extends Address> - Parameters:
ctx
- handler contextrecipient
- the recipient of the messagemsg
- the messagefuture
- a future for the message
-