Class ApplicationMessage

java.lang.Object
org.drasyl.peer.connection.message.ApplicationMessage
All Implemented Interfaces:
Message, RequestMessage

public class ApplicationMessage extends Object implements RequestMessage
A message that is sent by an application running on drasyl.
  • Field Details

    • headers

      protected final Map<String,String> headers
    • payload

      protected final byte[] payload
    • defaultUserAgentGenerator

      public static final Supplier<String> defaultUserAgentGenerator
    • userAgentGenerator

      public static Supplier<String> userAgentGenerator
    • id

      protected final MessageId id
    • userAgent

      protected final String userAgent
    • networkId

      protected final int networkId
    • sender

      protected final CompressedPublicKey sender
    • proofOfWork

      protected final ProofOfWork proofOfWork
    • recipient

      protected final CompressedPublicKey recipient
    • hopCount

      protected short hopCount
  • Constructor Details

  • Method Details

    • getHeaders

      public Map<String,String> getHeaders()
    • getHeader

      public String getHeader(String name)
      Returns the value of header with name name, or null if this header does not exist. Returns byte[].class.getName() if the header does not contain a value for name = ObjectHolder.CLASS_KEY_NAME.
      Returns:
      value of header with name name, or null 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

      public boolean equals(Object o)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getId

      public MessageId getId()
      Description copied from interface: Message
      Returns the unique id of this message. Each message generates a random id when it is created.
      Specified by:
      getId in interface Message
      Returns:
      the unique id of this message. Each message generates a random id when it is created.
    • getUserAgent

      public String getUserAgent()
      Description copied from interface: Message
      Returns the user agent of the sender's node.
      Specified by:
      getUserAgent in interface Message
      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 interface Message
      Returns:
      the network the sender belongs to
    • getSender

      public CompressedPublicKey getSender()
      Description copied from interface: Message
      Returns this message's sender.
      Specified by:
      getSender in interface Message
      Returns:
      this message's sender.
    • getProofOfWork

      public ProofOfWork getProofOfWork()
      Description copied from interface: Message
      Returns this message sender's proof of work.
      Specified by:
      getProofOfWork in interface Message
      Returns:
      this message sender's proof of work.
    • getRecipient

      public CompressedPublicKey getRecipient()
      Description copied from interface: Message
      Returns this message's recipient.
      Specified by:
      getRecipient in interface Message
      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 config drasyl.message.hop-limit it will be dropped.
      Specified by:
      getHopCount in interface Message
      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 interface Message