本文整理汇总了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();
}
示例2: channelActive
import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
channels.add(ctx.channel());
ctx.fireChannelActive();
}
示例3: channelActive
import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void channelActive(ChannelHandlerContext ctx) {
log(() -> format(ctx, "CHANNEL_ACTIVE"));
ctx.fireChannelActive();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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());
}
示例15: channelActive
import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
ctx.pipeline().remove(this);
ctx.fireChannelActive();
}