ChannelHandler which encodes message in a stream-like fashion from one message to a Buffer.
Example implementation which encodes Integers to a Buffer.
public class IntegerEncoder extends MessageToByteEncoder<Integer> {
@Override
public void encode(ChannelHandlerContext ctx, Integer msg, Buffer out)
throws Exception {
out.writeInt(msg);
}
}
| Modifier and Type | Field and Description |
|---|---|
| private final TypeParameterMatcher |
| Access | Constructor and Description |
|---|---|
| protected | MessageToByteEncoder()
Create a new instance which will try to detect the types to match out of the type parameter of the class. |
| protected | MessageToByteEncoder(Class<? extends I>
The type of messages to match. outboundMessageType)Create a new instance. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| protected abstract Buffer | allocateBuffer(ChannelHandlerContext
the ctx, I ChannelHandlerContext which this MessageToByteEncoder belongs tothe message to be encoded msg)Allocate a |
| protected abstract void | encode(ChannelHandlerContext
the ctx, I ChannelHandlerContext which this MessageToByteEncoder belongs tothe message to encode msg, Buffer the out)Buffer into which the encoded message will be writtenEncode a message into a |
| public Future | write(ChannelHandlerContext
the ctx, Object ChannelHandlerContext for which the write operation is madethe message to write msg)Overrides default io. |
| matcher | back to summary |
|---|---|
| private final TypeParameterMatcher matcher | |
| MessageToByteEncoder | back to summary |
|---|---|
| protected MessageToByteEncoder() Create a new instance which will try to detect the types to match out of the type parameter of the class. | |
| MessageToByteEncoder | back to summary |
|---|---|
| protected MessageToByteEncoder(Class<? extends I> outboundMessageType) Create a new instance.
| |
| acceptOutboundMessage | back to summary |
|---|---|
| public boolean acceptOutboundMessage(Object msg) throws Exception Returns | |
| allocateBuffer | back to summary |
|---|---|
| protected abstract Buffer allocateBuffer(ChannelHandlerContext ctx, I msg) throws Exception Allocate a
| |
| encode | back to summary |
|---|---|
| protected abstract void encode(ChannelHandlerContext ctx, I msg, Buffer out) throws Exception Encode a message into a
| |
| write | back to summary |
|---|---|
| public Future Overrides default io. Doc from io. Called once a write operation is made. The write operation will write the messages through the
| |