Class ConnectionChannelInitializer

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelInitializer<DrasylChannel>
org.drasyl.channel.ConnectionChannelInitializer
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

@UnstableApi public abstract class ConnectionChannelInitializer extends io.netty.channel.ChannelInitializer<DrasylChannel>
This ChannelInitializer create a channel providing reliable and ordered delivery of bytes between hosts. Handlers can either be added to the pipeline on channel creation time using initChannel(DrasylChannel) or after connection with the remote peer has been established using handshakeCompleted(ChannelHandlerContext). handshakeFailed(ChannelHandlerContext, Throwable) is called, when no connection could be established (e.g., because the other party has not responded within the time limit or has rejected the handshake).
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final ConnectionConfig
     
    static final int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    handshakeCompleted(io.netty.channel.ChannelHandlerContext ctx)
     
    protected abstract void
    handshakeFailed(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
     
    protected void
     

    Methods inherited from class io.netty.channel.ChannelInitializer

    channelRegistered, exceptionCaught, handlerAdded, handlerRemoved

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ConnectionChannelInitializer

      protected ConnectionChannelInitializer(Boolean doServer, int port, ConnectionConfig config)
      Parameters:
      doServer - Determines the server behavior:
      • true sets this channel to server mode, listening on the specified port.
      • false sets this channel to client mode, listening on a random port while assuming the peer listens on port.
      • null decides the server/client role based on comparing local and remote public keys, with the "higher" key indicating a server.
      port - Specifies the port number. In server mode, the channel listens on this port. In client mode, the channel assumes the peer listens on this port.
      config - Configuration settings for connections.
    • ConnectionChannelInitializer

      protected ConnectionChannelInitializer(Boolean doServer, int port)
      Parameters:
      doServer - Determines the server behavior:
      • true sets this channel to server mode, listening on the specified port.
      • false sets this channel to client mode, listening on a random port while assuming the peer listens on port.
      • null decides the server/client role based on comparing local and remote public keys, with the "higher" key indicating a server.
      port - Specifies the port number. In server mode, the channel listens on this port. In client mode, the channel assumes the peer listens on this port.
  • Method Details

    • initChannel

      protected void initChannel(DrasylChannel ch) throws Exception
      Specified by:
      initChannel in class io.netty.channel.ChannelInitializer<DrasylChannel>
      Throws:
      Exception
    • handshakeCompleted

      protected abstract void handshakeCompleted(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Throws:
      Exception
    • handshakeFailed

      protected abstract void handshakeFailed(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)