private void SwitchToWebsocket(ChannelHandlerContext ctx)
        {
            ChannelPipeline p = ctx.pipeline();

            p.addLast(new HttpServerCodec(), new HttpObjectAggregator(MAX_WEBSOCKET_HANDSHAKE_SIZE), new WebSocketServerProtocolHandler("/", null, false, MAX_WEBSOCKET_FRAME_SIZE), new WebSocketFrameAggregator(MAX_WEBSOCKET_FRAME_SIZE), new WebSocketFrameTranslator(), NewHandshaker());
            p.remove(this);
        }
Example #2
0
            /// <exception cref="System.Exception"/>
            protected override void InitChannel(SocketChannel ch)
            {
                ChannelPipeline p = ch.Pipeline();

                p.AddLast(new HttpRequestDecoder(), new StringEncoder(), new HttpResponseEncoder(
                              ), new FSImageHandler(loader, this._enclosing.allChannels));
            }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            @lock = NewThrottleLockMock();

            _config = mock(typeof(SocketChannelConfig));

            _lockAttribute = mock(typeof(Attribute));
            when(_lockAttribute.get()).thenReturn(@lock);

            Attribute durationExceedAttribute = mock(typeof(Attribute));

            when(durationExceedAttribute.get()).thenReturn(null);

            _channel = mock(typeof(SocketChannel), Answers.RETURNS_MOCKS);
            when(_channel.config()).thenReturn(_config);
            when(_channel.Open).thenReturn(true);
            when(_channel.remoteAddress()).thenReturn(InetSocketAddress.createUnresolved("localhost", 32000));
            when(_channel.attr(TransportWriteThrottle.LockKey)).thenReturn(_lockAttribute);
            when(_channel.attr(TransportWriteThrottle.MaxDurationExceededKey)).thenReturn(durationExceedAttribute);

            ChannelPipeline pipeline = _channel.pipeline();

            when(_channel.pipeline()).thenReturn(pipeline);

            _context = mock(typeof(ChannelHandlerContext), Answers.RETURNS_MOCKS);
            when(_context.channel()).thenReturn(_channel);
        }
        private void SwitchToSocket(ChannelHandlerContext ctx)
        {
            ChannelPipeline p = ctx.pipeline();

            p.addLast(NewHandshaker());
            p.remove(this);
        }
Example #5
0
            /// <exception cref="System.Exception"/>
            protected override void InitChannel(SocketChannel ch)
            {
                ChannelPipeline p = ch.Pipeline();

                p.AddLast(new HttpRequestDecoder(), new HttpResponseEncoder(), new ChunkedWriteHandler
                              (), new URLDispatcher(jettyAddr, conf, this._enclosing.confForCreate));
            }
Example #6
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="pipeline"></param>
 /// <param name="name"></param>
 /// <param name="handler"></param>
 public DefaultChannelHandlerContext(ChannelPipeline pipeline, string name, ChannelHandler handler, bool async)
 {
     ChannelPipeline = pipeline;
     Name            = name;
     ChannelHandler  = handler;
     Async           = async;
 }
            /// <exception cref="System.Exception"/>
            protected override void InitChannel(SocketChannel ch)
            {
                ChannelPipeline p = ch.Pipeline();

                p.AddLast(new HttpRequestEncoder(), new SimpleHttpProxyHandler.Forwarder(this._enclosing
                                                                                         .uri, client));
            }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="socketServer"></param>
 public SocketServerChannel(SocketServer socketServer, Socket socket, ByteBufPool <ByteBuf> byteBufPool)
 {
     Id              = Guid.NewGuid().ToString();
     SocketServer    = socketServer;
     Socket          = socket;
     ChannelPipeline = new DefaultChannelPipeline(this);
     buffPool        = byteBufPool;
 }
Example #9
0
        public IChannelPipeline GetPipeline(IChannel channel)
        {
            var pipeline = new ChannelPipeline(channel);

            Initialize(pipeline);

            return(pipeline);
        }
        private void EnableSsl(ChannelHandlerContext ctx)
        {
            ChannelPipeline p = ctx.pipeline();

            p.addLast(_sslCtx.newHandler(ctx.alloc()));
            p.addLast(new TransportSelectionHandler(_boltChannel, null, _encryptionRequired, true, _logging, _boltProtocolFactory));
            p.remove(this);
        }
Example #11
0
 internal NettyPipelineBuilder(ChannelPipeline pipeline, Log log)
 {
     if (!InstanceFieldsInitialized)
     {
         InitializeInstanceFields();
         InstanceFieldsInitialized = true;
     }
     this._pipeline = pipeline;
     this._log      = log;
 }
Example #12
0
            protected internal override void InitChannel(SocketChannel channel)
            {
                ChannelPipeline pipeline = channel.pipeline();

                ChannelHandler clientOnConnectSslHandler = SslPolicy.nettyClientHandler(channel, SslContext);

                pipeline.addLast(clientOnConnectSslHandler);
                pipeline.addLast(new ChannelInboundHandlerAdapterAnonymousInnerClass(this));
                pipeline.addLast(Bucket);
            }
Example #13
0
            protected internal override void InitChannel(SocketChannel channel)
            {
                ChannelPipeline pipeline = channel.pipeline();

                pipeline.addLast("frameEncoder", new LengthFieldPrepender(4));
                pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(int.MaxValue, 0, 4, 0, 4));
                pipeline.addLast("requestMessageEncoder", new ClientMessageEncoder());
                pipeline.addLast("responseMessageDecoder", new ClientMessageDecoder());
                pipeline.addLast(new NettyHandshakeClient(HandshakeClient));
            }
Example #14
0
                protected internal override void initChannel(SocketChannel ch)
                {
                    ChannelPipeline pipeline = ch.pipeline();

                    _outerInstance.handshakeServer = new HandshakeServer(_applicationProtocolRepository, _modifierProtocolRepository, new SimpleNettyChannel(ch, NullLog.Instance));
                    pipeline.addLast("frameEncoder", new LengthFieldPrepender(4));
                    pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(int.MaxValue, 0, 4, 0, 4));
                    pipeline.addLast("responseMessageEncoder", new ServerMessageEncoder());
                    pipeline.addLast("requestMessageDecoder", new ServerMessageDecoder());
                    pipeline.addLast(new NettyHandshakeServer(_outerInstance.handshakeServer));
                }
Example #15
0
        internal ClientSideOnConnectSslHandler(Channel channel, SslContext sslContext, bool verifyHostname, string[] tlsVersions)
        {
            this._pipeline   = channel.pipeline();
            this._sslContext = sslContext;

            this._engineModifications = new List <Function <SSLEngine, SSLEngine> >();
            _engineModifications.Add(new EssentialEngineModifications(tlsVersions, true));
            if (verifyHostname)
            {
                _engineModifications.Add(new ClientSideHostnameVerificationEngineModification());
            }
        }
Example #16
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected void initChannel(io.netty.channel.socket.SocketChannel ch) throws Exception
            protected internal override void initChannel(SocketChannel ch)
            {
                ChannelPipeline pipeline = ch.pipeline();

                SSLEngine sslEngine = _outerInstance.sslContext.newEngine(ch.alloc());

                sslEngine.NeedClientAuth = true;
                SslHandler sslHandler = new SslHandler(sslEngine);

                pipeline.addLast(sslHandler);

                pipeline.addLast(new Responder());
            }
Example #17
0
			/// <exception cref="System.Exception"/>
			public virtual ChannelPipeline GetPipeline()
			{
				ChannelPipeline pipeline = Channels.Pipeline();
				if (this.sslFactory != null)
				{
					pipeline.AddLast("ssl", new SslHandler(this.sslFactory.CreateSSLEngine()));
				}
				pipeline.AddLast("decoder", new HttpRequestDecoder());
				pipeline.AddLast("aggregator", new HttpChunkAggregator(1 << 16));
				pipeline.AddLast("encoder", new HttpResponseEncoder());
				pipeline.AddLast("chunking", new ChunkedWriteHandler());
				pipeline.AddLast("shuffle", this.Shuffle);
				return pipeline;
			}
        private void remove(ChannelHandlerContext ctx)
        {
            try
            {
                ChannelPipeline pipeline = ctx.pipeline();

                if (pipeline.context(this) != null)
                {
                    pipeline.remove(this);
                }
            }
            finally
            {
                bool ret;
                initMap.TryRemove(ctx, out ret);
            }
        }
Example #19
0
        /// <exception cref="System.Exception"/>
        protected override void ChannelRead0(ChannelHandlerContext ctx, HttpRequest req)
        {
            string          uri = req.GetUri();
            ChannelPipeline p   = ctx.Pipeline();

            if (uri.StartsWith(WebHdfsHandler.WebhdfsPrefix))
            {
                WebHdfsHandler h = new WebHdfsHandler(conf, confForCreate);
                p.Replace(this, typeof(WebHdfsHandler).Name, h);
                h.ChannelRead0(ctx, req);
            }
            else
            {
                SimpleHttpProxyHandler h = new SimpleHttpProxyHandler(proxyHost);
                p.Replace(this, typeof(SimpleHttpProxyHandler).Name, h);
                h.ChannelRead0(ctx, req);
            }
        }
Example #20
0
        protected override void init(Channel _channel)
        {
            ChannelPipeline p = _channel.pipeline();

            EventLoopGroup currentChildGroup   = childGroup;
            ChannelHandler currentChildHandler = _childHandler;

            p.addLast(new ChannelInitializer <Channel>(channel =>
            {
                ChannelPipeline pipeline = channel.pipeline();
                ChannelHandler _handler  = handler();
                if (_handler != null)
                {
                    pipeline.addLast(_handler);
                }

                channel.eventLoop().execute(() => pipeline.addLast(new ServerBootstrapAcceptor(channel, currentChildGroup, currentChildHandler)));
            }));
        }
Example #21
0
 private IList <ChannelHandler> GetHandlers(ChannelPipeline pipeline)
 {
     return(pipeline.names().Select(pipeline.get).Where(Objects.nonNull).ToList());
 }
Example #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") private static org.jboss.netty.handler.queue.BlockingReadHandler<org.jboss.netty.buffer.ChannelBuffer> extractBlockingReadHandler(ChannelContext channelContext)
        private static BlockingReadHandler <ChannelBuffer> ExtractBlockingReadHandler(ChannelContext channelContext)
        {
            ChannelPipeline pipeline = channelContext.Channel().Pipeline;

            return((BlockingReadHandler <ChannelBuffer>)pipeline.get(BLOCKING_CHANNEL_HANDLER_NAME));
        }
Example #23
0
 /// <summary>
 /// Entry point for the server builder.
 /// </summary>
 /// <param name="pipeline"> The pipeline to build for. </param>
 /// <param name="log"> The log used for last-resort errors occurring in the pipeline. </param>
 /// <returns> The server builder. </returns>
 public static ServerNettyPipelineBuilder Server(ChannelPipeline pipeline, Log log)
 {
     return(new ServerNettyPipelineBuilder(pipeline, log));
 }
Example #24
0
 /// <summary>
 /// Entry point for the client builder.
 /// </summary>
 /// <param name="pipeline"> The pipeline to build for. </param>
 /// <param name="log"> The log used for last-resort errors occurring in the pipeline. </param>
 /// <returns> The client builder. </returns>
 public static ClientNettyPipelineBuilder Client(ChannelPipeline pipeline, Log log)
 {
     return(new ClientNettyPipelineBuilder(pipeline, log));
 }
Example #25
0
        protected override void init(Channel _channel)
        {
            ChannelPipeline p = _channel.pipeline();

            p.addLast(handler());
        }
Example #26
0
 public static void AddLengthFieldPipes(ChannelPipeline pipeline, int frameLength)
 {
     pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(frameLength + 4, 0, 4, 0, 4));
     pipeline.addLast("frameEncoder", new LengthFieldPrepender(4));
 }
Example #27
0
 public HeadHandler(ChannelPipeline pipeline)
 {
     this.pipeline = pipeline;
 }
Example #28
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="pipeline"></param>
 /// <param name="name"></param>
 /// <param name="handler"></param>
 public DefaultChannelHandlerContext(ChannelPipeline pipeline, string name, ChannelHandler handler)
 {
     ChannelPipeline = pipeline;
     Name            = name;
     ChannelHandler  = handler;
 }