public final class MessageDecoder extends Object
| Constructor and Description |
|---|
MessageDecoder()
Creates a
MessageDecoder instance that will buffer messages internally as they are decoded. |
MessageDecoder(Consumer<Message> messageConsumer)
Creates a
MessageDecoder instance that will publish messages incrementally to the supplied messageConsumer as they are decoded. |
| Modifier and Type | Method and Description |
|---|---|
void |
feed(byte[] bytes) |
void |
feed(byte[] bytes,
int offset,
int length) |
MessageDecoder |
feed(ByteBuffer byteBuffer)
Feed the contents of the given
ByteBuffer into this decoder. |
List<Message> |
getDecodedMessages()
Returns
Message instances that have been decoded since this method was last invoked. |
public MessageDecoder()
MessageDecoder instance that will buffer messages internally as they are decoded. Decoded
messages can be obtained by calling getDecodedMessages().public MessageDecoder(Consumer<Message> messageConsumer)
MessageDecoder instance that will publish messages incrementally to the supplied messageConsumer as they are decoded. The resulting instance does not support the getDecodedMessages()
operation, and will throw an exception if it is invoked.messageConsumer - a function that consumes Message instancespublic List<Message> getDecodedMessages()
Message instances that have been decoded since this method was last invoked. Note that this
method is only supported if this decoder was not configured to use a custom message consumer.public void feed(byte[] bytes)
public void feed(byte[] bytes,
int offset,
int length)
public MessageDecoder feed(ByteBuffer byteBuffer)
ByteBuffer into this decoder. Messages will be incrementally decoded and
buffered or published to the message consumer (depending on configuration).byteBuffer - a ByteBuffer whose entire contents will be read into the decoder's internal bufferMessageDecoder instanceCopyright © 2018. All rights reserved.