Class QuicCodecDispatcher

  • All Implemented Interfaces:
    ChannelHandler, ChannelInboundHandler

    public abstract class QuicCodecDispatcher
    extends ChannelInboundHandlerAdapter
    Special ChannelHandler that should be used to init Channels that will be used for QUIC while SO_REUSEPORT is used to bind to same InetSocketAddress multiple times. This is necessary to ensure QUIC packets are always dispatched to the correct codec that keeps the mapping for the connection id. This implementation use a very simple mapping strategy by encoding the index of the internal datastructure that keeps track of the different ChannelHandlerContexts into the destination connection id. This way once a QUIC packet is received its possible to forward it to the right codec. Subclasses might change how encoding / decoding of the index is done by overriding decodeIndex(ByteBuf) and newIdGenerator(int).

    It is important that the same QuicCodecDispatcher instance is shared between all the Channels that are bound to the same InetSocketAddress and use SO_REUSEPORT.

    An alternative way to handle this would be to do the "routing" to the correct socket in an epbf program by implementing your own QuicConnectionIdGenerator that issue ids that can be understood and handled by the epbf program to route the packet to the correct socket.