Class DynamicSerializerProtocol

java.lang.Object
org.ngengine.network.protocol.DynamicSerializerProtocol
All Implemented Interfaces:
MessageProtocol

public class DynamicSerializerProtocol extends Object implements MessageProtocol
  • 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

      public void registerSerializer(Class<?> cls, Serializer serializer)
    • registerSerializable

      public void registerSerializable(Class<?>... clss)
    • registerSerializableAnnotation

      public void registerSerializableAnnotation(Class<?> cls)
    • checkIsSerializable

      protected void checkIsSerializable(Class<?> messageClass, boolean messageOnly)
    • getBestSerializerFor

      protected Serializer getBestSerializerFor(Class<?> cls)
    • swapInternals

      protected Object swapInternals(Object obj)
    • 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

      public ByteBuffer toByteBuffer(Message message, ByteBuffer target)
      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 interface MessageProtocol
    • toMessage

      public Message toMessage(ByteBuffer bytes)
      Creates and returns a message from the properly sized byte buffer using com.jme3.network.serializing.Serializer.
      Specified by:
      toMessage in interface MessageProtocol
    • createBuffer

      public MessageBuffer createBuffer()
      Specified by:
      createBuffer in interface MessageProtocol