Class ChunkedMessage
- java.lang.Object
-
- org.drasyl.peer.connection.message.AbstractMessage
-
- org.drasyl.peer.connection.message.RelayableMessage
-
- org.drasyl.peer.connection.message.ApplicationMessage
-
- org.drasyl.peer.connection.message.ChunkedMessage
-
- All Implemented Interfaces:
Message
,RequestMessage
public class ChunkedMessage extends ApplicationMessage
Models a chunked application message that can be composed by the recipient to one final message.
A chunked message sequence looks like the follow:
1. ChunkedMessage withRelayableMessage.recipient
,ApplicationMessage.sender
,RelayableMessage.hopCount
,AbstractMessage.id
,ApplicationMessage.payload
,contentLength
andchecksum
2. - (n-1). ChunkedMessageRelayableMessage.recipient
,ApplicationMessage.sender
,RelayableMessage.hopCount
,AbstractMessage.id
andApplicationMessage.payload
n. ChunkedMessageRelayableMessage.recipient
,ApplicationMessage.sender
,RelayableMessage.hopCount
,AbstractMessage.id
andpayload := new byte[]{}
-
-
Field Summary
-
Fields inherited from class org.drasyl.peer.connection.message.ApplicationMessage
headers, payload, sender
-
Fields inherited from class org.drasyl.peer.connection.message.RelayableMessage
hopCount, recipient
-
Fields inherited from class org.drasyl.peer.connection.message.AbstractMessage
id
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ChunkedMessage
createFirstChunk(CompressedPublicKey sender, CompressedPublicKey recipient, MessageId msgID, byte[] payload, int contentLength, String checksum)
Creates the initial chunked message.static ChunkedMessage
createFollowChunk(CompressedPublicKey sender, CompressedPublicKey recipient, MessageId msgID, byte[] payload)
Creates a follow chunked message.static ChunkedMessage
createLastChunk(CompressedPublicKey sender, CompressedPublicKey recipient, MessageId msgID)
Creates the last chunked message.boolean
equals(Object o)
String
getChecksum()
int
getContentLength()
int
hashCode()
boolean
isInitialChunk()
String
toString()
-
Methods inherited from class org.drasyl.peer.connection.message.ApplicationMessage
getHeader, getHeaders, getPayload, getSender, payloadAsByteBuf
-
Methods inherited from class org.drasyl.peer.connection.message.RelayableMessage
getHopCount, getRecipient, incrementHopCount
-
Methods inherited from class org.drasyl.peer.connection.message.AbstractMessage
getId
-
-
-
-
Method Detail
-
getContentLength
public int getContentLength()
-
getChecksum
public String getChecksum()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classApplicationMessage
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classApplicationMessage
-
toString
public String toString()
- Overrides:
toString
in classApplicationMessage
-
isInitialChunk
public boolean isInitialChunk()
-
createFirstChunk
public static ChunkedMessage createFirstChunk(CompressedPublicKey sender, CompressedPublicKey recipient, MessageId msgID, byte[] payload, int contentLength, String checksum)
Creates the initial chunked message.- Parameters:
sender
- the sender of the messagerecipient
- the recipient of the messagemsgID
- the id of this message (must be the same as composed message)payload
- the chunkcontentLength
- the final content lengthchecksum
- the final checksum
-
createFollowChunk
public static ChunkedMessage createFollowChunk(CompressedPublicKey sender, CompressedPublicKey recipient, MessageId msgID, byte[] payload)
Creates a follow chunked message.- Parameters:
sender
- the sender of the messagerecipient
- the recipient of the messagemsgID
- the id of this message (must be the same as the initial chunk)payload
- the chunk
-
createLastChunk
public static ChunkedMessage createLastChunk(CompressedPublicKey sender, CompressedPublicKey recipient, MessageId msgID)
Creates the last chunked message.- Parameters:
sender
- the sender of the messagerecipient
- the recipient of the messagemsgID
- the id of this message (must be the same as the initial chunk)
-
-