Class Message

java.lang.Object
org.kendar.sync.lib.protocol.Message
Direct Known Subclasses:
ConnectMessage, ConnectResponseMessage, ErrorMessage, FileDataAck, FileDataMessage, FileDescriptorAckMessage, FileDescriptorMessage, FileEndAckMessage, FileEndMessage, FileListMessage, FileListResponseMessage, FileSyncMessage, FileSyncMessageAck, KeepAlive, StartRestore, StartRestoreAck, SyncEndAckMessage, SyncEndMessage

public abstract class Message extends Object
Base class for all messages in the sync protocol.
  • Constructor Details

    • Message

      public Message()
  • Method Details

    • deserialize

      public static <T extends Message> T deserialize(byte[] data, Class<T> clazz)
      Deserializes a message from a JSON byte array.
      Type Parameters:
      T - The type of the message
      Parameters:
      data - The serialized message
      clazz - The class of the message
      Returns:
      The deserialized message
    • deserialize

      public static Message deserialize(byte[] data)
      Deserializes a message from a JSON byte array.
      Parameters:
      data - The serialized message
      Returns:
      The deserialized message
    • deserialize

      protected abstract Message deserialize(ByteContainer buffer)
    • getConnectionId

      public int getConnectionId()
    • getSessionId

      public UUID getSessionId()
    • getPacketId

      public int getPacketId()
    • getMessageType

      public abstract MessageType getMessageType()
      Gets the message type for this message.
      Returns:
      The message type
    • serialize

      public byte[] serialize()
      Serializes this message to a JSON byte array.
      Returns:
      The serialized message
    • serialize

      protected abstract void serialize(ByteContainer buffer)
    • initialize

      public void initialize(int connectionId, UUID sessionId, int packetId)