Class AbstractThreeWayHandshakeServerHandler<R extends RequestMessage,​O extends ResponseMessage<?>>

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler
    Direct Known Subclasses:
    ServerConnectionHandler

    public abstract class AbstractThreeWayHandshakeServerHandler<R extends RequestMessage,​O extends ResponseMessage<?>>
    extends SimpleChannelDuplexHandler<Message,​Message>
    This handler performs the server-side part of a three-way handshake to create a session. It waits for a request message for a new session from the client. The request is then confirmed by sending an offer message to the client. It then waits for the client to confirm the offer.
    • Field Detail

      • timeout

        protected final Duration timeout
      • messenger

        protected final Messenger messenger
      • timeoutFuture

        protected io.netty.util.concurrent.ScheduledFuture<?> timeoutFuture
    • Constructor Detail

      • AbstractThreeWayHandshakeServerHandler

        protected AbstractThreeWayHandshakeServerHandler​(Duration timeout,
                                                         Messenger messenger)
      • AbstractThreeWayHandshakeServerHandler

        protected AbstractThreeWayHandshakeServerHandler​(Duration timeout,
                                                         Messenger messenger,
                                                         CompletableFuture<Void> handshakeFuture,
                                                         io.netty.util.concurrent.ScheduledFuture<?> timeoutFuture,
                                                         R requestMessage,
                                                         O offerMessage)
    • Method Detail

      • doHandshake

        protected void doHandshake​(io.netty.channel.ChannelHandlerContext ctx,
                                   Message message)
      • offerSession

        protected abstract O offerSession​(io.netty.channel.ChannelHandlerContext ctx,
                                          R requestMessage)
      • createConnection

        protected abstract void createConnection​(io.netty.channel.ChannelHandlerContext ctx,
                                                 R requestMessage)
      • processUnexpectedMessageDuringHandshake

        protected void processUnexpectedMessageDuringHandshake​(io.netty.channel.ChannelHandlerContext ctx,
                                                               Message message)
      • getLogger

        protected abstract org.slf4j.Logger getLogger()
      • processMessageAfterHandshake

        protected void processMessageAfterHandshake​(io.netty.channel.ChannelHandlerContext ctx,
                                                    Message message)
      • channelActive

        public void channelActive​(io.netty.channel.ChannelHandlerContext ctx)
                           throws Exception
        Specified by:
        channelActive in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • startTimeoutGuard

        protected void startTimeoutGuard​(io.netty.channel.ChannelHandlerContext ctx)
      • exceptionCaught

        public void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx,
                                    Throwable cause)
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelHandler
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter