Example usage for io.netty.handler.codec.string LineEncoder LineEncoder

List of usage examples for io.netty.handler.codec.string LineEncoder LineEncoder

Introduction

In this page you can find the example usage for io.netty.handler.codec.string LineEncoder LineEncoder.

Prototype

public LineEncoder(LineSeparator lineSeparator, Charset charset) 

Source Link

Document

Creates a new instance with the specified line separator and character set.

Usage

From source file:diskCacheV111.doors.NettyLineBasedDoor.java

License:Open Source License

@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
    ChannelPipeline pipeline = ctx.pipeline();
    String self = ctx.name();//w w  w.j ava 2 s.  c  o m

    if (expectProxyProtocol) {
        pipeline.addBefore("door", "haproxy", new HAProxyMessageDecoder());
    }

    // Decoders
    pipeline.addBefore(self, "frameDecoder", new LineBasedFrameDecoder(KiB.toBytes(64)));
    pipeline.addBefore(self, "stringDecoder", new StringDecoder(charset));

    // Encoder
    pipeline.addBefore(self, "lineEncoder", new LineEncoder(lineSeparator, charset));

    pipeline.addBefore(self, "logger", new LoggingHandler());
}