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


Java Channel.pipeline方法代码示例

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


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

示例1: initChannel

import io.netty.channel.Channel; //导入方法依赖的package包/类
@Override
protected void initChannel(Channel ch) throws Exception {
    RPCChannelHandler channelHandler = 
            new RPCChannelHandler(syncManager, rpcService);

    IdleStateHandler idleHandler = 
            new IdleStateHandler(5, 10, 0);
    ReadTimeoutHandler readTimeoutHandler = 
            new ReadTimeoutHandler(30);
    
    ChannelPipeline pipeline = ch.pipeline();
    pipeline.addLast("idle", idleHandler);
    pipeline.addLast("timeout", readTimeoutHandler);
    pipeline.addLast("handshaketimeout",
                     new HandshakeTimeoutHandler(channelHandler, timer, 10));

    pipeline.addLast("syncMessageDecoder",
                     new SyncMessageDecoder(maxFrameSize));
    pipeline.addLast("syncMessageEncoder",
                     new SyncMessageEncoder());

    pipeline.addLast("handler", channelHandler);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:24,代码来源:RPCChannelInitializer.java

示例2: initChannel

import io.netty.channel.Channel; //导入方法依赖的package包/类
@Override
protected void initChannel(Channel channel) throws Exception {
  ChannelPipeline pipeline = channel.pipeline();
  BoundNode node = channel.parent().attr(HANDLER).get();
  node.clientChannelGroup.add(channel);
  MDC.put("node", node.getId().toString());

  try {
    logger.debug("Got new connection {}", channel);

    pipeline
        .addLast("decoder", new FrameDecoder(node.getFrameCodec()))
        .addLast("encoder", new FrameEncoder(node.getFrameCodec()))
        .addLast("requestHandler", new RequestHandler(node));
  } finally {
    MDC.remove("node");
  }
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:19,代码来源:Server.java

示例3: unregisterChannelHandler

import io.netty.channel.Channel; //导入方法依赖的package包/类
private void unregisterChannelHandler() {
    if (serverChannelHandler == null)
        return;

    for (Channel serverChannel : serverChannels) {
        final ChannelPipeline pipeline = serverChannel.pipeline();

        // Remove channel handler
        serverChannel.eventLoop().execute(new Runnable() {

            @Override
            public void run() {
                try {
                    pipeline.remove(serverChannelHandler);
                } catch (NoSuchElementException e) {
                    // That's fine
                }
            }

        });
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:23,代码来源:TinyProtocol.java

示例4: channelCreated

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

    if (sslContext != null) {
        SslHandler handler = sslContext.newHandler(ch.alloc());
        p.addLast(handler);
        handler.handshakeFuture().addListener(future -> {
            if (!future.isSuccess()) {
                log.error(() -> "SSL handshake failed.", future.cause());
            }
        });
    }

    p.addLast(new HttpClientCodec());
    p.addLast(handlers);
    // Disabling auto-read is needed for backpressure to work
    ch.config().setOption(ChannelOption.AUTO_READ, false);
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:20,代码来源:ChannelPipelineInitializer.java

示例5: channelCreated

import io.netty.channel.Channel; //导入方法依赖的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

示例6: initChannel

import io.netty.channel.Channel; //导入方法依赖的package包/类
/**
 * 通道注册的时候配置websocket解码handler
 */
@Override
protected final void initChannel(Channel ch) throws Exception {
	ChannelPipeline pipeline=ch.pipeline();
	pipeline.addLast(new HttpClientCodec());
	pipeline.addLast(new ChunkedWriteHandler());
	pipeline.addLast(new HttpObjectAggregator(64*1024));
	pipeline.addLast(new WebSocketClientProtocolHandler(WebSocketClientHandshakerFactory.newHandshaker(new URI(url), WebSocketVersion.V13, null, false, new DefaultHttpHeaders())));
       pipeline.addLast(new WebSocketConnectedClientHandler());//连接成功监听handler
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:13,代码来源:WebSocketClientInitializer.java

示例7: initChannel

import io.netty.channel.Channel; //导入方法依赖的package包/类
@Override
protected final void initChannel(Channel ch) throws Exception {
	ChannelPipeline pipeline=ch.pipeline();
	pipeline.addLast(new HttpServerCodec());
       pipeline.addLast(new ChunkedWriteHandler());
       pipeline.addLast(new HttpObjectAggregator(64*1024));
       pipeline.addLast(new WebSocketServerProtocolHandler(uri));
       pipeline.addLast(new WebSocketConnectedServerHandler());//连接成功监听handler
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:10,代码来源:WebSocketServerInitializer.java

示例8: initChannel

import io.netty.channel.Channel; //导入方法依赖的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

示例9: initChannel

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

示例10: channelCreated

import io.netty.channel.Channel; //导入方法依赖的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:warlock-china,项目名称:azeroth,代码行数:11,代码来源:FastdfsPool.java

示例11: fireChannelRead

import io.netty.channel.Channel; //导入方法依赖的package包/类
static void fireChannelRead(Channel ch, CodecOutputList<ByteBuf> bufList) {
    ChannelPipeline childPipeline = ch.pipeline();
    int size = bufList.size();
    for (int i = 0; i < size; i++) {
        ByteBuf msg = bufList.getUnsafe(i);
        childPipeline.fireChannelRead(msg);
    }
    childPipeline.fireChannelReadComplete();
}
 
开发者ID:szhnet,项目名称:kcp-netty,代码行数:10,代码来源:Utils.java

示例12: initChannel

import io.netty.channel.Channel; //导入方法依赖的package包/类
@Override
protected void initChannel(Channel ch) throws Exception {
	ChannelPipeline pipeline = ch.pipeline();
	OFChannelHandler handler = new OFChannelHandler(
			switchManager,
			connectionListener,
			pipeline,
			debugCounters,
			timer,
			ofBitmaps,
			defaultFactory);

	if (keyStore != null && keyStorePassword != null) {
		try {
			/* Set up factories and stores. */
			TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
			KeyStore tmpKS = null;
			tmFactory.init(tmpKS);

			/* Use keystore/pass defined in properties file. */
			KeyStore ks = KeyStore.getInstance("JKS");
			ks.load(new FileInputStream(keyStore), keyStorePassword.toCharArray());

			KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
			kmf.init(ks, keyStorePassword.toCharArray());

			KeyManager[] km = kmf.getKeyManagers();
			TrustManager[] tm = tmFactory.getTrustManagers();

			/* Set up SSL prereqs for Netty. */
			SSLContext sslContext = SSLContext.getInstance("TLS");
			sslContext.init(km, tm, null);
			SSLEngine sslEngine = sslContext.createSSLEngine();

			/* We are the server and we will create secure sessions. */
			sslEngine.setUseClientMode(false);
			sslEngine.setEnableSessionCreation(true);

			/* These are redundant (default), but for clarity... */
			sslEngine.setEnabledProtocols(sslEngine.getSupportedProtocols()); 
			sslEngine.setEnabledCipherSuites(sslEngine.getSupportedCipherSuites());
			
			/* First, decrypt w/handler+engine; then, proceed with rest of handlers. */
			pipeline.addLast(PipelineHandler.SSL_TLS_ENCODER_DECODER, new SslHandler(sslEngine));
			log.info("SSL OpenFlow socket initialized and handler ready for switch.");
		} catch (Exception e) { /* There are lots of possible exceptions to catch, so this should get them all. */
			log.error("Exception initializing SSL OpenFlow socket: {}", e.getMessage());
			throw e; /* If we wanted secure but didn't get it, we should bail. */
		}
	}
	
	pipeline.addLast(PipelineHandler.OF_MESSAGE_DECODER,
			new OFMessageDecoder());
	pipeline.addLast(PipelineHandler.OF_MESSAGE_ENCODER,
			new OFMessageEncoder());
	pipeline.addLast(PipelineHandler.MAIN_IDLE,
			new IdleStateHandler(PipelineIdleReadTimeout.MAIN,
					PipelineIdleWriteTimeout.MAIN,
					0));
	pipeline.addLast(PipelineHandler.READ_TIMEOUT, new ReadTimeoutHandler(30));
	pipeline.addLast(PipelineHandler.CHANNEL_HANDSHAKE_TIMEOUT,
			new HandshakeTimeoutHandler(
					handler,
					timer,
					PipelineHandshakeTimeout.CHANNEL));

	pipeline.addLast(PipelineHandler.CHANNEL_HANDLER, handler);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:69,代码来源:OFChannelInitializer.java

示例13: initChannel

import io.netty.channel.Channel; //导入方法依赖的package包/类
@Override
protected void initChannel(Channel channel) throws Exception {
    ChannelPipeline pipeline = channel.pipeline();
    pipeline.addLast("timeout", new ReadTimeoutHandler(10));

    NetworkManager networkManager = new NetworkManager(connectionProvider.getCore());
    pipeline.addLast("packet_codec", new PacketCodec(networkManager.getProtocolManager()));
    pipeline.addLast("network_manager", networkManager);

    for (ConnectionInitListener initializerListener : connectionProvider.getInitializerListeners()) {
        initializerListener.init(networkManager);
    }
}
 
开发者ID:dzikoysk,项目名称:UnknownPandaServer,代码行数:14,代码来源:ConnectionInitializer.java

示例14: initChannel

import io.netty.channel.Channel; //导入方法依赖的package包/类
@Override
protected void initChannel(Channel ch) throws Exception {
    BootstrapChannelHandler handler =
            new BootstrapChannelHandler(bootstrap);

    ChannelPipeline pipeline = ch.pipeline();

    pipeline.addLast("syncMessageDecoder", new SyncMessageDecoder(maxFrameSize));

    pipeline.addLast("syncMessageEncoder", new SyncMessageEncoder());

    pipeline.addLast("timeout", new BootstrapTimeoutHandler(timer, 10));

    pipeline.addLast("handler", handler);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:BootstrapChannelInitializer.java

示例15: initChannel

import io.netty.channel.Channel; //导入方法依赖的package包/类
@Override
protected void initChannel(Channel ch) throws Exception {
    RemoteSyncChannelHandler channelHandler =
            new RemoteSyncChannelHandler(syncManager);

    ChannelPipeline pipeline = ch.pipeline();

    pipeline.addLast("syncMessageDecoder", new SyncMessageDecoder(maxFrameSize));

    pipeline.addLast("syncMessageEncoder", new SyncMessageEncoder());

    pipeline.addLast("timeout", new RSHandshakeTimeoutHandler(channelHandler, timer, 3));

    pipeline.addLast("handler", channelHandler);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:RemoteSyncChannelInitializer.java


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