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.
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.
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.