Class RelayableMessageGuard
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelOutboundHandlerAdapter
-
- org.drasyl.peer.connection.handler.SimpleChannelOutboundHandler<RelayableMessage>
-
- org.drasyl.peer.connection.handler.RelayableMessageGuard
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelOutboundHandler
public class RelayableMessageGuard extends SimpleChannelOutboundHandler<RelayableMessage>
This handler ensures thatRelayableMessage
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
-
Constructor Summary
Constructors Constructor Description RelayableMessageGuard(short messageHopLimit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
channelWrite0(io.netty.channel.ChannelHandlerContext ctx, RelayableMessage msg, io.netty.channel.ChannelPromise promise)
Is called for each message of typeSimpleChannelOutboundHandler
on the outbound channel.-
Methods inherited from class org.drasyl.peer.connection.handler.SimpleChannelOutboundHandler
acceptOutboundMessage, write
-
Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, read
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Field Detail
-
HOP_COUNT_GUARD
public static final String HOP_COUNT_GUARD
- See Also:
- Constant Field Values
-
-
Method Detail
-
channelWrite0
protected void channelWrite0(io.netty.channel.ChannelHandlerContext ctx, RelayableMessage msg, io.netty.channel.ChannelPromise promise)
Description copied from class:SimpleChannelOutboundHandler
Is called for each message of typeSimpleChannelOutboundHandler
on the outbound channel.- Specified by:
channelWrite0
in classSimpleChannelOutboundHandler<RelayableMessage>
- Parameters:
ctx
- theChannelHandlerContext
which thisSimpleChannelDuplexHandler
belongs tomsg
- the message to handlepromise
- the corresponding promise
-
-