Class ApplicationMessage
- java.lang.Object
-
- org.drasyl.peer.connection.message.AbstractMessage
-
- org.drasyl.peer.connection.message.RelayableMessage
-
- org.drasyl.peer.connection.message.ApplicationMessage
-
- All Implemented Interfaces:
Message
,RequestMessage
- Direct Known Subclasses:
ChunkedMessage
public class ApplicationMessage extends RelayableMessage implements RequestMessage
A message that is sent by an application running on drasyl.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,String>
headers
protected byte[]
payload
protected CompressedPublicKey
sender
-
Fields inherited from class org.drasyl.peer.connection.message.RelayableMessage
hopCount, recipient
-
Fields inherited from class org.drasyl.peer.connection.message.AbstractMessage
id
-
-
Constructor Summary
Constructors Constructor Description ApplicationMessage(CompressedPublicKey sender, CompressedPublicKey recipient, byte[] payload)
Creates a new message.ApplicationMessage(CompressedPublicKey sender, CompressedPublicKey recipient, Map<String,String> headers, byte[] payload)
Creates a new message.ApplicationMessage(MessageId id, CompressedPublicKey sender, CompressedPublicKey recipient, byte[] payload, short hopCount)
ApplicationMessage(MessageId id, CompressedPublicKey sender, CompressedPublicKey recipient, Map<String,String> headers, byte[] payload, short hopCount)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
String
getHeader(String name)
Returns the value of header with namename
, ornull
if this header does not exist.Map<String,String>
getHeaders()
byte[]
getPayload()
CompressedPublicKey
getSender()
int
hashCode()
io.netty.buffer.ByteBuf
payloadAsByteBuf()
String
toString()
-
Methods inherited from class org.drasyl.peer.connection.message.RelayableMessage
getHopCount, getRecipient, incrementHopCount
-
Methods inherited from class org.drasyl.peer.connection.message.AbstractMessage
getId
-
-
-
-
Field Detail
-
sender
protected final CompressedPublicKey sender
-
payload
protected final byte[] payload
-
-
Constructor Detail
-
ApplicationMessage
public ApplicationMessage(MessageId id, CompressedPublicKey sender, CompressedPublicKey recipient, byte[] payload, short hopCount)
-
ApplicationMessage
public ApplicationMessage(MessageId id, CompressedPublicKey sender, CompressedPublicKey recipient, Map<String,String> headers, byte[] payload, short hopCount)
-
ApplicationMessage
public ApplicationMessage(CompressedPublicKey sender, CompressedPublicKey recipient, Map<String,String> headers, byte[] payload)
Creates a new message.- Parameters:
sender
- The senderrecipient
- The recipientpayload
- The data to be sent
-
ApplicationMessage
public ApplicationMessage(CompressedPublicKey sender, CompressedPublicKey recipient, byte[] payload)
Creates a new message.- Parameters:
sender
- The senderrecipient
- The recipientpayload
- The data to be sent
-
-
Method Detail
-
getSender
public CompressedPublicKey getSender()
-
getHeader
public String getHeader(String name)
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()
- Overrides:
hashCode
in classRelayableMessage
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classRelayableMessage
-
toString
public String toString()
- Overrides:
toString
in classAbstractMessage
-
-