awaitRoom

abstract suspend fun awaitRoom(memberName: String? = null, deviceId: String? = null): ElectionOutcome

Await the session as a member: suspend until the elected host freezes the lobby, acknowledge it, and adopt the seam as us.tractat.kuilt.session.SessionRole.Joiner. (The host obtains its Room from start instead.)

Ends one of three ways — see ElectionOutcome. ElectionOutcome.Adopted is the session starting; ElectionOutcome.Torn is a mid-2PC collapse; ElectionOutcome.BecameHost means the hosting peer left and this peer is now the elected host, whose recovery is start on this same lobby. All three are terminal and reached within a bound: awaitRoom never suspends forever on a mid-2PC peer-set collapse.

It does suspend indefinitely while the lobby is simply empty or still weaving in, or while the elected host is alive and has not called start — waiting is what a lobby is for, and is not a collapse. An app that wants a limit sets its own: cancel this call, then leave.

deviceId is this device's own stable id. It travels in the joiner's Hello, and the host records it as the member's us.tractat.kuilt.session.MemberIdentity.deviceId, exactly as us.tractat.kuilt.session.RoomFactory.join sends it. Null, the default, sends none.

Throws

if deviceId could not be signed into a key proof (an unpaired surrogate, or UTF-8 longer than 65 535 bytes), before the election runs.