當前位置: 首頁>>代碼示例>>Java>>正文


Java ReadTimeoutHandler類代碼示例

本文整理匯總了Java中io.netty.handler.timeout.ReadTimeoutHandler的典型用法代碼示例。如果您正苦於以下問題:Java ReadTimeoutHandler類的具體用法?Java ReadTimeoutHandler怎麽用?Java ReadTimeoutHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ReadTimeoutHandler類屬於io.netty.handler.timeout包,在下文中一共展示了ReadTimeoutHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Client

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的package包/類
/**
 * 本地爬蟲服務,長連接
 *
 * @param action
 */
public Client(@Nonnull final Action action){
    isLongConnection = true;
    final Client self = this;
    this.action = action;
    channelInitializer = new ChannelInitializer<SocketChannel>() {
        @Override
        protected void initChannel(SocketChannel ch) throws Exception {
            ch.pipeline().addLast(new ProtobufVarint32FrameDecoder());
            ch.pipeline().addLast(new ProtobufDecoder(ProcessData.getDefaultInstance()));
            ch.pipeline().addLast(new ProtobufVarint32LengthFieldPrepender());
            ch.pipeline().addLast(new ProtobufEncoder());
            ch.pipeline().addLast(new ReadTimeoutHandler(60));
            ch.pipeline().addLast(new LoginAuthReqHandler(channel));
            ch.pipeline().addLast(new LocalCrawlerHandler(action));
            ch.pipeline().addLast(new HeartBeatReqHandler(self, closeLongConnection));
        }
    };
}
 
開發者ID:xiongbeer,項目名稱:Cobweb,代碼行數:24,代碼來源:Client.java

示例2: NettyServer

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的package包/類
private NettyServer(){
	pGroup = new NioEventLoopGroup();
	cGroup = new NioEventLoopGroup();
	serverBootstrap = new ServerBootstrap();
	serverBootstrap.group(pGroup, cGroup)
	 .channel(NioServerSocketChannel.class)
	 .option(ChannelOption.SO_BACKLOG, 1024)
	 //設置日誌
	 .handler(new LoggingHandler(LogLevel.INFO))
	 .childHandler(new ChannelInitializer<SocketChannel>() {
		protected void initChannel(SocketChannel sc) throws Exception {
			sc.pipeline().addLast(MarshallingCodeCFactory.buildMarshallingDecoder());
			sc.pipeline().addLast(MarshallingCodeCFactory.buildMarshallingEncoder());
			sc.pipeline().addLast(new ReadTimeoutHandler(60));
			sc.pipeline().addLast(new NettyServerHandler());
		}
	});		
}
 
開發者ID:craware,項目名稱:webapp-tyust,代碼行數:19,代碼來源:NettyServer.java

示例3: initChannel

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的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

示例4: initChannel

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的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:didclab,項目名稱:onedatashare,代碼行數:21,代碼來源:HTTPInitializer.java

示例5: initChannel

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的package包/類
@Override
public void initChannel(Channel ch) throws Exception
{
    try
    {
        ch.config().setOption( ChannelOption.IP_TOS, 0x18 );
    } catch ( ChannelException ex )
    {
        // IP_TOS is not supported (Windows XP / Windows Server 2003)
    }
    ch.config().setOption( ChannelOption.TCP_NODELAY, true );
    ch.config().setAllocator( PooledByteBufAllocator.DEFAULT );

    ch.pipeline().addLast( TIMEOUT_HANDLER, new ReadTimeoutHandler( BungeeCord.getInstance().config.getTimeout(), TimeUnit.MILLISECONDS ) );
    ch.pipeline().addLast( FRAME_DECODER, new Varint21FrameDecoder() );
    ch.pipeline().addLast( FRAME_PREPENDER, framePrepender );

    ch.pipeline().addLast( BOSS_HANDLER, new HandlerBoss() );
}
 
開發者ID:WaterfallMC,項目名稱:Waterfall-Old,代碼行數:20,代碼來源:PipelineUtils.java

示例6: initChannel

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的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:zhenshengcai,項目名稱:floodlight-hardware,代碼行數:24,代碼來源:RPCChannelInitializer.java

示例7: initChannel

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
	ChannelPipeline pipeline = ch.pipeline();
	if (sslCtx != null) {
		pipeline.addLast(sslCtx.newHandler(ch.alloc()));
	}
	pipeline.addLast(new HttpResponseEncoder());
	pipeline.addLast(new HttpRequestDecoder());
	// Uncomment the following line if you don't want to handle HttpChunks.
	//pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
	//p.addLast(new HttpObjectAggregator(1048576));
	// Remove the following line if you don't want automatic content compression.
	//pipeline.addLast(new HttpContentCompressor());
	
	// Uncomment the following line if you don't want to handle HttpContents.
	pipeline.addLast(new HttpObjectAggregator(65536));
	pipeline.addLast("readTimeoutHandler", new ReadTimeoutHandler(READ_TIMEOUT));
	pipeline.addLast("myHandler", new MyHandler());
	
	pipeline.addLast("handler", new HttpServerHandler(listener));
}
 
開發者ID:iotoasis,項目名稱:SI,代碼行數:22,代碼來源:HttpServerInitializer.java

示例8: provideHandlerProviders

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的package包/類
@Provides
@EppProtocol
static ImmutableList<Provider<? extends ChannelHandler>> provideHandlerProviders(
    Provider<SslServerInitializer<NioSocketChannel>> sslServerInitializerProvider,
    Provider<ProxyProtocolHandler> proxyProtocolHandlerProvider,
    @EppProtocol Provider<ReadTimeoutHandler> readTimeoutHandlerProvider,
    Provider<LengthFieldBasedFrameDecoder> lengthFieldBasedFrameDecoderProvider,
    Provider<LengthFieldPrepender> lengthFieldPrependerProvider,
    Provider<EppServiceHandler> eppServiceHandlerProvider,
    Provider<LoggingHandler> loggingHandlerProvider,
    Provider<FullHttpRequestRelayHandler> relayHandlerProvider) {
  return ImmutableList.of(
      proxyProtocolHandlerProvider,
      sslServerInitializerProvider,
      readTimeoutHandlerProvider,
      lengthFieldBasedFrameDecoderProvider,
      lengthFieldPrependerProvider,
      eppServiceHandlerProvider,
      loggingHandlerProvider,
      relayHandlerProvider);
}
 
開發者ID:google,項目名稱:nomulus,代碼行數:22,代碼來源:EppProtocolModule.java

示例9: modifyPipeLine

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的package包/類
/**
 * Modify the pipeline for the request
 *
 * @param req      to process
 * @param pipeline to modify
 * @param <R>      Type of Response
 */
private <R> void modifyPipeLine(final EtcdRequest<R> req, final ChannelPipeline pipeline) {
  final EtcdResponseHandler<R> handler = new EtcdResponseHandler<>(this, req);

  if (req.hasTimeout()) {
    pipeline.addFirst(new ReadTimeoutHandler(req.getTimeout(), req.getTimeoutUnit()));
  }

  pipeline.addLast(handler);
  pipeline.addLast(new ChannelHandlerAdapter() {
    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
      handler.retried(true);
      req.getPromise().handleRetry(cause);
    }
  });
}
 
開發者ID:jurmous,項目名稱:etcd4j,代碼行數:24,代碼來源:EtcdNettyClient.java

示例10: initChannel

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
    ChannelPipeline p = ch.pipeline();
    if (sslCtx != null) {
        p.addLast(sslCtx.newHandler(ch.alloc(), NettyPistachioClient.HOST, NettyPistachioClient.PORT));
    }

    LogLevel level = LogLevel.DEBUG;


    p.addLast(new LoggingHandler(level));
    p.addLast(new ReadTimeoutHandler(ConfigurationManager.getConfiguration().getInt("Network.Netty.ClientReadTimeoutMillis",10000), TimeUnit.MILLISECONDS));
    p.addLast(new ProtobufVarint32FrameDecoder());
    p.addLast(new ProtobufDecoder(NettyPistachioProtocol.Response.getDefaultInstance()));

    p.addLast(new ProtobufVarint32LengthFieldPrepender());
    p.addLast(new ProtobufEncoder());

    p.addLast(new NettyPistachioClientHandler());
}
 
開發者ID:lyogavin,項目名稱:Pistachio,代碼行數:21,代碼來源:NettyPistachioClientInitializer.java

示例11: initChannel

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的package包/類
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
    ChannelPipeline pipeline = socketChannel.pipeline();
    pipeline.addLast("timeout", new ReadTimeoutHandler(15));
    pipeline.addLast("codec-http", new HttpServerCodec());
    pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
    pipeline.addLast("handler", new HTTPHandler(plugin));
    pipeline.addLast("websocket", new WebSocketServerProtocolHandler("/server"));
    pipeline.addLast("packet-decoder", new PacketDecoder());
    pipeline.addLast("packet-encoder", new PacketEncoder());
    pipeline.addLast("packet-handler", new ClientHandler(socketChannel, plugin));

    socketChannel.config().setAllocator(PooledByteBufAllocator.DEFAULT);

    plugin.getWebHandler().getChannelGroup().add(socketChannel);
}
 
開發者ID:Thinkofname,項目名稱:ThinkMap,代碼行數:17,代碼來源:ServerChannelInitializer.java

示例12: start

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的package包/類
public void start() {
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup);
        b.channel(NioServerSocketChannel.class);
        b.childHandler(new ChannelInitializer<SocketChannel>() {
            public void initChannel(SocketChannel ch) throws Exception {
                IngotPlayer ingotPlayer = new IngotPlayer(ch);
                ch.pipeline().addLast(new ReadTimeoutHandler(15));
                ch.pipeline().addLast(new VarIntCodec());
                ch.pipeline().addLast(ingotPlayer.packetCodec);
            }
        });
        b.option(ChannelOption.SO_BACKLOG, 16);
        b.childOption(ChannelOption.SO_KEEPALIVE, true);
        future = b.bind(25565);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
開發者ID:IngotPowered,項目名稱:IngotEngine,代碼行數:21,代碼來源:NetManager.java

示例13: initChannel

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
  ChannelPipeline p = ch.pipeline();
  p.addLast(new ReadTimeoutHandler(60, TimeUnit.SECONDS));
  if (sslContext != null) {
    p.addLast(sslContext.newHandler(ch.alloc()));
  }
  p.addLast(new HttpContentCompressor(5));
  p.addLast(new HttpServerCodec());
  p.addLast(new HttpObjectAggregator(1048576));
  p.addLast(new ChunkedWriteHandler());
  if (null != corsConfig) {
    p.addLast(new CorsHandler(corsConfig));
  }
  p.addLast(new WebSocketServerCompressionHandler());
  p.addLast(new WebSocketServerProtocolHandler(webSocketPath, null, true));
  p.addLast(new LaputaServerHandler(null != sslContext, requestProcessor));
}
 
開發者ID:orctom,項目名稱:laputa,代碼行數:19,代碼來源:LaputaServerInitializer.java

示例14: initChannel

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的package包/類
@Override
protected void initChannel(SocketChannel channel) throws Exception {
	channel.pipeline()
			.addLast(new ReadTimeoutHandler(30))
			.addLast("splitter", new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4))
			.addLast(new PacketDecoder())
			.addLast("prepender", new LengthFieldPrepender(4))
			.addLast(new PacketEncoder())
			.addLast(client.getHandler());
	this.client.setChannel(channel);
	System.out.println("Netty client started");
}
 
開發者ID:CentauriCloud,項目名稱:CentauriCloud,代碼行數:13,代碼來源:OpenCloudChannelInitializer.java

示例15: init

import io.netty.handler.timeout.ReadTimeoutHandler; //導入依賴的package包/類
public void init(ChannelPipeline pipeline, String remoteId, boolean discoveryMode, ChannelManager channelManager) {
        this.channelManager = channelManager;
        this.remoteId = remoteId;

        isActive = remoteId != null && !remoteId.isEmpty();

        pipeline.addLast("readTimeoutHandler",
                new ReadTimeoutHandler(config.peerChannelReadTimeout(), TimeUnit.SECONDS));
        pipeline.addLast(stats.tcp);
        pipeline.addLast("handshakeHandler", handshakeHandler);

        this.discoveryMode = discoveryMode;

        if (discoveryMode) {
            // temporary key/nodeId to not accidentally smear our reputation with
            // unexpected disconnect
//            handshakeHandler.generateTempKey();
        }

        handshakeHandler.setRemoteId(remoteId, this);

        messageCodec.setChannel(this);

        msgQueue.setChannel(this);

        p2pHandler.setMsgQueue(msgQueue);
        messageCodec.setP2pMessageFactory(new P2pMessageFactory());

        shhHandler.setMsgQueue(msgQueue);
        messageCodec.setShhMessageFactory(new ShhMessageFactory());

        bzzHandler.setMsgQueue(msgQueue);
        messageCodec.setBzzMessageFactory(new BzzMessageFactory());
    }
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:35,代碼來源:Channel.java


注:本文中的io.netty.handler.timeout.ReadTimeoutHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。