Class SerializerMessageProtocol
java.lang.Object
com.jme3.network.base.protocol.SerializerMessageProtocol
- All Implemented Interfaces:
MessageProtocol
Implements a MessageProtocol providing message serializer/deserialization
based on the built-in Serializer code.
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.
- Author:
- Paul Speed
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a rolling message buffer compatible with this protocol.toByteBuffer(Message message, ByteBuffer target) Converts a message to a ByteBuffer using the com.jme3.network.serializing.Serializer and the (short length) + data protocol.toMessage(ByteBuffer bytes) Creates and returns a message from the properly sized byte buffer using com.jme3.network.serializing.Serializer.
-
Field Details
-
MAX_MESSAGE_SIZE
public static final int MAX_MESSAGE_SIZE- See Also:
-
-
Constructor Details
-
SerializerMessageProtocol
public SerializerMessageProtocol()Creates a serializer-backed message protocol.
-
-
Method Details
-
toByteBuffer
Converts a message to a ByteBuffer using the com.jme3.network.serializing.Serializer and the (short length) + data protocol. If target is null then a 32k byte buffer will be created and filled.- Specified by:
toByteBufferin interfaceMessageProtocol- Parameters:
message- the message to serializetarget- the optional target buffer to reuse- Returns:
- a buffer containing the serialized message
-
toMessage
Creates and returns a message from the properly sized byte buffer using com.jme3.network.serializing.Serializer.- Specified by:
toMessagein interfaceMessageProtocol- Parameters:
bytes- the serialized message bytes- Returns:
- the decoded message
-
createBuffer
Description copied from interface:MessageProtocolCreates a rolling message buffer compatible with this protocol.- Specified by:
createBufferin interfaceMessageProtocol- Returns:
- a new message buffer
-