Package com.privatechain.network.rpc
Class MessageCodec.NetworkMessage
java.lang.Object
com.privatechain.network.rpc.MessageCodec.NetworkMessage
- Enclosing class:
MessageCodec
Immutable envelope wrapping all P2P messages.
The payload field holds a raw JSON string whose schema is determined
by MessageCodec.MessageType. Storing it as a pre-serialized string avoids double-encoding during envelope serialization and simplifies re-forwarding in the
gossip layer.
- Since:
- 1.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionNetworkMessage(MessageCodec.MessageType type, String senderId, String payload) Constructs aNetworkMessage. -
Method Summary
-
Constructor Details
-
NetworkMessage
Constructs aNetworkMessage.- Parameters:
type- message type (non-null)senderId- originating node ID (non-null, non-blank)payload- JSON payload string (non-null)- Throws:
NullPointerException- if type, senderId, or payload is nullIllegalArgumentException- if senderId is blank
-
-
Method Details
-
getType
Returns the message type discriminator.- Returns:
- non-null
MessageCodec.MessageType
-
getSenderId
Returns the node ID of the originating sender.- Returns:
- non-null, non-blank sender ID
-
getPayload
Returns the raw JSON payload string.- Returns:
- non-null JSON string
-
toString
Returns a log-safe summary of this message.
-