Class InternetDiscoveryChildrenHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
org.drasyl.handler.remote.internet.InternetDiscoveryChildrenHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler
Direct Known Subclasses:
TraversingInternetDiscoveryChildrenHandler

public class InternetDiscoveryChildrenHandler extends io.netty.channel.ChannelDuplexHandler
Joins one ore multiple super peer(s) as a children. Uses the super peer with the best latency as a default gateway for outbound messages.
See Also:
  • Field Details

    • myNetworkId

      protected final int myNetworkId
    • myPublicKey

      protected final IdentityPublicKey myPublicKey
    • myProofOfWork

      protected final ProofOfWork myProofOfWork
    • currentTime

      protected final LongSupplier currentTime
    • pingTimeoutMillis

      protected final long pingTimeoutMillis
    • maxTimeOffsetMillis

      protected final long maxTimeOffsetMillis
    • superPeers

      protected final Map<IdentityPublicKey,org.drasyl.handler.remote.internet.InternetDiscoveryChildrenHandler.SuperPeer> superPeers
    • pathEventFilter

      protected final DuplicatePathEventFilter pathEventFilter
  • Constructor Details

  • Method Details

    • channelActive

      public void channelActive(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelActive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
    • channelInactive

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
    • channelRead

      public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
      Specified by:
      channelRead in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
    • write

      public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)
      Specified by:
      write in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      write in class io.netty.channel.ChannelDuplexHandler
    • writeDiscoveryMessage

      protected void writeDiscoveryMessage(io.netty.channel.ChannelHandlerContext ctx, DrasylAddress publicKey, InetSocketAddress inetAddress, boolean isChildrenJoin)
      Make sure to call Channel.flush() by your own!
    • isUnexpectedMessage

      protected boolean isUnexpectedMessage(Object msg)