Package org.kendar.sync.lib.protocol
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,StartRestore,StartRestoreAck,SyncEndAckMessage,SyncEndMessage
Base class for all messages in the sync protocol.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Messagedeserialize(byte[] data) Deserializes a message from a JSON byte array.static <T extends Message>
Tdeserialize(byte[] data, Class<T> clazz) Deserializes a message from a JSON byte array.protected abstract Messagedeserialize(ByteContainer buffer) intabstract MessageTypeGets the message type for this message.intvoidinitialize(int connectionId, UUID sessionId, int packetId) static voidregisterMessageType(Class<? extends Message> clazz) byte[]Serializes this message to a JSON byte array.protected abstract voidserialize(ByteContainer buffer)
-
Constructor Details
-
Message
public Message()
-
-
Method Details
-
registerMessageType
-
deserialize
Deserializes a message from a JSON byte array.- Type Parameters:
T- The type of the message- Parameters:
data- The serialized messageclazz- The class of the message- Returns:
- The deserialized message
-
deserialize
Deserializes a message from a JSON byte array.- Parameters:
data- The serialized message- Returns:
- The deserialized message
-
deserialize
-
getConnectionId
public int getConnectionId() -
getSessionId
-
getPacketId
public int getPacketId() -
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
-
initialize
-