Package convex.net.message
Class Message
java.lang.Object
convex.net.message.Message
- Direct Known Subclasses:
MessageLocal
,MessageRemote
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 Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.slf4j.Logger
protected Blob
protected ACell
protected MessageType
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
static MessageRemote
create
(Connection peerConnection, MessageType type, ACell payload, Blob data) static Message
createBelief
(Belief belief) static Message
Create a Belief request messagestatic Message
createChallenge
(SignedData<ACell> challenge) static Message
createData
(ACell o) static Message
static Message
createMissingData
(Hash missingHash) static Message
createMissingData
(CVMLong id, Hash... missingHashes) static Message
createResponse
(SignedData<ACell> response) static Message
createResult
(CVMLong id, ACell value, ACell error) static Message
createResult
(Result res) abstract Connection
Gets the Connection instance associated with this message, or null if no connection exists (presumably a local Message)getID()
Gets the message ID for correlation, assuming this message type supports IDs.Gets the encoded data for this message.abstract String
Gets a String identifying the origin of the message.<T extends ACell>
TgetType()
boolean
hasData()
abstract boolean
reportResult
(Result res) Reports a result back to the originator of the message.abstract boolean
Sends a cell of data to the connected Peerabstract boolean
sendMissingData
(Hash hash) Returns a missing data request to the connected PeertoString()
-
Field Details
-
log
protected static final org.slf4j.Logger log -
payload
-
messageData
-
type
-
-
Constructor Details
-
Message
-
-
Method Details
-
create
public static MessageRemote create(Connection peerConnection, MessageType type, ACell payload, Blob data) -
createData
-
createMissingData
-
createMissingData
-
createBelief
-
createBeliefRequest
Create a Belief request message- Returns:
- Message instance
-
createChallenge
-
createResponse
-
createGoodBye
-
getPayload
-
getMessageData
Gets the encoded data for this message. Generates a single cell encoding if required.- Returns:
- Blob containing message data
-
getType
-
toString
-
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
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
Gets a String identifying the origin of the message. Used for logging.- Returns:
- String representing message origin
-
sendData
Sends a cell of data to the connected Peer- Parameters:
value
- Cell value to send- Returns:
- true if data sent, false otherwise
-
sendMissingData
Returns a missing data request to the connected Peer- Parameters:
hash
- Hash of missing data- Returns:
- True if request sent, false otherwise
-
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
-
createResult
-
closeConnection
public abstract void closeConnection()
-