|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme3.network.base.MessageProtocol
public class MessageProtocol
Consolidates the conversion of messages to/from byte buffers and provides a rolling message buffer. ByteBuffers can be pushed in and messages will be extracted, accumulated, and available for retrieval. This is not thread safe and is meant to be used within a single message processing thread.
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 Summary | |
---|---|
MessageProtocol()
|
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MessageProtocol()
Method Detail |
---|
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)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |