protected virtual void SetInitialChannelPipeline(IChannel ch)
        {
            var p          = ch.Pipeline;
            var connection = new DefaultHttp2Connection(false);

            this.clientHandler = new Http2ConnectionHandlerBuilder()
            {
                FrameListener = new InboundHttp2ToHttpAdapterBuilder(connection)
                {
                    MaxContentLength = this.maxContentLength,
                }.Build(),
                Connection = connection,
                GracefulShutdownTimeout = TimeSpan.Zero
            }.Build();
            p.AddLast(this.clientHandler);

            this.clientDelegator = new HttpResponseDelegator(this.clientListener.Object, this.clientLatch, this.clientLatch2);
            p.AddLast(this.clientDelegator);
        }
        private void BootstrapEnv(int clientLatchCount, int clientLatchCount2, int serverLatchCount,
                                  int serverLatchCount2, int settingsLatchCount)
        {
            var prefaceWrittenLatch = new CountdownEvent(1);

            this.clientDelegator        = null;
            this.serverDelegator        = null;
            this.serverConnectedChannel = null;
            this.maxContentLength       = 1024;
            var serverChannelLatch = new CountdownEvent(1);

            this.serverLatch   = new CountdownEvent(serverLatchCount);
            this.clientLatch   = new CountdownEvent(clientLatchCount);
            this.serverLatch2  = new CountdownEvent(serverLatchCount2);
            this.clientLatch2  = new CountdownEvent(clientLatchCount2);
            this.settingsLatch = new CountdownEvent(settingsLatchCount);

            this.sb = new ServerBootstrap();
            this.cb = new Bootstrap();

            this.SetupServerBootstrap(this.sb);
            this.sb.ChildHandler(new ActionChannelInitializer <IChannel>(ch =>
            {
                this.SetInitialServerChannelPipeline(ch);
                serverChannelLatch.SafeSignal();
            }));

            this.SetupBootstrap(this.cb);
            this.cb.Handler(new ActionChannelInitializer <IChannel>(ch =>
            {
                this.SetInitialChannelPipeline(ch);

                ch.Pipeline.AddLast(new TestChannelHandlerAdapterEC(this));

                ch.Pipeline.AddLast(new TestChannelHandlerAdapter(prefaceWrittenLatch));
            }));

            this.StartBootstrap();

            Assert.True(prefaceWrittenLatch.Wait(TimeSpan.FromSeconds(5)));
            Assert.True(serverChannelLatch.Wait(TimeSpan.FromSeconds(5)));
        }
        protected virtual void SetInitialServerChannelPipeline(IChannel ch)
        {
            this.serverConnectedChannel = ch;
            var p          = ch.Pipeline;
            var connection = new DefaultHttp2Connection(true);

            this.serverHandler = new Http2ConnectionHandlerBuilder()
            {
                FrameListener = new InboundHttp2ToHttpAdapterBuilder(connection)
                {
                    MaxContentLength      = this.maxContentLength,
                    IsValidateHttpHeaders = true,
                    IsPropagateSettings   = true,
                }.Build(),
                Connection = connection,
                GracefulShutdownTimeout = TimeSpan.Zero
            }.Build();
            p.AddLast(this.serverHandler);

            this.serverDelegator = new HttpResponseDelegator(this.serverListener.Object, this.serverLatch, this.serverLatch2);
            p.AddLast(this.serverDelegator);
            this.settingsDelegator = new HttpSettingsDelegator(this.settingsListener.Object, this.settingsLatch);
            p.AddLast(this.settingsDelegator);
        }