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

    • log

      protected static final org.slf4j.Logger log
    • payload

      protected ACell payload
    • messageData

      protected Blob messageData
    • type

      protected MessageType type
  • Constructor Details

  • Method Details

    • create

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

      public static Message createData(ACell o)
    • createMissingData

      public static Message createMissingData(Hash missingHash)
    • createMissingData

      public static Message createMissingData(CVMLong id, Hash... missingHashes)
    • createBelief

      public static Message createBelief(Belief belief)
    • createBeliefRequest

      public static Message createBeliefRequest()
      Create a Belief request message
      Returns:
      Message instance
    • createChallenge

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

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

      public static Message createGoodBye()
    • getPayload

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

      public Blob getMessageData()
      Gets the encoded data for this message. Generates a single cell encoding if required.
      Returns:
      Blob containing message data
    • getType

      public MessageType getType()
    • 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
    • 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 value)
      Sends a cell of data to the connected Peer
      Parameters:
      value - Cell value to send
      Returns:
      true if data sent, false otherwise
    • sendMissingData

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

      public abstract Connection getConnection()
      Gets the Connection instance associated with this message, or null if no connection exists (presumably a local Message)
      Returns:
      Connection instance
    • hasData

      public boolean hasData()
    • createResult

      public static Message createResult(Result res)
    • createResult

      public static Message createResult(CVMLong id, ACell value, ACell error)
    • closeConnection

      public abstract void closeConnection()