當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。