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.Loggerprotected Blobprotected ACellprotected MessageType -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidstatic MessageRemotecreate(Connection peerConnection, MessageType type, ACell payload, Blob data) static MessagecreateBelief(Belief belief) static MessagecreateBelief(Belief belief, List<ACell> novelty) Create a Belief message ready for broadcast including delta noveltystatic MessageCreate a Belief request messagestatic MessagecreateChallenge(SignedData<ACell> challenge) static MessagecreateData(ACell o) static Messagestatic MessagecreateMissingData(Hash missingHash) static MessagecreateMissingData(CVMLong id, Hash... missingHashes) static MessagecreateResponse(SignedData<ACell> response) static MessagecreateResult(CVMLong id, ACell value, ACell error) static MessagecreateResult(Result res) abstract ConnectionGets 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 StringGets a String identifying the origin of the message.<T extends ACell>
TgetType()booleanhasData()abstract booleanreportResult(Result res) Reports a result back to the originator of the message.abstract booleanSends a cell of data to the connected Peerabstract booleansendMissingData(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
-
createBelief
Create a Belief message ready for broadcast including delta novelty- Parameters:
novelty- Novel cells for transmission.belief- Belief top level Cell to encode- Returns:
- Message instance
-
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()
-