Package org.ngengine.network.protocol
Class DynamicSerializerProtocol
java.lang.Object
org.ngengine.network.protocol.DynamicSerializerProtocol
- All Implemented Interfaces:
MessageProtocol
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
-
Constructor Summary
ConstructorsConstructorDescriptionDynamicSerializerProtocol
(boolean spidermonkeyCompatible) Creates a new DynamicSerializerProtocol that automatically handles class registration and serialization. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkIsSerializable
(Class<?> messageClass, boolean messageOnly) protected <T> T
deserialize
(ByteBuffer bytes, Class<?> expectedClass, boolean messageOnly) protected Serializer
getBestSerializerFor
(Class<?> cls) protected void
registerDefaultSerializables
(boolean spidermonkeyCompatible) protected void
void
registerSerializable
(Class<?>... clss) void
registerSerializableAnnotation
(Class<?> cls) void
registerSerializer
(Class<?> cls, Serializer serializer) protected void
serialize
(Object obj, GrowableByteBuffer buffer, boolean messageOnly) void
setForceStaticBuffer
(boolean forceStatic) Force use of static buffer (old behavior) even if the serialize supports dynamic buffers.protected Object
swapInternals
(Object obj) 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.
-
Constructor Details
-
DynamicSerializerProtocol
public DynamicSerializerProtocol(boolean spidermonkeyCompatible) Creates a new DynamicSerializerProtocol that automatically handles class registration and serialization.- Parameters:
strict
- set if the serializer should be strict (safer) or unstrict (FAFO)
-
-
Method Details
-
registerDefaultSerializables
protected void registerDefaultSerializables(boolean spidermonkeyCompatible) -
registerDefaultSerializers
protected void registerDefaultSerializers() -
setForceStaticBuffer
public void setForceStaticBuffer(boolean forceStatic) Force use of static buffer (old behavior) even if the serialize supports dynamic buffers. Used mostly for debugging.- Parameters:
forceStatic
-
-
registerSerializer
-
registerSerializable
-
registerSerializableAnnotation
-
checkIsSerializable
-
getBestSerializerFor
-
swapInternals
-
serialize
protected void serialize(Object obj, GrowableByteBuffer buffer, boolean messageOnly) throws IOException - Throws:
IOException
-
deserialize
protected <T> T deserialize(ByteBuffer bytes, Class<?> expectedClass, boolean messageOnly) throws IOException - Throws:
IOException
-
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:
toByteBuffer
in interfaceMessageProtocol
-
toMessage
Creates and returns a message from the properly sized byte buffer using com.jme3.network.serializing.Serializer.- Specified by:
toMessage
in interfaceMessageProtocol
-
createBuffer
- Specified by:
createBuffer
in interfaceMessageProtocol
-