Class Message

java.lang.Object
convex.net.message.Message
Direct Known Subclasses:
MessageLocal, MessageRemote

public abstract class Message extends Object

Class representing a message to / from a specific connection

Encapsulates both message content and a means of return communication

.

This class is an immutable data structure, but NOT a representable on-chain data structure, as it is part of the peer protocol layer.

Messages may contain a Payload, which can be any Data Object.

  • Field Details

    • payload

      protected final ACell payload
    • type

      protected final MessageType type
  • Constructor Details

  • Method Details

    • create

      public static MessageRemote create(Connection peerConnection, MessageType type, ACell payload)
    • create

      public static MessageRemote create(Connection peerConnection, ACell o)
    • createData

      public static Message createData(ACell o)
    • createBelief

      public static Message createBelief(SignedData<Belief> sb)
    • createChallenge

      public static Message createChallenge(SignedData<ACell> challenge)
    • createResponse

      public static Message createResponse(SignedData<ACell> response)
    • createGoodBye

      public static Message createGoodBye(SignedData<ACell> peerKey)
    • getPayload

      public <T extends ACell> T getPayload()
    • getType

      public MessageType getType()
    • getErrorCode

      public ACell getErrorCode()
    • toString

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

      public CVMLong getID()
      Gets the message ID for correlation, assuming this message type supports IDs.
      Returns:
      Message ID, or null if the message type does not use message IDs
    • reportResult

      public abstract boolean reportResult(Result res)
      Reports a result back to the originator of the message. Will set a Result ID if necessary.
      Parameters:
      res - Result record
      Returns:
      True if reported successfully, false otherwise
    • reportResult

      public abstract boolean reportResult(CVMLong id, ACell reply)
      Report a result for a given message ID
      Parameters:
      id - Message ID
      reply - Value for result
      Returns:
      True if reported successfully, false otherwise
    • getOriginString

      public abstract String getOriginString()
      Gets a String identifying the origin of the message. Used for logging.
      Returns:
      String representing message origin
    • sendData

      public abstract boolean sendData(ACell data)
      Sends a cell of data to the connected Peer
      Parameters:
      data - Data to send
      Returns:
      true if data sent, false otherwise
    • sendMissingData

      public abstract boolean sendMissingData(Hash hash)
      Sends a missing data request to the connected Peer
      Parameters:
      hash - HAsh of missing data
      Returns:
      True if request sent, false otherwise