Class RelayableMessageGuard
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
org.drasyl.peer.connection.handler.SimpleChannelOutboundHandler<Message>
org.drasyl.peer.connection.handler.RelayableMessageGuard
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelOutboundHandler
This handler ensures that
Message
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.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
channelWrite0
(io.netty.channel.ChannelHandlerContext ctx, Message 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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
exceptionCaught, handlerAdded, handlerRemoved
-
Field Details
-
HOP_COUNT_GUARD
- See Also:
-
-
Constructor Details
-
RelayableMessageGuard
public RelayableMessageGuard(short messageHopLimit)
-
-
Method Details
-
channelWrite0
protected void channelWrite0(io.netty.channel.ChannelHandlerContext ctx, Message 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<Message>
- Parameters:
ctx
- theChannelHandlerContext
which thisSimpleChannelDuplexHandler
belongs tomsg
- the message to handlepromise
- the corresponding promise
-