respond To Waiting
Responds to a waiting participant by allowing or denying access based on specified options.
This function uses RespondToWaitingOptions to handle a participant in the waiting room, updating the waiting list and emitting an event through a socket to approve or deny access. The response type ("true" or "false") is determined based on the type provided.
Parameters:
options - An instance of
RespondToWaitingOptionscontaining:participantId: The unique identifier for the participant.participantName: The name of the participant.updateWaitingList: A function to update the waiting list.waitingList: The current list of participants in the waiting room.type: The approval type, which can be aboolorString("true"or"false").roomName: The name of the room the participant is waiting to join.socket: The socket used to emit the response event.
Example Usage:
// Define a sample waiting list and an update function
val waitingList = listOf(
WaitingRoomParticipant(name = "John Doe", id = "123"),
WaitingRoomParticipant(name = "Jane Smith", id = "456")
)
val updateWaitingList: (List<WaitingRoomParticipant>) -> Unit = { newList ->
}
// Initialize options for responding to a participant
val options = RespondToWaitingOptions(
participantId = "123",
participantName = "John Doe",
updateWaitingList = updateWaitingList,
waitingList = waitingList,
type = true, // Allow participant
roomName = "MainRoom",
socket = socketInstance // Assume socket connection is established
)
// Call respondToWaiting to process the response
respondToWaiting(options)
// Expected output:
// Updated waiting list: [Jane Smith]
// Emits an event to allow "John Doe" to join the "MainRoom".