requestDisplayNames top-level constant
Handles the response of a host to a participant's request.
This function processes the host's response to a participant request for various actions (e.g., microphone, video, screenshare, chat) and updates the corresponding action states, request statuses, and times.
options
The options used to handle the host's response.requestResponse
: A map containing details of the request and the host's response.type
: The type of the request, such asfa-microphone
,fa-video
,fa-desktop
, orfa-comments
.action
: The response of the host, such asaccepted
orrejected
.
showAlert
: A callback function to display an alert message to the user.requestList
: The current list of active requests made by participants.updateRequestList
: Callback function to update the request list.updateMicAction
,updateVideoAction
,updateScreenAction
,updateChatAction
: Functions to update the state of the actions.updateAudioRequestState
,updateVideoRequestState
,updateScreenRequestState
,updateChatRequestState
: Functions to update the request states.updateAudioRequestTime
,updateVideoRequestTime
,updateScreenRequestTime
,updateChatRequestTime
: Functions to update the time of each request.updateRequestIntervalSeconds
: The interval in seconds to delay further requests after a rejection.
If the request is accepted, it updates the respective action's state to true
,
updates the request state to 'accepted'
, and calls an alert to inform the user.
If the request is rejected, it sets the request state to 'rejected'
, displays an alert,
and sets a cooldown time for retrying based on the updateRequestIntervalSeconds
.
Example Usage:
final options = HostRequestResponseOptions(
requestResponse: {
'id': 'request123',
'type': 'fa-microphone',
'action': 'accepted',
},
showAlert: (message, type, duration) {
print('$type: $message for $duration ms');
},
requestList: [
{'id': 'request123', 'type': 'fa-microphone', 'name': 'Participant1'},
],
updateRequestList: (updatedList) {
print('Updated request list: $updatedList');
},
updateMicAction: (status) {
print('Mic action updated: $status');
},
updateVideoAction: (status) {},
updateScreenAction: (status) {},
updateChatAction: (status) {},
updateAudioRequestState: (state) {
print('Audio request state updated: $state');
},
updateVideoRequestState: (state) {},
updateScreenRequestState: (state) {},
updateChatRequestState: (state) {},
updateAudioRequestTime: (time) {
print('Audio request time updated to: $time');
},
updateVideoRequestTime: (time) {},
updateScreenRequestTime: (time) {},
updateChatRequestTime: (time) {},
updateRequestIntervalSeconds: 240,
);
await hostRequestResponse(options);
In this example, the host accepts a microphone request. The function updates
the microphone action state, sets the audio request state to 'accepted'
,
and calls showAlert
to notify the user. If the request had been rejected,
it would set the audio request state to 'rejected'
, show an alert, and set
a cooldown time before the next request.
Display names for the request types.
Implementation
/// Display names for the request types.
const requestDisplayNames = {
'fa-microphone': 'Audio',
'fa-video': 'Video',
'fa-desktop': 'Screen share',
'fa-comments': 'Chat',
};