AirpassSyncEngine class
Orchestrates the epidemic data exchange between two connected peers.
Usage (called by NearbyConnectionManager):
// When connection is established:
final outgoing = await syncEngine.buildSyncPayload();
Nearby().sendBytesPayload(endpointId, outgoing);
// When peer's payload is received:
await syncEngine.processSyncPayload(incomingBytes);
Constructors
-
AirpassSyncEngine({required AirpassDatabase database, required String localNodeId, required NodeRole localRole, List<
String> localGroupIds = const [], String? localDisplayName, int? localBatteryLevel, bool localHasInternetAccess = false})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- localBatteryLevel ↔ int?
-
The local node's battery level (0-100), if available.
getter/setter pair
- localDisplayName ↔ String?
-
The local user's display name, if set.
getter/setter pair
-
localGroupIds
↔ List<
String> -
All groups the local node is subscribed to.
Used to populate self-entries in the routing table so that multi-hop
peers learn about ALL of our group memberships, not just the first.
getter/setter pair
- localHasInternetAccess ↔ bool
-
Whether the local node currently has internet access.
getter/setter pair
- localNodeId → String
-
The local node's UUID. Set during initialization.
final
- localRole ↔ NodeRole
-
The local node's role. Used to populate the self-entry in sync payloads.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
buildBloomFilter(
) → Future< Uint8List> - Builds a Bloom filter containing the IDs of all syncable messages in the local database.
-
buildFilteredSyncPayload(
{BloomFilter? peerFilter, String? peerNodeId}) → Future< Uint8List> - Packages the local routing table and syncable messages into a compressed bytes payload, using the peer's Bloom filter to exclude messages the peer already has.
-
buildSyncPayload(
{String? peerNodeId}) → Future< Uint8List> -
Packages the local routing table and syncable messages into a
compressed bytes payload ready to send via
Nearby.sendBytesPayload. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
processSyncPayload(
Uint8List compressedBytes) → Future< ({int newMessages, String peerNodeId})> - Decompresses, parses, and merges an incoming sync payload into the local database.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited