當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。