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


Java ChannelHandlerContext.fireChannelActive方法代碼示例

本文整理匯總了Java中io.netty.channel.ChannelHandlerContext.fireChannelActive方法的典型用法代碼示例。如果您正苦於以下問題:Java ChannelHandlerContext.fireChannelActive方法的具體用法?Java ChannelHandlerContext.fireChannelActive怎麽用?Java ChannelHandlerContext.fireChannelActive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.netty.channel.ChannelHandlerContext的用法示例。


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

示例1: channelActive

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
  String remoteAddress =
      ((InetSocketAddress) ctx.channel().remoteAddress()).getAddress().getHostAddress();

  if (blackList.contains(remoteAddress)) {
    ctx.channel().attr(XrpcConstants.IP_BLACK_LIST).set(Boolean.TRUE);
  }

  ctx.fireChannelActive();
}
 
開發者ID:Nordstrom,項目名稱:xrpc,代碼行數:12,代碼來源:BlackListFilter.java

示例2: channelActive

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    channels.add(ctx.channel());
    ctx.fireChannelActive();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:6,代碼來源:ConnectionWatchdog.java

示例3: channelActive

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
public void channelActive(ChannelHandlerContext ctx) {
    log(() -> format(ctx, "CHANNEL_ACTIVE"));
    ctx.fireChannelActive();
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:6,代碼來源:LoggingHandler.java

示例4: channelActive

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
  String remoteAddress =
      ((InetSocketAddress) ctx.channel().remoteAddress()).getAddress().getHostAddress();

  if (!whiteList.contains(remoteAddress)) {
    ctx.channel().attr(XrpcConstants.IP_WHITE_LIST).set(Boolean.FALSE);
  }

  ctx.fireChannelActive();
}
 
開發者ID:Nordstrom,項目名稱:xrpc,代碼行數:12,代碼來源:WhiteListFilter.java

示例5: channelActive

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
  if (ctx.channel().hasAttr(XrpcConstants.XRPC_HARD_RATE_LIMITED)) {
    if (log.isErrorEnabled()) {
      log.error("Channel " + ctx.channel() + " Closed due to Xrpc Hard Rate Limit being reached");
    }

    rateLimits.mark();
    ctx.channel().closeFuture();
  }

  if ((ctx.channel().hasAttr(XrpcConstants.IP_BLACK_LIST))) {
    if (log.isErrorEnabled()) {
      log.error("Channel " + ctx.channel() + " Closed due to Xrpc IP Black List Configuration");
    }
    ctx.channel().closeFuture();
  }

  // This will always be set to False
  if ((ctx.channel().hasAttr(XrpcConstants.IP_WHITE_LIST))) {
    if (log.isErrorEnabled()) {
      log.error(ctx.channel() + " is not a white listed client. Dropping Connection");
    }
    ctx.channel().closeFuture();
  }

  ctx.fireChannelActive();
}
 
開發者ID:Nordstrom,項目名稱:xrpc,代碼行數:29,代碼來源:Firewall.java

示例6: channelActive

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
  connections.inc();

  //TODO(JR): Should this return a 429 or is the current logic of silently dropping the connection sufficient?
  if (maxConnections > 0) {
    if (numConnections.incrementAndGet() > maxConnections) {
      log.info("Accepted connection above limit (%d). Dropping.", maxConnections);
      ctx.channel().close().addListener(ChannelFutureListener.CLOSE);
    }
  }
  ctx.fireChannelActive();
}
 
開發者ID:Nordstrom,項目名稱:xrpc,代碼行數:14,代碼來源:ConnectionLimiter.java

示例7: channelActive

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
public void channelActive(ChannelHandlerContext ctx)
        throws Exception {
    if (timeoutNanos > 0) {
        timeout = timer.newTimeout(new HandshakeTimeoutTask(ctx), 
                                   timeoutNanos, TimeUnit.NANOSECONDS);
    }
    ctx.fireChannelActive();
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:10,代碼來源:HandshakeTimeoutHandler.java

示例8: switchToHttp

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
private void switchToHttp(ChannelHandlerContext ctx) {
    ChannelPipeline p = ctx.pipeline();
    p.addLast(new HttpServerCodec());
    p.addLast(new HttpObjectAggregator(65536));
    p.addLast(new WebSocketServerCompressionHandler());
    p.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, "ws", true));
    p.addLast(new NetoJsonStringToMapWebSocketDecoder());
    p.addLast(new NetoMessageToWebsocketFrameEncoder());
    p.remove(this);

    // 핸들러를 다시 등록 했으므로 이벤트를 전파
    ctx.fireChannelActive();
}
 
開發者ID:veritasware,項目名稱:neto,代碼行數:14,代碼來源:ProtocolUnificationHandler.java

示例9: channelActive

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    Attribute<RequestRecorder> attr = ctx.channel().attr(DovakinConstants.RECORDER_ATTRIBUTE_KEY);
    RequestRecorder var1 = attr.get();
    if(var1 == null){
        RequestRecorder var2 = new RequestRecorder();
        var1 = attr.setIfAbsent(var2);
    }

    ctx.fireChannelActive();
}
 
開發者ID:Dovakin-IO,項目名稱:DovakinMQ,代碼行數:12,代碼來源:MqttHandler.java

示例10: webSocketHandComplete

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
protected void webSocketHandComplete(ChannelHandlerContext ctx) {
	ctx.channel().pipeline().addLast(new WebSocketTextFrameByteBufAdapter());//適配器
	ctx.channel().pipeline().addLast(handler);
	//為新加的handler手動觸發必要事件
	ctx.fireChannelRegistered();
	ctx.fireChannelActive();
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:9,代碼來源:WebSocketServerTextAdapterHandler.java

示例11: webSocketHandComplete

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
protected void webSocketHandComplete(ChannelHandlerContext ctx) {
	ctx.channel().pipeline().addLast(new WebSocketBinaryFrameByteBufAdapter());//適配器
	ctx.channel().pipeline().addLast(handler);
	//為新加的handler手動觸發必要事件
	ctx.fireChannelRegistered();
	ctx.fireChannelActive();
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:9,代碼來源:WebSocketClientBinaryAdapterHandler.java

示例12: userEventTriggered

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
		throws Exception {
	if (evt == WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_COMPLETE) {
		log.log(logLevel,"WebSocket:HANDSHAKE_COMPLETE,pipeline:"+ctx.channel().pipeline().toMap().toString());
		ctx.pipeline().addLast(new WebSocketTextFrameByteBufAdapter());//適配器
		ctx.pipeline().addLast(this.handler);//業務層handler
		//為新加的handler手動觸發必要事件
		ctx.fireChannelRegistered();
		ctx.fireChannelActive();
		log.log(logLevel,"HANDSHAKE_COMPLETED HANDLERS:"+ctx.channel().pipeline().toMap().toString());
	}
	super.userEventTriggered(ctx, evt);
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:15,代碼來源:NettyTextWebSocketClient.java

示例13: channelActive

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
/**
 * 服務端監聽到客戶端活動
 * 
 * @param ctx
 * @throws Exception
 */
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    // 服務端接收到客戶端上線通知
    Channel incoming = ctx.channel();
    logger.debug("MessageServerHandler:" + incoming.remoteAddress() + "在線");
    handlerManager.online(ctx);
    ctx.fireChannelActive();
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:15,代碼來源:MessageServerHandler.java

示例14: channelActive

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
  reqs.mark();

  // Rate Limit per server
  String remoteAddress =
      ((InetSocketAddress) ctx.channel().remoteAddress()).getAddress().getHostAddress();

  if (config.getClientRateLimitOverride().containsKey(remoteAddress)) {
    if (hardLimiterMap.containsKey(remoteAddress)) {
      if (!hardLimiterMap.get(remoteAddress).tryAcquire()) {
        log.debug("Hard Rate limit fired for " + remoteAddress);
        ctx.channel().attr(XrpcConstants.XRPC_HARD_RATE_LIMITED).set(Boolean.TRUE);
      } else if (!softLimiterMap.get(remoteAddress).tryAcquire()) {
        ctx.channel().attr(XrpcConstants.XRPC_SOFT_RATE_LIMITED).set(Boolean.TRUE);
      }
    } else {
      hardLimiterMap.put(
          remoteAddress,
          RateLimiter.create(config.getClientRateLimitOverride().get(remoteAddress).get(1)));
      softLimiterMap.put(
          remoteAddress,
          RateLimiter.create(config.getClientRateLimitOverride().get(remoteAddress).get(0)));
    }

  } else {
    if (!hardLimiterMap
        .get(hardRateLimitHasher.getOne(remoteAddress.getBytes(XrpcConstants.DEFAULT_CHARSET)))
        .tryAcquire()) {
      log.debug("Hard Rate limit fired for " + remoteAddress);
      ctx.channel().attr(XrpcConstants.XRPC_HARD_RATE_LIMITED).set(Boolean.TRUE);
    } else if (!softLimiterMap
        .get(softRateLimitHasher.getOne(remoteAddress.getBytes(XrpcConstants.DEFAULT_CHARSET)))
        .tryAcquire()) {
      ctx.channel().attr(XrpcConstants.XRPC_SOFT_RATE_LIMITED).set(Boolean.TRUE);
    }
  }

  // Global Rate Limiter
  if (!globalHardLimiter.tryAcquire()) {
    log.debug("Global Hard Rate limit fired");
    ctx.channel().attr(XrpcConstants.XRPC_HARD_RATE_LIMITED).set(Boolean.TRUE);

  } else if (!globalSoftLimiter.tryAcquire()) {
    ctx.channel().attr(XrpcConstants.XRPC_SOFT_RATE_LIMITED).set(Boolean.TRUE);
  }

  ctx.fireChannelActive();

  timerMap.put(ctx, timer.time());
}
 
開發者ID:Nordstrom,項目名稱:xrpc,代碼行數:52,代碼來源:ServiceRateLimiter.java

示例15: channelActive

import io.netty.channel.ChannelHandlerContext; //導入方法依賴的package包/類
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
  ctx.pipeline().remove(this);
  ctx.fireChannelActive();
}
 
開發者ID:Nordstrom,項目名稱:xrpc,代碼行數:6,代碼來源:NoOpHandler.java


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