- Encodes the requested {@link String} into a {@link ByteBuf}.
- A typical setup for a text-based line protocol in a TCP/IP socket would be:
-
- {@link ChannelPipeline} pipeline = ...;
-
- // Decoders
- pipeline.addLast("frameDecoder", new {@link LineBasedFrameDecoder}(80));
- pipeline.addLast("stringDecoder", new {@link StringDecoder}(CharsetUtil.UTF_8));
-
- // Encoder
- pipeline.addLast("stringEncoder", new {@link StringEncoder}(CharsetUtil.UTF_8));
-
- and then you can use a {@link String} instead of a {@link ByteBuf}
- as a message:
-
- void channelRead({@link ChannelHandlerContext} ctx, {@link String} msg) {
- ch.write("Did you say '" + msg + "'?\n");
- }
-
-
-