PeerDiscoverySource

A transport-agnostic feed of peer advertisements.

Each transport module provides its own implementation: MDNSServiceDiscoverer for Bonjour, MultipeerServiceBrowser for Apple MultipeerConnectivity, and so on. The lobby controller composes a list of these and merges their flows so the UI sees one unified roster.

Implementations expose a narrower return type via Kotlin's covariant-return support (e.g. Flow<MDNSAdvertisement>); direct callers keep their typed APIs while the lobby treats every source as Flow<Tag>.

Both members are required. Neither has a default, so a source that cannot honour one of them says so in its own body rather than inheriting silence — see departures.

Not an election input. A discovery feed is one peer's current best guess at who is around: it lags, it may never remove departed peers (see departures), and Tag.peerKey is transport-scoped, so the same physical peer carries different keys across sources. Two peers folding these flows can hold different rosters — and so compute different answers — even with perfect connectivity. Pick a host from us.tractat.kuilt.core.Seam.peers once connected, not from here. See docs/discovery-bootstrap.md.

Properties

Link copied to clipboard
abstract val kind: DiscoveryKind

Identifies the underlying transport (mDNS, MultipeerConnectivity, …).

Functions

Link copied to clipboard
abstract fun departures(): Flow<String>

Cold flow that emits a Tag.peerKey for every peer that leaves the network.

Link copied to clipboard
abstract fun discoveries(): Flow<Tag>

Cold flow that emits a Tag for every peer the source discovers. Stays open until the collector's scope is cancelled.