// 
// Decompiled by Procyon v0.6.0
// 

package io.netty.handler.codec.http3;

import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.quic.QuicStreamChannel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.internal.ObjectUtil;
import org.jetbrains.annotations.Nullable;
import java.util.function.LongFunction;
import io.netty.channel.ChannelHandler;

public final class Http3ServerConnectionHandler extends Http3ConnectionHandler
{
    private final ChannelHandler requestStreamHandler;
    
    public Http3ServerConnectionHandler(final ChannelHandler requestStreamHandler) {
        this(requestStreamHandler, null, null, null, true);
    }
    
    public Http3ServerConnectionHandler(final ChannelHandler requestStreamHandler, @Nullable final ChannelHandler inboundControlStreamHandler, @Nullable final LongFunction<ChannelHandler> unknownInboundStreamHandlerFactory, @Nullable final Http3SettingsFrame localSettings, final boolean disableQpackDynamicTable) {
        super(true, inboundControlStreamHandler, unknownInboundStreamHandlerFactory, localSettings, disableQpackDynamicTable);
        this.requestStreamHandler = ObjectUtil.checkNotNull(requestStreamHandler, "requestStreamHandler");
    }
    
    @Override
    void initBidirectionalStream(final ChannelHandlerContext ctx, final QuicStreamChannel streamChannel) {
        final ChannelPipeline pipeline = streamChannel.pipeline();
        final Http3RequestStreamEncodeStateValidator encodeStateValidator = new Http3RequestStreamEncodeStateValidator();
        final Http3RequestStreamDecodeStateValidator decodeStateValidator = new Http3RequestStreamDecodeStateValidator();
        pipeline.addLast(this.newCodec(encodeStateValidator, decodeStateValidator));
        pipeline.addLast(encodeStateValidator);
        pipeline.addLast(decodeStateValidator);
        pipeline.addLast(this.newRequestStreamValidationHandler(streamChannel, encodeStateValidator, decodeStateValidator));
        pipeline.addLast(this.requestStreamHandler);
    }
    
    @Override
    void initUnidirectionalStream(final ChannelHandlerContext ctx, final QuicStreamChannel streamChannel) {
        final long maxTableCapacity = this.maxTableCapacity();
        streamChannel.pipeline().addLast(new Http3UnidirectionalStreamInboundServerHandler(this.codecFactory, this.localControlStreamHandler, this.remoteControlStreamHandler, this.unknownInboundStreamHandlerFactory, () -> new QpackEncoderHandler(maxTableCapacity, this.qpackDecoder), () -> new QpackDecoderHandler(this.qpackEncoder)));
    }
}
