Package convex.net
Class Message
java.lang.Object
convex.net.Message
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 Value.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.slf4j.Logger
protected Blob
protected ACell
protected MessageType
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Closes any connection associated with this message, probably because of bad behaviourstatic Message
create
(Connection conn, MessageType type, Blob data) static Message
create
(MessageType type, ACell payload) static Message
create
(MessageType type, ACell payload, Blob data) static Message
create
(MessageType type, ACell payload, Predicate<Message> handler) Create an instance with the given message datastatic Message
createBelief
(Belief belief) static Message
Create a Belief request messagestatic Message
createChallenge
(SignedData<ACell> challenge) static Message
createDataRequest
(CVMLong id, Hash... hashes) static Message
createDataResponse
(CVMLong id, ACell... cells) static Message
static Message
createResponse
(SignedData<ACell> response) static Message
createResult
(CVMLong id, ACell value, ACell error) static Message
createResult
(Result res) boolean
getID()
Gets the message ID for correlation, assuming this message type supports IDs.Gets the encoded data for this message.<T extends ACell>
TgetType()
boolean
hasData()
makeDataResponse
(AStore store) boolean
Returns a message back to the originator of the message.boolean
returnResult
(Result res) Reports a result back to the originator of the message.toResult()
toString()
-
Field Details
-
log
protected static final org.slf4j.Logger log -
payload
-
messageData
-
type
-
returnHandler
-
-
Constructor Details
-
Message
-
-
Method Details
-
create
-
create
-
create
-
createDataResponse
-
createDataRequest
-
createBelief
-
createBeliefRequest
Create a Belief request message- Returns:
- Message instance
-
createChallenge
-
createResponse
-
createGoodBye
-
getPayload
- Throws:
BadFormatException
-
getMessageData
Gets the encoded data for this message. Generates a single cell encoding if required.- Returns:
- Blob containing message data
-
getType
-
toString
-
equals
-
getID
Gets the message ID for correlation, assuming this message type supports IDs.- Returns:
- Message ID, or null if the message does not have a message ID
-
returnResult
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
-
returnMessage
Returns a message back to the originator of the message. Will set response ID if necessary.- Parameters:
m
- Message- Returns:
- True if sent successfully, false otherwise
-
hasData
public boolean hasData() -
createResult
-
createResult
-
closeConnection
public void closeConnection()Closes any connection associated with this message, probably because of bad behaviour -
makeDataResponse
- Throws:
BadFormatException
-
toResult
-
create
Create an instance with the given message data- Parameters:
type
- Message typepayload
- Message payloadhandler
- Handler for Results- Returns:
- New MessageLocal instance
-