Example usage for io.netty.channel ChannelHandlerContext fireChannelReadComplete

List of usage examples for io.netty.channel ChannelHandlerContext fireChannelReadComplete

Introduction

In this page you can find the example usage for io.netty.channel ChannelHandlerContext fireChannelReadComplete.

Prototype

@Override
    ChannelHandlerContext fireChannelReadComplete();

Source Link

Usage

From source file:divconq.net.ByteToMessageDecoder.java

License:Apache License

@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
    RecyclableArrayList out = RecyclableArrayList.newInstance();
    try {/*from   w ww  . j  a  v a  2 s. c o  m*/
        if (this.cumulation != null) {
            callDecode(ctx, this.cumulation, out);
            decodeLast(ctx, this.cumulation, out);
        } else {
            decodeLast(ctx, Unpooled.EMPTY_BUFFER, out);
        }
    } catch (DecoderException e) {
        throw e;
    } catch (Exception e) {
        throw new DecoderException(e);
    } finally {
        try {
            if (this.cumulation != null) {
                this.cumulation.release();
                this.cumulation = null;
            }
            int size = out.size();
            for (int i = 0; i < size; i++) {
                ctx.fireChannelRead(out.get(i));
            }
            if (size > 0) {
                // Something was read, call fireChannelReadComplete()
                ctx.fireChannelReadComplete();
            }
            ctx.fireChannelInactive();
        } finally {
            // recycle in all cases
            out.recycle();
        }
    }
}

From source file:eu.xworlds.util.raknet.ConnectionHandler.java

License:Open Source License

@Override
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
    for (final RaknetServerListener listener : this.listeners) {
        if (listener.isBlocked(ctx, msg)) {
            ctx.fireChannelReadComplete();
        } else {/* w  w w  .  j av a 2  s .c  o m*/
            ctx.fireChannelRead(msg);
        }
    }
}

From source file:jlibs.wamp4j.netty.NettyWebSocket.java

License:Apache License

@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    if (listener != null)
        listener.onReadComplete(this);
    ctx.fireChannelReadComplete();
}

From source file:org.asynchttpclient.netty.handler.AsyncHttpClientHandler.java

License:Open Source License

@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    if (!isHandledByReactiveStreams(ctx)) {
        ctx.read();/*from ww  w . j a  v a 2 s .c  o m*/
    } else {
        ctx.fireChannelReadComplete();
    }
}

From source file:org.code_house.ebus.netty.codec.OutboundEBusHandler.java

License:Apache License

@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    if (masterHeader != null && masterData != null) {
        // passive get
        int destination = masterHeader.getDestination();
        if (device.getSlave().getAddress() == destination) {
            Command command = new DefaultCommand(masterHeader.getPrimary(), masterHeader.getSecondary());
            Optional<CommandCodec> mapper = codecRegistry.find(command);

            if (mapper.isPresent()) {
                try {
                    PropertyValue value = mapper.get().master().decode(masterData.getData());
                    if (value == null) {
                        ctx.write(new Rejection());
                    } else {
                        // ok, we received data and mapper was able to parse it, try to set value
                        PropertyValue returnValue = device.set(command, value);
                        if (returnValue == null) {
                            ctx.write(new Rejection());
                        }/* ww  w  .  j  a v  a2s  .  c  o  m*/

                        ByteBuffer reply = mapper.get().slave().encode(returnValue);
                        // data should not exceed 16 bytes, so we're safe here
                        ctx.write(new SlaveHeader((short) reply.capacity()));
                        ctx.write(new SlaveData(reply, (byte) 0, (byte) 0));

                    }
                } catch (UnsupportedCommandException | CommandCodecException e) {
                    logger.error("Could not answer slave command", e);
                }
            } else {
                logger.warn("Received slave command {}, but could not find mapping for it. Ignoring", command);
                ctx.write(new Rejection());
            }
        }

        if (device.getMaster().getAddress() == destination) {
            Command command = new DefaultCommand(masterHeader.getPrimary(), masterHeader.getSecondary());
            Optional<CommandCodec> mapper = codecRegistry.find(command);
            if (mapper.isPresent()) {
                try {
                    PropertyValue value = mapper.get().master().decode(masterData.getData());
                    if (value != null && device.receive(command, value)) {
                        ctx.write(new Confirmation()); // ok, we received data and mapper is able to parse it
                    } else {
                        ctx.write(new Rejection());
                    }
                } catch (UnsupportedCommandException | CommandCodecException e) {
                    logger.error("Could not handle master command", e);
                }
            } else {
                logger.warn("Received master command {}, but could not find mapping for it. Ignoring", command);
            }
        }

        ctx.flush();
    }
    masterHeader = null;
    masterData = null;

    ctx.fireChannelReadComplete();
}

From source file:org.jupiter.transport.netty.handler.IdleStateChecker.java

License:Apache License

@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    if (readerIdleTimeMillis > 0 || allIdleTimeMillis > 0) {
        lastReadTime = SystemClock.millisClock().now(); // make hb for firstReaderIdleEvent and firstAllIdleEvent
        reading = false;//from   w w  w.j  a va  2s.c  o  m
    }
    ctx.fireChannelReadComplete();
}

From source file:org.opendaylight.controller.netconf.nettyutil.handler.ssh.virtualsocket.ChannelInputStream.java

License:Open Source License

public void channelReadComplete(ChannelHandlerContext ctx) {
    ctx.fireChannelReadComplete();
}

From source file:org.opendaylight.controller.netconf.util.handler.ssh.virtualsocket.ChannelInputStream.java

License:Open Source License

public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
    ctx.fireChannelReadComplete();
}

From source file:org.opendaylight.ocpjava.protocol.impl.core.DummyDecoder.java

License:Open Source License

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
    LOG.debug("decoding");
    ctx.fireChannelReadComplete();
}

From source file:org.opendaylight.openflowjava.protocol.impl.core.DummyDecoder.java

License:Open Source License

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
    LOGGER.debug("decoding");
    ctx.fireChannelReadComplete();
}