Package org.drasyl.handler.remote
Class LocalNetworkDiscovery
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
org.drasyl.handler.remote.LocalNetworkDiscovery
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
,io.netty.channel.ChannelOutboundHandler
public class LocalNetworkDiscovery
extends io.netty.channel.ChannelDuplexHandler
This handler, along with the
UdpMulticastServer
, is used to discover other nodes on the
local network.
For this purpose, the UdpMulticastServer
joins a multicast group and forwards received
DiscoveryMessage
s to this handler, which thus becomes aware of other nodes in the local
network. In case no DiscoveryMessage
has been received for a longer period of time, the
other node is considered stale.
In addition, this handler periodically sends a DiscoveryMessage
messages to a multicast
group so that other nodes become aware of this node.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Constructor Summary
ConstructorDescriptionLocalNetworkDiscovery
(int networkId, Duration pingInterval, Duration pingTimeout, IdentityPublicKey myPublicKey, ProofOfWork myProofOfWork) LocalNetworkDiscovery
(Map<DrasylAddress, org.drasyl.handler.remote.LocalNetworkDiscovery.Peer> peers, IdentityPublicKey myPublicKey, ProofOfWork myProofOfWork, Duration pingInterval, Duration pingTimeout, int networkId, io.netty.util.concurrent.Future<?> scheduledPingFuture) -
Method Summary
Modifier and TypeMethodDescriptionvoid
channelActive
(io.netty.channel.ChannelHandlerContext ctx) void
channelInactive
(io.netty.channel.ChannelHandlerContext ctx) void
channelRead
(io.netty.channel.ChannelHandlerContext ctx, Object msg) void
write
(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, read
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, 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
handlerAdded, handlerRemoved
-
Constructor Details
-
LocalNetworkDiscovery
public LocalNetworkDiscovery(Map<DrasylAddress, org.drasyl.handler.remote.LocalNetworkDiscovery.Peer> peers, IdentityPublicKey myPublicKey, ProofOfWork myProofOfWork, Duration pingInterval, Duration pingTimeout, int networkId, io.netty.util.concurrent.Future<?> scheduledPingFuture) -
LocalNetworkDiscovery
public LocalNetworkDiscovery(int networkId, Duration pingInterval, Duration pingTimeout, IdentityPublicKey myPublicKey, ProofOfWork myProofOfWork)
-
-
Method Details
-
channelRead
- Specified by:
channelRead
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelRead
in classio.netty.channel.ChannelInboundHandlerAdapter
-
write
public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) - Specified by:
write
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
write
in classio.netty.channel.ChannelDuplexHandler
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classio.netty.channel.ChannelInboundHandlerAdapter
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelInactive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelInactive
in classio.netty.channel.ChannelInboundHandlerAdapter
-