NearbyApi
Abstracts the slice of Google Nearby Connections needed by NearbyLoom.
Implementations: FakeNearbyApi (tests, commonTest) and the real GmsNearbyApi (androidMain, dispatched separately).
All callbacks surface as Flows. The endpointId used in these events is a local-namespace opaque string assigned by the runtime — it is NOT a stable peer identity across sessions. Stable identity is exchanged as a payload during the handshake.
Properties
Emits when a connection initiation is signalled (either side triggered it). The receiver should call acceptConnection to proceed.
Emits the result of a connection request — success or failure.
Emits when an endpoint disconnects.
Emits when a remote endpoint is found during discovery. Carries the endpointId and the remote's display name.
Emits when a bytes payload is received from an endpoint.
The device's live radio state, or null while unknown. This is what makes a seam's us.tractat.kuilt.core.Seam.capability reactive (#1543): as Bluetooth is toggled, Wi-Fi returns, or the Play services runtime hosting the fabric goes away, a fresh NearbyRadioState appears here and the seam folds its toAvailability into the live capability — and its radioRoles into the live ROLES.
Functions
Accept an incoming connection from endpointId. Called after an EndpointEvent.ConnectionInitiated event is received.
Reports whether the underlying fabric is usable on this runtime — a one-shot, static platform-support question ("is there a Nearby runtime here at all"), answered once when NearbyLoom.capability is asked. It is deliberately NOT the live signal: see radioState, which is what makes a woven seam's capability reactive.
Disconnect from endpointId. No-op if already disconnected.
Request a connection to a discovered endpointId. The local displayName is sent to the remote during the handshake.
Send a raw bytes payload to endpointId.
Begin advertising under displayName with service id serviceId.
Begin discovering endpoints with the given serviceId.
Stop advertising. No-op if not advertising.
Stop discovery. No-op if not discovering.