public class MessageProtocol
extends java.lang.Object
The protocol is based on a simple length + data format where two bytes represent the (short) length of the data and the rest is the raw data for the Serializers class.
| Constructor and Description |
|---|
MessageProtocol() |
| Modifier and Type | Method and Description |
|---|---|
int |
addBuffer(java.nio.ByteBuffer buffer)
Adds the specified buffer, extracting the contained messages
and making them available to getMessage().
|
protected void |
createMessage(java.nio.ByteBuffer buffer)
Creates a message from the properly sized byte buffer
and adds it to the messages queue.
|
Message |
getMessage()
Retrieves and removes an extracted message from the accumulated buffer
or returns null if there are no more messages.
|
static java.nio.ByteBuffer |
messageToBuffer(Message message,
java.nio.ByteBuffer target)
Converts a message to a ByteBuffer using the Serializer
and the (short length) + data protocol.
|
public static java.nio.ByteBuffer messageToBuffer(Message message, java.nio.ByteBuffer target)
public Message getMessage()
public int addBuffer(java.nio.ByteBuffer buffer)
protected void createMessage(java.nio.ByteBuffer buffer)