Class ApplicationMessage
java.lang.Object
org.drasyl.peer.connection.message.ApplicationMessage
- All Implemented Interfaces:
Message
,RequestMessage
A message that is sent by an application running on drasyl.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected short
protected final MessageId
protected final int
protected final byte[]
protected final ProofOfWork
protected final CompressedPublicKey
protected final CompressedPublicKey
protected final String
-
Constructor Summary
ConstructorsConstructorDescriptionApplicationMessage
(int networkId, CompressedPublicKey sender, ProofOfWork proofOfWork, CompressedPublicKey recipient, byte[] payload) Creates a new message.ApplicationMessage
(int networkId, CompressedPublicKey sender, ProofOfWork proofOfWork, CompressedPublicKey recipient, Map<String, String> headers, byte[] payload) Creates a new message.ApplicationMessage
(MessageId id, int networkId, String userAgent, CompressedPublicKey sender, ProofOfWork proofOfWork, CompressedPublicKey recipient, short hopCount, byte[] payload) ApplicationMessage
(MessageId id, int networkId, CompressedPublicKey sender, ProofOfWork proofOfWork, CompressedPublicKey recipient, short hopCount, byte[] payload) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the value of header with namename
, ornull
if this header does not exist.short
Returns this message's hop count.getId()
Returns the unique id of this message.int
Returns the network the sender belongs to.byte[]
Returns this message sender's proof of work.Returns this message's recipient.Returns this message's sender.Returns the user agent of the sender's node.int
hashCode()
void
Increases the message's hop count.io.netty.buffer.ByteBuf
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.drasyl.peer.connection.message.Message
getHopCount, getId, getNetworkId, getProofOfWork, getRecipient, getSender, getUserAgent, incrementHopCount
-
Field Details
-
headers
-
payload
protected final byte[] payload -
defaultUserAgentGenerator
-
userAgentGenerator
-
id
-
userAgent
-
networkId
protected final int networkId -
sender
-
proofOfWork
-
recipient
-
hopCount
protected short hopCount
-
-
Constructor Details
-
ApplicationMessage
public ApplicationMessage(MessageId id, int networkId, String userAgent, CompressedPublicKey sender, ProofOfWork proofOfWork, CompressedPublicKey recipient, short hopCount, byte[] payload) -
ApplicationMessage
public ApplicationMessage(MessageId id, int networkId, CompressedPublicKey sender, ProofOfWork proofOfWork, CompressedPublicKey recipient, short hopCount, byte[] payload) -
ApplicationMessage
public ApplicationMessage(int networkId, CompressedPublicKey sender, ProofOfWork proofOfWork, CompressedPublicKey recipient, Map<String, String> headers, byte[] payload) Creates a new message.- Parameters:
networkId
- the network the sender belongs tosender
- the senderproofOfWork
- the sender's proof of workrecipient
- the recipientpayload
- the data to be sent
-
ApplicationMessage
public ApplicationMessage(int networkId, CompressedPublicKey sender, ProofOfWork proofOfWork, CompressedPublicKey recipient, byte[] payload) Creates a new message.- Parameters:
networkId
- the network the sender belongs tosender
- the senderproofOfWork
- the sender's proof of workrecipient
- the recipientpayload
- the data to be sent
-
-
Method Details
-
getHeaders
-
getHeader
Returns the value of header with namename
, ornull
if this header does not exist. Returnsbyte[].class.getName()
if the header does not contain a value forname =
ObjectHolder.CLASS_KEY_NAME
.- Returns:
- value of header with name
name
, ornull
if this header does not exist
-
getPayload
public byte[] getPayload() -
payloadAsByteBuf
public io.netty.buffer.ByteBuf payloadAsByteBuf()- Returns:
- a ByteBuf that wraps the underling payload byte array
-
hashCode
public int hashCode() -
equals
-
toString
-
getId
Description copied from interface:Message
Returns the unique id of this message. Each message generates a random id when it is created. -
getUserAgent
Description copied from interface:Message
Returns the user agent of the sender's node.- Specified by:
getUserAgent
in interfaceMessage
- Returns:
- the user agent of the sender's node.
-
getNetworkId
public int getNetworkId()Description copied from interface:Message
Returns the network the sender belongs to.- Specified by:
getNetworkId
in interfaceMessage
- Returns:
- the network the sender belongs to
-
getSender
Description copied from interface:Message
Returns this message's sender. -
getProofOfWork
Description copied from interface:Message
Returns this message sender's proof of work.- Specified by:
getProofOfWork
in interfaceMessage
- Returns:
- this message sender's proof of work.
-
getRecipient
Description copied from interface:Message
Returns this message's recipient.- Specified by:
getRecipient
in interfaceMessage
- Returns:
- this message's recipient.
-
getHopCount
public short getHopCount()Description copied from interface:Message
Returns this message's hop count. Starts at 0 and is incremented every time it is sent. Once the message reaches the limit defined in configdrasyl.message.hop-limit
it will be dropped.- Specified by:
getHopCount
in interfaceMessage
- Returns:
- this message's hop count.
-
incrementHopCount
public void incrementHopCount()Description copied from interface:Message
Increases the message's hop count.- Specified by:
incrementHopCount
in interfaceMessage
-