【问题标题】:How to pause and resume reading with Netty 4?如何使用 Netty 4 暂停和恢复阅读?
【发布时间】:2014-02-27 06:12:26
【问题描述】:

在 Netty 3 中我们可以这样做:

Channel.setReadable(false);
Channel.setReadable(true);

我读过: http://netty.io/news/2012/09/13/4-0-0-alpha4.html

但是使用最新的 Netty 4 版本(4.0.17,http://netty.io/news/2014/02/25/4-0-17-Final.html),此代码无效,因为没有 ChannelHandlerContext#readable

serverChannel.pipeline().firstContext().readable(false);
serverChannel.pipeline().firstContext().readable(true);

【问题讨论】:

    标签: netty


    【解决方案1】:

    用于暂停:

    channel.config.setAutoRead(false)
    

    然后继续:

    channel.config.setAutoRead(true)
    

    【讨论】:

    • 如果你使用一些消息解码器,它不会立即暂停。
    猜你喜欢
    • 2018-02-05
    • 2018-04-08
    • 2016-10-07
    • 1970-01-01
    • 1970-01-01
    • 2020-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多