Message class
Message Structure:
- 16 bytes: Message header (contains metadata about the message)
- 64 bytes: Source Peer ID (identifies the sender)
- 64 bytes: Destination Peer ID (identifies the recipient)
- 0 or >48 bytes: Encrypted payload (optional data, encrypted for security)
- 64 bytes: Signature (used for message authentication)
Constructors
- Message({required PacketHeader header, required PeerId srcPeerId, required PeerId dstPeerId, Uint8List? payload})
Properties
- dstPeerId → PeerId
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- header → PacketHeader
-
final
- isEmpty → bool
-
no setter
- isNotEmpty → bool
-
no setter
- payload ↔ Uint8List?
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- srcPeerId → PeerId
-
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toBytes(
) → Uint8List -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
getDstPeerId(
Uint8List datagram) → PeerId - Extracts the destination Peer ID from the datagram.
-
getHeader(
Uint8List datagram) → Uint8List - Extracts the header from the datagram.
-
getPayload(
Uint8List datagram) → Uint8List - Extracts the payload from the datagram.
-
getSignature(
Uint8List signedDatagram) → Uint8List - Extracts the signature from a signed datagram.
-
getSrcPeerId(
Uint8List datagram) → PeerId - Extracts the source Peer ID from the datagram.
-
getUnsignedDatagram(
Uint8List signedDatagram) → Uint8List - Extracts the unsigned datagram from a signed datagram.
-
getUnsignedPayload(
Uint8List signedDatagram) → Uint8List - Extracts the unsigned payload from a signed datagram.
-
hasCorrectLength(
Uint8List datagram) → bool - Checks if the datagram has the correct length for a message.
-
hasEmptyPayload(
Uint8List signedDatagram) → bool - Checks if the signed datagram has an empty payload.
-
isNotEmptyPayload(
Uint8List datagram) → bool - Checks if the datagram has a non-empty payload.
Constants
- emptySignedMessageLength → const int
- Length of an empty signed message in bytes.
- headerLength → const int
- Length of the message header in bytes.
- protocolNumber → const int
- Protocol number for this message type.