ByteBuf.
A typical setup for TCP/IP would be:
and then you can use an array of bytes instead of aChannelPipelinepipeline = ...; // Decoders pipeline.addLast("frameDecoder", newLengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4)); pipeline.addLast("bytesDecoder", newByteArrayDecoder()); // Encoder pipeline.addLast("frameEncoder", newLengthFieldPrepender(4)); pipeline.addLast("bytesEncoder", newByteArrayEncoder());
ByteBuf
as a message:
void channelRead(ChannelHandlerContext ctx, byte[] bytes) {
...
}
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | encode(ChannelHandlerContext
the ctx, byte[] ChannelHandlerContext which this MessageToMessageEncoder belongs tothe message to encode to an other one msg, List<Object> the out)List into which the encoded msg should be added
needs to do some kind of aggregationImplements abstract io. |
| ByteArrayEncoder | back to summary |
|---|---|
| public ByteArrayEncoder() | |
| encode | back to summary |
|---|---|
| protected void encode(ChannelHandlerContext ctx, byte[] msg, List<Object> out) throws Exception Implements abstract io. Doc from io. Encode from one message to an other. This method will be called for each written message that can be handled by this encoder.
| |