Example usage for io.netty.channel ChannelConfig setAutoRead

List of usage examples for io.netty.channel ChannelConfig setAutoRead

Introduction

In this page you can find the example usage for io.netty.channel ChannelConfig setAutoRead.

Prototype

ChannelConfig setAutoRead(boolean autoRead);

Source Link

Document

Sets if ChannelHandlerContext#read() will be invoked automatically so that a user application doesn't need to call it at all.

Usage

From source file:org.jooby.internal.netty.NettyWebSocket.java

License:Apache License

@Override
public void resume() {
    ChannelConfig config = ctx.channel().config();
    if (!config.isAutoRead()) {
        config.setAutoRead(true);
    }/* w  w w . j  ava  2s  .c om*/
}

From source file:org.jooby.internal.netty.NettyWebSocket.java

License:Apache License

@Override
public void pause() {
    ChannelConfig config = ctx.channel().config();
    if (config.isAutoRead()) {
        config.setAutoRead(false);
    }// w w  w . j av  a2 s.c  o m
}

From source file:org.jupiter.transport.netty.handler.acceptor.AcceptorHandler.java

License:Apache License

@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
    Channel ch = ctx.channel();/*from www .j a  v a2s. c  om*/
    ChannelConfig config = ch.config();

    // ?: ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK
    // ?: ChannelOption.WRITE_BUFFER_LOW_WATER_MARK
    if (!ch.isWritable()) {
        // ?channel(OutboundBuffer)?WRITE_BUFFER_HIGH_WATER_MARK
        if (logger.isWarnEnabled()) {
            logger.warn(
                    "{} is not writable, high water mask: {}, the number of flushed entries that are not written yet: {}.",
                    ch, config.getWriteBufferHighWaterMark(), ch.unsafe().outboundBuffer().size());
        }

        config.setAutoRead(false);
    } else {
        // ??OutboundBuffer?WRITE_BUFFER_LOW_WATER_MARK
        if (logger.isWarnEnabled()) {
            logger.warn(
                    "{} is writable(rehabilitate), low water mask: {}, the number of flushed entries that are not written yet: {}.",
                    ch, config.getWriteBufferLowWaterMark(), ch.unsafe().outboundBuffer().size());
        }

        config.setAutoRead(true);
    }
}