当前位置: 首页>>代码示例>>Java>>正文


Java Channel.eventLoop方法代码示例

本文整理汇总了Java中io.netty.channel.Channel.eventLoop方法的典型用法代码示例。如果您正苦于以下问题:Java Channel.eventLoop方法的具体用法?Java Channel.eventLoop怎么用?Java Channel.eventLoop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.channel.Channel的用法示例。


在下文中一共展示了Channel.eventLoop方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: XrpcRequest

import io.netty.channel.Channel; //导入方法依赖的package包/类
public XrpcRequest(FullHttpRequest request, Map<String, String> groups, Channel channel) {
  this.h1Request = request;
  this.h2Headers = null;
  this.groups = groups;
  this.upstreamChannel = channel;
  this.alloc = channel.alloc();
  this.eventLoop = channel.eventLoop();
  this.streamId = -1;
}
 
开发者ID:Nordstrom,项目名称:xrpc,代码行数:10,代码来源:XrpcRequest.java

示例2: pauseReceiver

import io.netty.channel.Channel; //导入方法依赖的package包/类
private void pauseReceiver(boolean pause, Consumer<NetworkEndpoint<T>> callback) {
    ChannelContext localCtx = this.channelCtx;

    if (localCtx != null) {
        if (debug) {
            if (pause) {
                log.debug("Pausing outbound receiver [to={}]", id());
            } else {
                log.debug("Resuming outbound receiver [to={}]", id());
            }
        }

        Channel channel = localCtx.channel();
        EventLoop eventLoop = channel.eventLoop();

        if (eventLoop.inEventLoop()) {
            channel.config().setAutoRead(!pause);

            notifyOnReceivePause(pause, callback, channel);
        } else {
            eventLoop.execute(() -> {
                channel.config().setAutoRead(!pause);

                notifyOnReceivePause(pause, callback, channel);
            });
        }
    } else if (callback != null) {
        callback.accept(this);
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:31,代码来源:NettyClient.java

示例3: pauseReceiver

import io.netty.channel.Channel; //导入方法依赖的package包/类
private void pauseReceiver(boolean pause, Consumer<NetworkEndpoint<Object>> callback) {
    ChannelHandlerContext localCtx = this.handlerCtx;

    if (localCtx != null) {
        if (debug) {
            if (pause) {
                log.debug("Pausing inbound receiver [from={}, protocol={}]", address(), protocol);
            } else {
                log.debug("Resuming Pausing inbound receiver [from={}, protocol={}]", address(), protocol);
            }
        }

        Channel channel = localCtx.channel();
        EventLoop eventLoop = channel.eventLoop();

        if (eventLoop.inEventLoop()) {
            channel.config().setAutoRead(!pause);

            notifyOnReceivePause(pause, callback, channel);
        } else {
            eventLoop.execute(() -> {
                channel.config().setAutoRead(!pause);

                notifyOnReceivePause(pause, callback, channel);
            });
        }
    } else if (callback != null) {
        callback.accept(this);
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:31,代码来源:NettyServerClient.java

示例4: init

import io.netty.channel.Channel; //导入方法依赖的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.channel.Channel.eventLoop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。