admissionRequest
Builds the AdmissionRequest a room would hand your AdmissionPolicy for a newcomer holding key, so you can test decide without standing up a room.
No proof is checked: the request carries key as if the joiner had signed for it. Take a real key from DeviceKey.generate().id, or DidKey.parse a fixed one.
The fields arrive as the room's own request carries them: displayName is what the joiner's join was given as its member name, or its peer id when it was given none, and an empty deviceId is none, as AdmissionRequest reads it. So there is no default name: the room never sends an empty one for a joiner that gave none.
Parameters
The device key the newcomer proved, as the policy will see it.
The name the newcomer asked to be shown under: its member name, or its peer id. Unverified in production too.
The app's own device id, or null when the joiner sent none.
Samples
// Your policy, as your app would hand it to the room. Decide on the key; the name is say-so.
val blockedList = setOf(blocked)
val policy = AdmissionPolicy { request ->
if (request.key in blockedList) {
AdmissionDecision.Reject(RejectCode.Unknown("blocked"))
} else {
AdmissionDecision.Admit(GrantTerms(readmitFor = 1.hours))
}
}
// The requests the room would build once each joiner had proved its key.
return listOf(
policy.decide(admissionRequest(blocked, displayName = "Mallory")),
policy.decide(admissionRequest(stranger, displayName = "Ada", deviceId = "phone-1")),
)