Example usage for io.netty.handler.stream ChunkedStream readChunk

List of usage examples for io.netty.handler.stream ChunkedStream readChunk

Introduction

In this page you can find the example usage for io.netty.handler.stream ChunkedStream readChunk.

Prototype

@Override
    public ByteBuf readChunk(ByteBufAllocator allocator) throws Exception 

Source Link

Usage

From source file:org.opendaylight.controller.netconf.ssh.threads.Handshaker.java

License:Open Source License

@Override
public void run() {
    ChunkedStream chunkedStream = new ChunkedStream(fromClientIS);
    try {/*from   ww w .  jav a  2 s.com*/
        ByteBuf byteBuf;
        while ((byteBuf = chunkedStream
                .readChunk(channelHandlerContext/*only needed for ByteBuf alloc */)) != null) {
            serverChannel.writeAndFlush(byteBuf);
        }
    } catch (Exception e) {
        logger.warn("Exception", e);
    } finally {
        logger.trace("End of input");
        // tear down connection
        try {
            onEndOfInput.close();
        } catch (Exception e) {
            logger.warn("Ignoring exception while closing socket", e);
        }
    }
}