本文整理汇总了Java中io.netty.handler.traffic.ChannelTrafficShapingHandler类的典型用法代码示例。如果您正苦于以下问题:Java ChannelTrafficShapingHandler类的具体用法?Java ChannelTrafficShapingHandler怎么用?Java ChannelTrafficShapingHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChannelTrafficShapingHandler类属于io.netty.handler.traffic包,在下文中一共展示了ChannelTrafficShapingHandler类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initChannel
import io.netty.handler.traffic.ChannelTrafficShapingHandler; //导入依赖的package包/类
@Override
public void initChannel(SocketChannel ch) throws Exception {
final int kbps = 25;
final int bytesPerSecond = kbps * 125;
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new ChannelTrafficShapingHandler(bytesPerSecond, bytesPerSecond));
pipeline.addLast(new ElysiumDecoder());
pipeline.addLast(new ElysiumConnectionHandler());
}
开发者ID:MoparClassic,项目名称:elysium-single-threaded,代码行数:11,代码来源:ElysiumChannelInitializer.java
示例2: TrafficShapingChannelHandler
import io.netty.handler.traffic.ChannelTrafficShapingHandler; //导入依赖的package包/类
public TrafficShapingChannelHandler(final HandlerConfig handlerConfig)
{
super(handlerConfig);
this.channelTrafficShapingHandler = new ChannelTrafficShapingHandler(
handlerParams.getLong(PARAM_WRITE_LIMIT),
handlerParams.getLong(PARAM_READ_LIMIT)
);
}
开发者ID:tacitknowledge,项目名称:slow-light,代码行数:10,代码来源:TrafficShapingChannelHandler.java
示例3: init
import io.netty.handler.traffic.ChannelTrafficShapingHandler; //导入依赖的package包/类
private void init(Channel channel, HandshakeRequest request, HandlerRegistration handlerReg) {
NettyServerHandlerConfig<Object> cfg = handlerReg.config();
if (cfg.getLoggerCategory() != null) {
log = LoggerFactory.getLogger(cfg.getLoggerCategory());
debug = log.isDebugEnabled();
trace = log.isTraceEnabled();
}
if (debug) {
log.debug("Initialized connection [from={}, protocol={}]", address(), cfg.getProtocol());
}
this.eventLoop = channel.eventLoop();
this.serverHandler = cfg.getHandler();
this.handlerReg = handlerReg;
this.metrics = handlerReg.metrics();
this.codec = request.codec();
// Register this client.
handlerReg.add(this);
if (metrics != null) {
channel.pipeline().addFirst(new ChannelTrafficShapingHandler(0, 0, NettyClient.TRAFFIC_SHAPING_INTERVAL) {
@Override
protected void doAccounting(TrafficCounter counter) {
metrics.onBytesReceived(counter.lastReadBytes());
metrics.onBytesSent(counter.lastWrittenBytes());
}
});
metrics.onConnect();
}
// Accept handshake.
HandshakeAccept accepted = new HandshakeAccept(hbInterval, hbLossThreshold, hbDisabled);
channel.writeAndFlush(accepted).addListener(future -> {
if (channel.isOpen()) {
connectNotified = true;
// Notify on connect.
serverHandler.onConnect(request.payload(), this);
}
}
);
}
开发者ID:hekate-io,项目名称:hekate,代码行数:49,代码来源:NettyServerClient.java
注:本文中的io.netty.handler.traffic.ChannelTrafficShapingHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论