当前位置: 首页>>代码示例>>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;未经允许,请勿转载。