Example usage for io.netty.channel ChannelPipeline writeAndFlush

List of usage examples for io.netty.channel ChannelPipeline writeAndFlush

Introduction

In this page you can find the example usage for io.netty.channel ChannelPipeline writeAndFlush.

Prototype

ChannelFuture writeAndFlush(Object msg);

Source Link

Document

Shortcut for call #write(Object) and #flush() .

Usage

From source file:com.tesora.dve.server.connectionmanager.loaddata.MSPLoadDataDecoder.java

License:Open Source License

private void sendResponseAndRemove(ChannelHandlerContext ctx) {
    ChannelPipeline pipeline = ctx.pipeline();
    try {//w  w  w .j a v a 2s  .  com
        pauseInput(ctx);//stop incoming packets so we don't process the next request, we'll resume in the removal callback.

        MyMessage response;

        if (encounteredError == null)
            response = createLoadDataEOFMsg(myLoadDataInfileContext);
        else
            response = new MyErrorResponse(new PEException(encounteredError));

        pipeline.writeAndFlush(response);
        pipeline.remove(this);

    } catch (Exception e) {
        ctx.channel().close();
    }
}