Class ConnectionHandshakeHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
org.drasyl.handler.connection.ConnectionHandshakeHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

public class ConnectionHandshakeHandler extends io.netty.channel.ChannelDuplexHandler
This handler partially implements the Transmission Control Protocol know from RFC 793. Only the three-way-handshake and tear-down handshake are currently supported. Segments just contain parameters required for that operations.

The handler can be configured to perform an active or passive OPEN process.

If the handler is configured for active OPEN, a ConnectionHandshakeIssued will be emitted once the handshake has been issued. The handshake process will result either in a ConnectionHandshakeCompleted event or ConnectionHandshakeException exception.

  • 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 io.netty.util.concurrent.ScheduledFuture<?>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConnectionHandshakeHandler(Duration userTimeout, boolean activeOpen)
     
  • Method Summary

    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
    close(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise)
     
    void
    write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)
     

    Methods inherited from class io.netty.channel.ChannelDuplexHandler

    bind, 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
  • Field Details

    • userTimeoutFuture

      protected io.netty.util.concurrent.ScheduledFuture<?> userTimeoutFuture
  • Constructor Details

    • ConnectionHandshakeHandler

      public ConnectionHandshakeHandler(Duration userTimeout, boolean activeOpen)
      Parameters:
      userTimeout - time in ms in which a handshake must taken place after issued
      activeOpen - if true a handshake will be issued on channelActive(ChannelHandlerContext). Otherwise the remote peer must initiate the handshake
  • Method Details

    • close

      public void close(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) throws Exception
      Specified by:
      close in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      close in class io.netty.channel.ChannelDuplexHandler
      Throws:
      Exception
    • 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
    • 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