当前位置: 首页>>代码示例>>Java>>正文


Java ChannelPipeline.addLast方法代码示例

本文整理汇总了Java中io.netty.channel.ChannelPipeline.addLast方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelPipeline.addLast方法的具体用法?Java ChannelPipeline.addLast怎么用?Java ChannelPipeline.addLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.channel.ChannelPipeline的用法示例。


在下文中一共展示了ChannelPipeline.addLast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
/**
 * Adds pipelines to channel.
 * 
 *  @param ch channel to be operated on
 */
protected void initChannel(SocketChannel ch) throws Exception {
  ChannelPipeline pipe = ch.pipeline();

  if (ssl) {
    // HTTPs connection
    SSLEngine sslEng = getSsl(null);
    sslEng.setUseClientMode(true);
    pipe.addLast("SSL", new SslHandler(sslEng, false));
  }

  pipe.addFirst("Timer", new ReadTimeoutHandler(30));
  pipe.addLast("Codec", new HttpClientCodec());
  pipe.addLast("Inflater", new HttpContentDecompressor());
  pipe.addLast("Handler", new HTTPMessageHandler(builder));
}
 
开发者ID:SOURAVPURI100,项目名称:Stork,代码行数:21,代码来源:HTTPInitializer.java

示例2: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    // 根据服务端协议,选择解码器
    Constants.ProtocolType type = transportConfig.getProvider().getProtocolType();
    switch (type) {
        case jsf:
            pipeline.addLast(new JSFEncoder());
            pipeline.addLast(new JSFDecoder(transportConfig.getPayload()));
            break;
        case dubbo:
            pipeline.addLast(new DubboEncoder());
            pipeline.addLast(new DubboDecoder(transportConfig.getPayload()));
            break;
        default:
            throw new InitErrorException("Unsupported client protocol type : " + type.name());
    }
    pipeline.addLast(Constants.CLIENT_CHANNELHANDLE_NAME, clientChannelHandler);
}
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:20,代码来源:ClientChannelInitializer.java

示例3: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();

    pipeline.addLast(new LoggingHandler());
    // Add SSL handler first to encrypt and decrypt everything.
    // In this example, we use a bogus certificate in the server side
    // and accept any invalid certificates in the client side.
    // You will need something more complicated to identify both
    // and server in the real world.
    if (sslCtx != null)
        pipeline.addLast(sslCtx.newHandler(ch.alloc(), SecureChatClient.HOST, SecureChatClient.PORT));

    // On top of the SSL handler, add the text line codec.
    pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    pipeline.addLast(new StringDecoder());
    pipeline.addLast(new StringEncoder());

    // and then business logic.
    pipeline.addLast(new SecureChatClientHandler());
}
 
开发者ID:veritasware,项目名称:neto,代码行数:22,代码来源:SecureChatClientInitializer.java

示例4: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
public void initChannel(SocketChannel ch) throws Exception {
	ChannelPipeline pipeline = ch.pipeline();
	pipeline.addLast("encoder", new MqttMessageEncoder());
	pipeline.addLast("decoder", new MqttMessageDecoder());
	pipeline.addLast("handler", new MqttMessageHandler());
}
 
开发者ID:osswangxining,项目名称:mqttserver,代码行数:8,代码来源:TcpChannelInitializer.java

示例5: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		ChannelPipeline p = ch.pipeline();
		if(sslCtx!=null)
		{
			p.addLast(new SslHandler(sslCtx.newEngine(ch.alloc())));
		}
		p.addLast(new HttpResponseDecoder());
		//限制contentLength
		p.addLast(new HttpObjectAggregator(65536));
		p.addLast(new HttpRequestEncoder());
		//大文件传输处理
//		p.addLast(new ChunkedWriteHandler());
		p.addLast(new DefaultListenerHandler<HttpResponse>(listener));
	}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:16,代码来源:HttpClientInitHandler.java

示例6: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
    final ChannelPipeline pipeline = socketChannel.pipeline();
    NettyPipelineInit.serializePipeline(serializeProtocolEnum, pipeline);
    pipeline.addLast("timeout", new IdleStateHandler(txConfig.getHeartTime(), txConfig.getHeartTime(), txConfig.getHeartTime(), TimeUnit.SECONDS));
    pipeline.addLast(nettyClientMessageHandler);

}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:9,代码来源:NettyClientHandlerInitializer.java

示例7: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
public void initChannel(SocketChannel socketChannel) throws Exception {
	ChannelPipeline p = socketChannel.pipeline();
	p.addLast(new SocksInitRequestDecoder());
	p.addLast(socksMessageEncoder);
	p.addLast(socksServerHandler);
	p.addLast(trafficHandler);
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:9,代码来源:SocksServerInitializer.java

示例8: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
 protected void initChannel(SocketChannel ch) throws Exception {
     ChannelPipeline pipeline = ch.pipeline();

     // SSL的安全链接
     if (ServerConfig.isSsl()) {
         SSLContext sslcontext = SSLContext.getInstance("TLS");
         KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
         KeyStore ks = KeyStore.getInstance("JKS");
         String keyStorePath = ServerConfig.getKeyStorePath();
         String keyStorePassword = ServerConfig.getKeyStorePassword();
         ks.load(new FileInputStream(keyStorePath), keyStorePassword.toCharArray());
         String keyPassword = ServerConfig.getKeyPassword();
         kmf.init(ks, keyPassword.toCharArray());
         sslcontext.init(kmf.getKeyManagers(), null, null);
         SSLEngine sslEngine = sslcontext.createSSLEngine();
         sslEngine.setUseClientMode(false);
         sslEngine.setNeedClientAuth(false);
         /**
          * 务必放在第一位
          */
         pipeline.addLast(new SslHandler(sslEngine));
         logger.info("initChannel: addLast SslHandler");
         /**
          * Generates a temporary self-signed certificate for testing purposes.
          */
/*SelfSignedCertificate ssc = new SelfSignedCertificate();
SslContext sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
//SslContext sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());
if (sslCtx != null) {
	pipeline.addLast(sslCtx.newHandler(ch.alloc()));
}*/
     }
     // Register HTTP handler chain.
     this.appendHttpPipeline(pipeline);
 }
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:37,代码来源:HttpChannelInitializer.java

示例9: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
protected void initChannel( SocketChannel _channel ) throws Exception {
	logger.info( "Netty Server init channel: " + _channel.isActive() ) ;

	ChannelPipeline pipeline = _channel.pipeline() ;

	pipeline.addLast( ( AbsNettyDecoder ) CommonContextHolder.getBean( INettyHandler.NETTY_DECODER ) ) ;
	pipeline.addLast( new IdleStateHandler( 100 , 0 , 0 , TimeUnit.SECONDS ) ) ;
	pipeline.addLast( ( INettyHandler ) CommonContextHolder.getBean( INettyHandler.NETTY_HANDLER ) ) ;
}
 
开发者ID:aiyoyoyo,项目名称:jeesupport,代码行数:11,代码来源:NettyInitializer.java

示例10: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
public void initChannel(SocketChannel ch) {
    ChannelPipeline pipeline = ch.pipeline();
    //pipeline.addLast("http-compressor", new HttpContentCompressor());
    pipeline.addLast("http-codec", new HttpServerCodec());
    pipeline.addLast("http-aggregator", new HttpObjectAggregator(65536));
    pipeline.addLast("http-chunked", new ChunkedWriteHandler());
    pipeline.addLast("http-handler", new HttpRedirectHandler());
}
 
开发者ID:noti0na1,项目名称:HFSN,代码行数:10,代码来源:HttpRedirectInitializer.java

示例11: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception
{
	ChannelPipeline pipeline = ch.pipeline();

	pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
	pipeline.addLast(new MessageDecoder());
	pipeline.addLast(new MessageEncoder());

	pipeline.addLast(new ServerHandler());
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:12,代码来源:ServerChannelInitializer.java

示例12: channelCreated

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
public void channelCreated(Channel channel) throws Exception {
    if (LOG.isInfoEnabled()) {
        LOG.info("channel created : {}", channel.toString());
    }

    ChannelPipeline pipeline = channel.pipeline();
    pipeline.addLast(new IdleStateHandler(readTimeout, 0, idleTimeout, TimeUnit.MILLISECONDS));
    pipeline.addLast(new ChunkedWriteHandler()).addLast(new FastdfsHandler());
}
 
开发者ID:rodbate,项目名称:fastdfs-spring-boot,代码行数:10,代码来源:FastdfsPool.java

示例13: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
public void initChannel(final SocketChannel ch) {
    final ChannelPipeline pipeline = ch.pipeline();

    pipeline.addLast(new DelimiterBasedFrameDecoder(1048576 * 2, Delimiters.lineDelimiter()));
    pipeline.addLast(new StringDecoder());
    pipeline.addLast(new StringEncoder());

    pipeline.addLast(new NettyClientHandler(this.consumer));
}
 
开发者ID:dethi,项目名称:guereza,代码行数:11,代码来源:NettyClientInitializer.java

示例14: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
    ProtobufAdapter adapter = new ProtobufAdapter(config);

    ChannelPipeline pipeline = socketChannel.pipeline();
    pipeline.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
    pipeline.addLast("decoder", adapter.getDecoder());
    pipeline.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
    pipeline.addLast("encoder", adapter.getEncoder());
    pipeline.addLast("handler", new TcpServerHandler(config));
}
 
开发者ID:linkedkeeper,项目名称:tcp-gateway,代码行数:12,代码来源:ServerChannelInitializer.java

示例15: initChannel

import io.netty.channel.ChannelPipeline; //导入方法依赖的package包/类
@Override
protected void initChannel(Channel channel) throws Exception {
    //IdleStateHandler检测心跳.
    ChannelPipeline p = channel.pipeline();
    p.addLast(new IdleStateHandler(20, 10, 0));
    p.addLast(new ObjectEncoder());
    p.addLast(new ObjectDecoder(ClassResolvers.cacheDisabled(null)));
    p.addLast(new NettyClientHandler());
}
 
开发者ID:haifeiWu,项目名称:push-server,代码行数:10,代码来源:NettyClientInitializer.java


注:本文中的io.netty.channel.ChannelPipeline.addLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。