SFMessage class

Core Store-and-Forward message

Represents a message to be stored and forwarded to a recipient peer. Messages have priority, expiration, and can be encrypted/signed. Supports folder-based addressing and IMAP-style flags.

Constructors

SFMessage({required String messageId, required PeerId recipientPeerId, required PeerId senderPeerId, required Uint8List payload, MessagePriority priority = MessagePriority.normal, required int expiryTimestamp, int hopCount = 0, SFMessageFlags flags = SFMessageFlags.none, int? createdTimestamp, String? folderPath, int? sequenceNumber, MessageFlags? messageFlags, bool persistent = false})
SFMessage.fromJson(Map<String, dynamic> json)
Create from JSON (handles both string and byte-array peer ID formats)
factory
SFMessage.withDefaultExpiry({required String messageId, required PeerId recipientPeerId, required PeerId senderPeerId, required Uint8List payload, MessagePriority priority = MessagePriority.normal, int hopCount = 0, SFMessageFlags flags = SFMessageFlags.none, String? folderPath, bool persistent = false})
Create message with default 7-day expiry
factory

Properties

age → Duration
Get message age
no setter
createdTimestamp → int
Creation timestamp (milliseconds since epoch)
final
expiryTimestamp → int
Expiration timestamp (milliseconds since epoch)
final
flags → SFMessageFlags
Message flags (for protocol-level flags like encrypted, signed, etc.)
final
folderPath → String?
Target folder path (null = default inbox)
final
hashCode → int
The hash code for this object.
no setteroverride
hopCount → int
Number of hops this message has taken
final
isExpired → bool
Check if message has expired
no setter
messageFlags → MessageFlags?
IMAP-style message flags (seen, flagged, deleted, draft)
final
messageId → String
Unique message identifier (UUID)
final
payload → Uint8List
Message payload (possibly encrypted)
final
persistent → bool
Whether to keep message after reading (default: false for private mailboxes)
final
priority → MessagePriority
Message priority
final
recipientPeerId → PeerId
Recipient peer ID
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
senderPeerId → PeerId
Sender peer ID
final
sequenceNumber → int?
Sequence number (set by MDA on storage, null for unsaved messages)
final
timeUntilExpiry → Duration
Get time remaining until expiry
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
Convert to JSON for wire/storage (includes payload as base64)
toMap() → Map<String, dynamic>
Convert to map for serialization (without payload data)
toString() → String
A string representation of this object.
override
withFlags(SFMessageFlags newFlags) → SFMessage
Create a copy with updated flags
withIncrementedHopCount() → SFMessage
Create a copy with incremented hop count (for forwarding)
withMessageFlags(MessageFlags newMessageFlags) → SFMessage
Create a copy with updated message flags
withPayload(Uint8List newPayload, {SFMessageFlags? flags}) → SFMessage
Create a copy with a different payload (and, optionally, flags): the sealed or opened form of the same message.
withPriority(MessagePriority newPriority) → SFMessage
Create a copy with updated priority
withSequence(int sequence) → SFMessage
Create a copy with updated sequence number (set by MDA on storage)

Operators

operator ==(Object other) → bool
The equality operator.
override

Constants

maxHopCount → const int
Maximum hop count before message is dropped