Interface RemoteMessage
- All Known Subinterfaces:
FullReadMessage<T>
,PartialReadMessage
- All Known Implementing Classes:
AcknowledgementMessage
,ApplicationMessage
,ArmedProtocolMessage
,HelloMessage
,UnarmedProtocolMessage
,UniteMessage
Describes a message that is sent to remote peers via UDP/TCP.
Each message is made up of several parts:
- A fixed-length magic number used to identity if message belongs to the drasyl protocol.
- A fixed-length public header with partly authenticated information required for routing the message to its destination.
- An armed-dependent fixed-length private header with encrypted information only readable by the recipient.
- A variable-length body with message type specific (encrypted) information.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Magic Number (4 Bytes) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |PublicHeader
(PublicHeader.LENGTH
Bytes) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |PrivateHeader
(PrivateHeader.LENGTH
or | |PrivateHeader.ARMED_LENGTH
Bytes) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / Body (HelloMessage
,ApplicationMessage
, / \AcknowledgementMessage
, orUniteMessage
) \ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionio.netty.buffer.ByteBuf
encodeMessage
(io.netty.buffer.ByteBufAllocator alloc) Writes this message to a buffer created byalloc
.boolean
getArmed()
int
int
getNonce()
Returns a copy of this message with incrementedgetHopCount()
.
-
Field Details
-
MAGIC_NUMBER
static final int MAGIC_NUMBER- See Also:
-
MAGIC_NUMBER_LEN
static final int MAGIC_NUMBER_LEN- See Also:
-
-
Method Details
-
getNonce
Nonce getNonce() -
getNetworkId
int getNetworkId() -
getSender
DrasylAddress getSender() -
getProofOfWork
ProofOfWork getProofOfWork() -
getRecipient
DrasylAddress getRecipient() -
getHopCount
HopCount getHopCount() -
getArmed
boolean getArmed() -
incrementHopCount
RemoteMessage incrementHopCount()Returns a copy of this message with incrementedgetHopCount()
.- Returns:
- message with incremented hop count
- Throws:
IllegalStateException
- if incremented hop count is greater thenHopCount.MAX_HOP_COUNT
-
encodeMessage
io.netty.buffer.ByteBuf encodeMessage(io.netty.buffer.ByteBufAllocator alloc) Writes this message to a buffer created byalloc
.- Parameters:
out
- writes this envelope to a buffer created by the given allocator- Returns:
- the buffer written to
-
getLength
int getLength()
-