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 theUdpMulticastServer
orUdpBroadcastServer
, is used to discover other nodes on the local network via IP multicast or broadcast.For this purpose, the above-mentioned server forwards received multicast/broadcast
HelloMessage
s to this handler, which thus becomes aware of other nodes in the local network. In case noHelloMessage
has been received for a longer period of time, the other node is considered stale.In addition, this handler periodically sends a
HelloMessage
messages to a given multicast/broadcast address so that other nodes become aware of this node.- See Also:
UdpMulticastServer
,UdpBroadcastServer
-
-
Constructor Summary
Constructors Constructor Description LocalNetworkDiscovery(int networkId, long pingIntervalMillis, long pingTimeoutMillis, IdentityPublicKey myPublicKey, ProofOfWork myProofOfWork, InetSocketAddress recipient)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
-
-
-
-
Constructor Detail
-
LocalNetworkDiscovery
public LocalNetworkDiscovery(int networkId, long pingIntervalMillis, long pingTimeoutMillis, IdentityPublicKey myPublicKey, ProofOfWork myProofOfWork, InetSocketAddress recipient)
-
-
Method Detail
-
channelRead
public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
- 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
-
-