Package org.drasyl.remote.handler
Class HopCountGuard
- java.lang.Object
-
- org.drasyl.pipeline.skeleton.HandlerAdapter
-
- org.drasyl.pipeline.skeleton.AddressHandlerAdapter<A>
-
- org.drasyl.pipeline.skeleton.SimpleOutboundHandler<AddressedIntermediateEnvelope<com.google.protobuf.MessageLite>,Address>
-
- org.drasyl.remote.handler.HopCountGuard
-
- All Implemented Interfaces:
Handler
public final class HopCountGuard extends SimpleOutboundHandler<AddressedIntermediateEnvelope<com.google.protobuf.MessageLite>,Address>
This handler ensures thatIntermediateEnvelope
s do not infinitely circulate in the network. It increments the hop counter of each outgoing message. If the limit of hops is reached, the message is discarded. Otherwise the message can pass.
-
-
Field Summary
Fields Modifier and Type Field Description static String
HOP_COUNT_GUARD
static HopCountGuard
INSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
matchedWrite(HandlerContext ctx, Address recipient, AddressedIntermediateEnvelope<com.google.protobuf.MessageLite> msg, CompletableFuture<Void> future)
Is called for each message of typeSimpleOutboundHandler
.-
Methods inherited from class org.drasyl.pipeline.skeleton.SimpleOutboundHandler
acceptOutbound, write
-
Methods inherited from class org.drasyl.pipeline.skeleton.AddressHandlerAdapter
acceptAddress
-
Methods inherited from class org.drasyl.pipeline.skeleton.HandlerAdapter
eventTriggered, exceptionCaught, handlerAdded, handlerRemoved, read
-
-
-
-
Field Detail
-
INSTANCE
public static final HopCountGuard INSTANCE
-
HOP_COUNT_GUARD
public static final String HOP_COUNT_GUARD
- See Also:
- Constant Field Values
-
-
Method Detail
-
matchedWrite
protected void matchedWrite(HandlerContext ctx, Address recipient, AddressedIntermediateEnvelope<com.google.protobuf.MessageLite> msg, CompletableFuture<Void> future)
Description copied from class:SimpleOutboundHandler
Is called for each message of typeSimpleOutboundHandler
.- Specified by:
matchedWrite
in classSimpleOutboundHandler<AddressedIntermediateEnvelope<com.google.protobuf.MessageLite>,Address>
- Parameters:
ctx
- handler contextrecipient
- the recipient of the messagemsg
- the messagefuture
- a future for the message
-
-