mediasfu-shared 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +103 -222
- package/dist/index.cjs +7634 -2180
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4203 -273
- package/dist/index.js +7663 -2209
- package/dist/index.js.map +1 -1
- package/package.json +96 -78
- package/src/ProducerClient/producerClientEmits/joinRoomClient.ts +57 -0
- package/src/ProducerClient/producerClientEmits/updateRoomParametersClient.ts +401 -0
- package/src/consumers/addVideosGrid.ts +3 -2
- package/src/consumers/changeVids.ts +111 -41
- package/src/consumers/checkPermission.ts +35 -1
- package/src/consumers/connectIps.ts +3 -1
- package/src/consumers/connectLocalIps.ts +3 -1
- package/src/consumers/connectRecvTransport.ts +96 -1
- package/src/consumers/consumerResume.ts +2 -2
- package/src/consumers/dispStreams.ts +83 -37
- package/src/consumers/frameworkConsumerContract.ts +6 -0
- package/src/consumers/generatePageContent.ts +24 -10
- package/src/consumers/getPipedProducersAlt.ts +112 -16
- package/src/consumers/gridLayout/addVideosGrid.engine.ts +42 -0
- package/src/consumers/gridLayout/prepopulateUserMedia.engine.ts +444 -0
- package/src/consumers/mixStreams.ts +45 -14
- package/src/consumers/onScreenChanges.ts +25 -10
- package/src/consumers/prepopulateUserMedia.ts +3 -2
- package/src/consumers/processConsumerTransports.ts +68 -23
- package/src/consumers/processConsumerTransportsAudio.ts +146 -17
- package/src/consumers/reUpdateInter.ts +61 -21
- package/src/consumers/readjust.ts +30 -14
- package/src/consumers/reorderStreams.ts +76 -42
- package/src/consumers/resumePauseAudioStreams.ts +66 -17
- package/src/consumers/resumePauseStreams.ts +53 -10
- package/src/consumers/socketReceiveMethods/joinConsumeRoom.ts +8 -0
- package/src/consumers/socketReceiveMethods/newPipeProducer.ts +114 -0
- package/src/consumers/socketReceiveMethods/producerClosed.ts +13 -0
- package/src/consumers/streamSuccessScreen.ts +2 -2
- package/src/consumers/streamSuccessVideo.ts +5 -0
- package/src/consumers/translationConsumerSwitch.ts +321 -0
- package/src/index.ts +85 -1
- package/src/methods/coHostMethods/modifyCoHostSettings.ts +9 -9
- package/src/methods/displaySettings/modifyDisplaySettings.ts +5 -0
- package/src/methods/index.ts +66 -0
- package/src/methods/message/sendMessage.ts +12 -29
- package/src/methods/panelists/focusPanelists.ts +83 -0
- package/src/methods/panelists/index.ts +3 -0
- package/src/methods/panelists/launchPanelists.ts +13 -0
- package/src/methods/panelists/updatePanelists.ts +135 -0
- package/src/methods/permissions/index.ts +3 -0
- package/src/methods/permissions/launchPermissions.ts +13 -0
- package/src/methods/permissions/updateParticipantPermission.ts +127 -0
- package/src/methods/permissions/updatePermissionConfig.ts +52 -0
- package/src/methods/polls/pollUpdated.ts +88 -0
- package/src/methods/recording/confirmRecording.ts +15 -12
- package/src/methods/recording/recordResumeTimer.ts +2 -2
- package/src/methods/recording/recordStartTimer.ts +2 -2
- package/src/methods/recording/timeLeftRecording.ts +25 -0
- package/src/methods/requests/hostRequestResponse.ts +158 -0
- package/src/methods/settings/modifySettings.ts +17 -17
- package/src/methods/socketReceive/allMembers.ts +450 -0
- package/src/methods/socketReceive/allMembersRest.ts +480 -0
- package/src/methods/socketReceive/allWaitingRoomMembers.ts +35 -0
- package/src/methods/socketReceive/banParticipant.ts +73 -0
- package/src/methods/socketReceive/controlMediaHost.ts +280 -0
- package/src/methods/socketReceive/disconnect.ts +40 -0
- package/src/methods/socketReceive/disconnectUserSelf.ts +56 -0
- package/src/methods/socketReceive/getDomains.ts +112 -0
- package/src/methods/socketReceive/meetingEnded.ts +49 -0
- package/src/methods/socketReceive/meetingStillThere.ts +26 -0
- package/src/methods/socketReceive/panelistReceiveMethods.ts +195 -0
- package/src/methods/socketReceive/participantRequested.ts +48 -0
- package/src/methods/socketReceive/permissionReceiveMethods.ts +59 -0
- package/src/methods/socketReceive/personJoined.ts +35 -0
- package/src/methods/socketReceive/producerMediaClosed.ts +223 -0
- package/src/methods/socketReceive/producerMediaPaused.ts +267 -0
- package/src/methods/socketReceive/producerMediaResumed.ts +157 -0
- package/src/methods/socketReceive/reInitiateRecording.ts +53 -0
- package/src/methods/socketReceive/receiveMessage.ts +117 -0
- package/src/methods/socketReceive/recordingNotice.ts +286 -0
- package/src/methods/socketReceive/roomRecordParams.ts +122 -0
- package/src/methods/socketReceive/screenProducerId.ts +61 -0
- package/src/methods/socketReceive/startRecords.ts +46 -0
- package/src/methods/socketReceive/stoppedRecording.ts +44 -0
- package/src/methods/socketReceive/translationReceiveMethods.ts +581 -0
- package/src/methods/socketReceive/updateConsumingDomains.ts +128 -0
- package/src/methods/socketReceive/updateMediaSettings.ts +45 -0
- package/src/methods/socketReceive/updatedCoHost.ts +75 -0
- package/src/methods/socketReceive/userWaiting.ts +45 -0
- package/src/methods/stream/clickAudio.ts +380 -0
- package/src/methods/stream/clickChat.ts +36 -0
- package/src/methods/stream/clickScreenShare.ts +173 -0
- package/src/methods/stream/clickVideo.ts +28 -6
- package/src/methods/stream/index.ts +1 -0
- package/src/methods/utils/SoundPlayer.ts +31 -0
- package/src/methods/utils/checkLimitsAndMakeRequest.ts +156 -2
- package/src/methods/utils/createResponseJoinRoom.ts +47 -0
- package/src/methods/utils/createRoomOnMediaSFU.ts +160 -0
- package/src/methods/utils/formatNumber.ts +42 -0
- package/src/methods/utils/generateRandomMessages.ts +70 -0
- package/src/methods/utils/generateRandomParticipants.ts +100 -0
- package/src/methods/utils/generateRandomPolls.ts +43 -0
- package/src/methods/utils/generateRandomRequestList.ts +51 -0
- package/src/methods/utils/generateRandomWaitingRoomList.ts +17 -0
- package/src/methods/utils/getModalPosition.ts +23 -0
- package/src/methods/utils/getOverlayPosition.ts +37 -0
- package/src/methods/utils/initialValuesState.ts +405 -0
- package/src/methods/utils/joinRoomOnMediaSFU.ts +124 -0
- package/src/methods/utils/liveSubtitle.ts +107 -0
- package/src/methods/utils/meetingTimeRemaining.ts +33 -0
- package/src/methods/utils/meetingTimer/startMeetingProgressTimer.ts +72 -0
- package/src/methods/utils/producer/aParams.ts +10 -0
- package/src/methods/utils/producer/hParams.ts +26 -0
- package/src/methods/utils/producer/screenParams.ts +13 -0
- package/src/methods/utils/producer/vParams.ts +26 -0
- package/src/methods/utils/producer/videoCaptureConstraints.ts +65 -0
- package/src/methods/utils/resolveMediaSFURoomApi.ts +28 -0
- package/src/methods/utils/sleep.ts +24 -0
- package/src/methods/utils/translationLanguages.ts +308 -0
- package/src/methods/utils/webrtc.ts +44 -0
- package/src/methods/welcome/handleWelcomeRequest.ts +11 -2
- package/src/methods/welcome/index.ts +5 -1
- package/src/methods/whiteboard/captureCanvasStream.ts +128 -0
- package/src/producers/producerEmits/joinConRoom.ts +2 -2
- package/src/producers/producerEmits/joinLocalRoom.ts +240 -0
- package/src/producers/producerEmits/joinRoom.ts +129 -0
- package/src/types/shared-base-types.ts +14 -3
- package/src/types/types.ts +255 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Socket } from 'socket.io-client';
|
|
2
|
+
import type { Participant, ShowAlert } from '../../types/types';
|
|
3
|
+
|
|
4
|
+
export type PermissionLevel = '0' | '1' | '2';
|
|
5
|
+
|
|
6
|
+
export interface UpdateParticipantPermissionOptions {
|
|
7
|
+
socket: Socket;
|
|
8
|
+
participant: Participant;
|
|
9
|
+
newLevel: PermissionLevel;
|
|
10
|
+
member: string;
|
|
11
|
+
islevel: string;
|
|
12
|
+
roomName: string;
|
|
13
|
+
showAlert?: ShowAlert;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface BulkUpdateParticipantPermissionsOptions {
|
|
17
|
+
socket: Socket;
|
|
18
|
+
participants: Participant[];
|
|
19
|
+
newLevel: PermissionLevel;
|
|
20
|
+
member: string;
|
|
21
|
+
islevel: string;
|
|
22
|
+
roomName: string;
|
|
23
|
+
showAlert?: ShowAlert;
|
|
24
|
+
maxBatchSize?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const updateParticipantPermission = async ({
|
|
28
|
+
socket,
|
|
29
|
+
participant,
|
|
30
|
+
newLevel,
|
|
31
|
+
member: _member,
|
|
32
|
+
islevel,
|
|
33
|
+
roomName,
|
|
34
|
+
showAlert,
|
|
35
|
+
}: UpdateParticipantPermissionOptions): Promise<void> => {
|
|
36
|
+
if (islevel !== '2') {
|
|
37
|
+
showAlert?.({ message: 'Only the host can update participant permissions', type: 'danger', duration: 3000 });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (participant.islevel === '2') {
|
|
42
|
+
showAlert?.({ message: "Cannot change the host's permission level", type: 'danger', duration: 3000 });
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (participant.islevel === newLevel) return;
|
|
47
|
+
|
|
48
|
+
return new Promise<void>((resolve) => {
|
|
49
|
+
socket.emit(
|
|
50
|
+
'updateParticipantPermission',
|
|
51
|
+
{
|
|
52
|
+
participantId: participant.id,
|
|
53
|
+
participantName: participant.name,
|
|
54
|
+
newLevel,
|
|
55
|
+
roomName,
|
|
56
|
+
},
|
|
57
|
+
(response: { success: boolean; reason?: string }) => {
|
|
58
|
+
if (!response?.success) {
|
|
59
|
+
showAlert?.({ message: response?.reason || 'Failed to update permission', type: 'danger', duration: 3000 });
|
|
60
|
+
}
|
|
61
|
+
resolve();
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const bulkUpdateParticipantPermissions = async ({
|
|
68
|
+
socket,
|
|
69
|
+
participants,
|
|
70
|
+
newLevel,
|
|
71
|
+
member: _member,
|
|
72
|
+
islevel,
|
|
73
|
+
roomName,
|
|
74
|
+
showAlert,
|
|
75
|
+
maxBatchSize = 50,
|
|
76
|
+
}: BulkUpdateParticipantPermissionsOptions): Promise<void> => {
|
|
77
|
+
if (islevel !== '2') {
|
|
78
|
+
showAlert?.({ message: 'Only the host can update participant permissions', type: 'danger', duration: 3000 });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const eligibleParticipants = participants.filter(
|
|
83
|
+
(p) => p.islevel !== '2' && p.islevel !== newLevel
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
if (eligibleParticipants.length === 0) {
|
|
87
|
+
showAlert?.({
|
|
88
|
+
message: 'No participants to update',
|
|
89
|
+
type: 'info',
|
|
90
|
+
duration: 3000,
|
|
91
|
+
});
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const batch = eligibleParticipants.slice(0, maxBatchSize);
|
|
96
|
+
|
|
97
|
+
return new Promise<void>((resolve) => {
|
|
98
|
+
socket.emit(
|
|
99
|
+
'bulkUpdateParticipantPermissions',
|
|
100
|
+
{
|
|
101
|
+
updates: batch.map((p) => ({
|
|
102
|
+
participantId: p.id,
|
|
103
|
+
participantName: p.name,
|
|
104
|
+
newLevel,
|
|
105
|
+
})),
|
|
106
|
+
roomName,
|
|
107
|
+
},
|
|
108
|
+
(response: { success: boolean; reason?: string }) => {
|
|
109
|
+
if (!response?.success) {
|
|
110
|
+
showAlert?.({
|
|
111
|
+
message: response?.reason || 'Failed to update permissions',
|
|
112
|
+
type: 'danger',
|
|
113
|
+
duration: 3000,
|
|
114
|
+
});
|
|
115
|
+
} else if (eligibleParticipants.length > maxBatchSize) {
|
|
116
|
+
showAlert?.({
|
|
117
|
+
message: `Updated ${batch.length} participants. ${eligibleParticipants.length - maxBatchSize} remaining.`,
|
|
118
|
+
type: 'info',
|
|
119
|
+
duration: 3000,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
resolve();
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Socket } from 'socket.io-client';
|
|
2
|
+
import type { ShowAlert } from '../../types/types';
|
|
3
|
+
|
|
4
|
+
export interface PermissionCapabilities {
|
|
5
|
+
useMic: 'allow' | 'approval' | 'disallow';
|
|
6
|
+
useCamera: 'allow' | 'approval' | 'disallow';
|
|
7
|
+
useScreen: 'allow' | 'approval' | 'disallow';
|
|
8
|
+
useChat: 'allow' | 'disallow';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface PermissionConfig {
|
|
12
|
+
level0: PermissionCapabilities;
|
|
13
|
+
level1: PermissionCapabilities;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface UpdatePermissionConfigOptions {
|
|
17
|
+
socket: Socket;
|
|
18
|
+
config: PermissionConfig;
|
|
19
|
+
member: string;
|
|
20
|
+
islevel: string;
|
|
21
|
+
roomName: string;
|
|
22
|
+
showAlert?: ShowAlert;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const updatePermissionConfig = async ({
|
|
26
|
+
socket,
|
|
27
|
+
config,
|
|
28
|
+
islevel,
|
|
29
|
+
roomName,
|
|
30
|
+
showAlert,
|
|
31
|
+
}: UpdatePermissionConfigOptions): Promise<void> => {
|
|
32
|
+
if (islevel !== '2') {
|
|
33
|
+
showAlert?.({ message: 'Only the host can update permission configuration', type: 'danger', duration: 3000 });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return new Promise<void>((resolve) => {
|
|
38
|
+
socket.emit(
|
|
39
|
+
'updatePermissionConfig',
|
|
40
|
+
{
|
|
41
|
+
config,
|
|
42
|
+
roomName,
|
|
43
|
+
},
|
|
44
|
+
(response: { success: boolean; reason?: string }) => {
|
|
45
|
+
if (!response?.success) {
|
|
46
|
+
showAlert?.({ message: response?.reason || 'Failed to update permission config', type: 'danger', duration: 3000 });
|
|
47
|
+
}
|
|
48
|
+
resolve();
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Poll, PollUpdatedData, ShowAlert } from '../../types/types';
|
|
2
|
+
|
|
3
|
+
export interface PollUpdatedOptions {
|
|
4
|
+
data: PollUpdatedData;
|
|
5
|
+
polls: Poll[];
|
|
6
|
+
poll: Poll;
|
|
7
|
+
member: string;
|
|
8
|
+
islevel: string;
|
|
9
|
+
showAlert?: ShowAlert;
|
|
10
|
+
updatePolls: (polls: Poll[]) => void;
|
|
11
|
+
updatePoll: (poll: Poll) => void;
|
|
12
|
+
updateIsPollModalVisible: (isVisible: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type PollUpdatedType = (options: PollUpdatedOptions) => Promise<void>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Reconciles poll update payloads with current poll state.
|
|
19
|
+
*
|
|
20
|
+
* This helper updates the poll collection, manages active poll visibility, and
|
|
21
|
+
* emits user-facing alerts when a new poll starts or an active poll ends.
|
|
22
|
+
*
|
|
23
|
+
* @param options Poll update handling options.
|
|
24
|
+
* @returns A promise that resolves after local poll state has been synchronized.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* await pollUpdated({
|
|
29
|
+
* data,
|
|
30
|
+
* polls,
|
|
31
|
+
* poll,
|
|
32
|
+
* member: 'Ada',
|
|
33
|
+
* islevel: '1',
|
|
34
|
+
* updatePolls: setPolls,
|
|
35
|
+
* updatePoll: setCurrentPoll,
|
|
36
|
+
* updateIsPollModalVisible: setPollModalVisible,
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export const pollUpdated = async ({
|
|
41
|
+
data,
|
|
42
|
+
polls,
|
|
43
|
+
poll,
|
|
44
|
+
member,
|
|
45
|
+
islevel,
|
|
46
|
+
showAlert,
|
|
47
|
+
updatePolls,
|
|
48
|
+
updatePoll,
|
|
49
|
+
updateIsPollModalVisible,
|
|
50
|
+
}: PollUpdatedOptions): Promise<void> => {
|
|
51
|
+
try {
|
|
52
|
+
if (data.polls) {
|
|
53
|
+
polls = data.polls;
|
|
54
|
+
updatePolls(data.polls);
|
|
55
|
+
} else {
|
|
56
|
+
polls = [data.poll];
|
|
57
|
+
updatePolls(polls);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let tempPoll: Poll | { id: string } = { id: '' };
|
|
61
|
+
|
|
62
|
+
if (poll) {
|
|
63
|
+
tempPoll = { ...poll };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (data.status !== 'ended') {
|
|
67
|
+
poll = data.poll;
|
|
68
|
+
updatePoll(data.poll);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (data.status === 'started' && islevel !== '2') {
|
|
72
|
+
if (!poll.voters || (poll.voters && !poll.voters[member])) {
|
|
73
|
+
showAlert?.({
|
|
74
|
+
message: 'New poll started',
|
|
75
|
+
type: 'success',
|
|
76
|
+
duration: 3000,
|
|
77
|
+
});
|
|
78
|
+
updateIsPollModalVisible(true);
|
|
79
|
+
}
|
|
80
|
+
} else if (data.status === 'ended') {
|
|
81
|
+
if (tempPoll.id === data.poll.id) {
|
|
82
|
+
showAlert?.({ message: 'Poll ended', type: 'danger', duration: 3000 });
|
|
83
|
+
updatePoll(data.poll);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
};
|
|
@@ -50,6 +50,10 @@ export interface ConfirmRecordingOptions {
|
|
|
50
50
|
|
|
51
51
|
export type ConfirmRecordingType = (options: ConfirmRecordingOptions) => Promise<void>
|
|
52
52
|
|
|
53
|
+
const ALERT_DURATION = 6000
|
|
54
|
+
const FULL_PARTICIPANT_RECORDING_ALERT_MESSAGE =
|
|
55
|
+
'You are not allowed to record videos of all participants while the meeting display is set to All. Switch the meeting display to Media and try again.'
|
|
56
|
+
|
|
53
57
|
/**
|
|
54
58
|
* Confirms the recording settings based on the provided parameters and updates the recording state.
|
|
55
59
|
*/
|
|
@@ -100,10 +104,9 @@ export const confirmRecording: ConfirmRecordingType = async ({
|
|
|
100
104
|
) {
|
|
101
105
|
if (meetingDisplayType === 'all' && !(breakOutRoomStarted && !breakOutRoomEnded)) {
|
|
102
106
|
showAlert?.({
|
|
103
|
-
message:
|
|
104
|
-
'You are not allowed to record videos of all participants; change the meeting display type to video or video optimized.',
|
|
107
|
+
message: FULL_PARTICIPANT_RECORDING_ALERT_MESSAGE,
|
|
105
108
|
type: 'danger',
|
|
106
|
-
duration:
|
|
109
|
+
duration: ALERT_DURATION,
|
|
107
110
|
})
|
|
108
111
|
return
|
|
109
112
|
}
|
|
@@ -113,7 +116,7 @@ export const confirmRecording: ConfirmRecordingType = async ({
|
|
|
113
116
|
showAlert?.({
|
|
114
117
|
message: 'You are only allowed to record yourself.',
|
|
115
118
|
type: 'danger',
|
|
116
|
-
duration:
|
|
119
|
+
duration: ALERT_DURATION,
|
|
117
120
|
})
|
|
118
121
|
return
|
|
119
122
|
}
|
|
@@ -122,7 +125,7 @@ export const confirmRecording: ConfirmRecordingType = async ({
|
|
|
122
125
|
showAlert?.({
|
|
123
126
|
message: 'You are not allowed to record other video participants.',
|
|
124
127
|
type: 'danger',
|
|
125
|
-
duration:
|
|
128
|
+
duration: ALERT_DURATION,
|
|
126
129
|
})
|
|
127
130
|
return
|
|
128
131
|
}
|
|
@@ -131,7 +134,7 @@ export const confirmRecording: ConfirmRecordingType = async ({
|
|
|
131
134
|
showAlert?.({
|
|
132
135
|
message: 'You are not allowed to record all orientations.',
|
|
133
136
|
type: 'danger',
|
|
134
|
-
duration:
|
|
137
|
+
duration: ALERT_DURATION,
|
|
135
138
|
})
|
|
136
139
|
return
|
|
137
140
|
}
|
|
@@ -144,7 +147,7 @@ export const confirmRecording: ConfirmRecordingType = async ({
|
|
|
144
147
|
showAlert?.({
|
|
145
148
|
message: 'You are not allowed to record this orientation.',
|
|
146
149
|
type: 'danger',
|
|
147
|
-
duration:
|
|
150
|
+
duration: ALERT_DURATION,
|
|
148
151
|
})
|
|
149
152
|
return
|
|
150
153
|
}
|
|
@@ -154,7 +157,7 @@ export const confirmRecording: ConfirmRecordingType = async ({
|
|
|
154
157
|
showAlert?.({
|
|
155
158
|
message: 'You are not allowed to record all formats.',
|
|
156
159
|
type: 'danger',
|
|
157
|
-
duration:
|
|
160
|
+
duration: ALERT_DURATION,
|
|
158
161
|
})
|
|
159
162
|
return
|
|
160
163
|
}
|
|
@@ -166,7 +169,7 @@ export const confirmRecording: ConfirmRecordingType = async ({
|
|
|
166
169
|
message:
|
|
167
170
|
'Recording display type can be either video, video optimized, or media when meeting display type is media.',
|
|
168
171
|
type: 'danger',
|
|
169
|
-
duration:
|
|
172
|
+
duration: ALERT_DURATION,
|
|
170
173
|
})
|
|
171
174
|
updateRecordingDisplayType(meetingDisplayType as 'video' | 'media' | 'all')
|
|
172
175
|
return
|
|
@@ -178,7 +181,7 @@ export const confirmRecording: ConfirmRecordingType = async ({
|
|
|
178
181
|
message:
|
|
179
182
|
'Recording display type can be either video or video optimized when meeting display type is video.',
|
|
180
183
|
type: 'danger',
|
|
181
|
-
duration:
|
|
184
|
+
duration: ALERT_DURATION,
|
|
182
185
|
})
|
|
183
186
|
updateRecordingDisplayType(meetingDisplayType as 'video' | 'media' | 'all')
|
|
184
187
|
return
|
|
@@ -189,7 +192,7 @@ export const confirmRecording: ConfirmRecordingType = async ({
|
|
|
189
192
|
message:
|
|
190
193
|
'Recording display type can only be video optimized when meeting display type is video optimized.',
|
|
191
194
|
type: 'danger',
|
|
192
|
-
duration:
|
|
195
|
+
duration: ALERT_DURATION,
|
|
193
196
|
})
|
|
194
197
|
updateRecordingVideoOptimized(meetingVideoOptimized)
|
|
195
198
|
return
|
|
@@ -205,7 +208,7 @@ export const confirmRecording: ConfirmRecordingType = async ({
|
|
|
205
208
|
showAlert?.({
|
|
206
209
|
message: 'You can only record all participants with media.',
|
|
207
210
|
type: 'danger',
|
|
208
|
-
duration:
|
|
211
|
+
duration: ALERT_DURATION,
|
|
209
212
|
})
|
|
210
213
|
return
|
|
211
214
|
}
|
|
@@ -6,13 +6,13 @@ export interface RecordResumeTimerParameters {
|
|
|
6
6
|
canPauseResume: boolean
|
|
7
7
|
recordElapsedTime: number
|
|
8
8
|
recordStartTime: number
|
|
9
|
-
recordTimerInterval?:
|
|
9
|
+
recordTimerInterval?: ReturnType<typeof setInterval> | null
|
|
10
10
|
showAlert?: ShowAlert
|
|
11
11
|
recordPaused: boolean
|
|
12
12
|
recordStopped: boolean
|
|
13
13
|
roomName: string | null
|
|
14
14
|
updateRecordStartTime: (time: number) => void
|
|
15
|
-
updateRecordTimerInterval: (interval:
|
|
15
|
+
updateRecordTimerInterval: (interval: ReturnType<typeof setInterval> | null) => void
|
|
16
16
|
updateIsTimerRunning: (isRunning: boolean) => void
|
|
17
17
|
updateCanPauseResume: (canPause: boolean) => void
|
|
18
18
|
updateRecordElapsedTime: (elapsed: number) => void
|
|
@@ -2,7 +2,7 @@ import { recordUpdateTimer } from './recordUpdateTimer'
|
|
|
2
2
|
|
|
3
3
|
export interface RecordStartTimerParameters {
|
|
4
4
|
recordStartTime: number
|
|
5
|
-
recordTimerInterval?:
|
|
5
|
+
recordTimerInterval?: ReturnType<typeof setInterval> | null
|
|
6
6
|
isTimerRunning: boolean
|
|
7
7
|
canPauseResume: boolean
|
|
8
8
|
recordChangeSeconds: number
|
|
@@ -10,7 +10,7 @@ export interface RecordStartTimerParameters {
|
|
|
10
10
|
recordStopped: boolean
|
|
11
11
|
roomName: string | null
|
|
12
12
|
updateRecordStartTime: (time: number) => void
|
|
13
|
-
updateRecordTimerInterval: (interval:
|
|
13
|
+
updateRecordTimerInterval: (interval: ReturnType<typeof setInterval> | null) => void
|
|
14
14
|
updateIsTimerRunning: (isRunning: boolean) => void
|
|
15
15
|
updateCanPauseResume: (canPause: boolean) => void
|
|
16
16
|
recordElapsedTime: number
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ShowAlert } from '../../types/types';
|
|
2
|
+
|
|
3
|
+
export interface TimeLeftRecordingOptions {
|
|
4
|
+
timeLeft: number;
|
|
5
|
+
showAlert?: ShowAlert;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type TimeLeftRecordingType = (options: TimeLeftRecordingOptions) => void;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Shows a short warning that the current recording session is about to end.
|
|
12
|
+
*
|
|
13
|
+
* @param options Function options including the remaining recording time in seconds.
|
|
14
|
+
*/
|
|
15
|
+
export const timeLeftRecording = ({ timeLeft, showAlert }: TimeLeftRecordingOptions): void => {
|
|
16
|
+
try {
|
|
17
|
+
showAlert?.({
|
|
18
|
+
message: `The recording will stop in less than ${timeLeft} seconds.`,
|
|
19
|
+
duration: 3000,
|
|
20
|
+
type: 'danger',
|
|
21
|
+
});
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.log('Error in timeLeftRecording: ', error);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { Request, RequestResponse, ShowAlert } from '../../types/types';
|
|
2
|
+
|
|
3
|
+
export interface HostRequestResponseOptions {
|
|
4
|
+
requestResponse: RequestResponse;
|
|
5
|
+
showAlert?: ShowAlert;
|
|
6
|
+
requestList: Request[];
|
|
7
|
+
updateRequestList: (requestList: Request[]) => void;
|
|
8
|
+
updateMicAction: (action: boolean) => void;
|
|
9
|
+
updateVideoAction: (action: boolean) => void;
|
|
10
|
+
updateScreenAction: (action: boolean) => void;
|
|
11
|
+
updateChatAction: (action: boolean) => void;
|
|
12
|
+
updateAudioRequestState: (state: string | null) => void;
|
|
13
|
+
updateVideoRequestState: (state: string | null) => void;
|
|
14
|
+
updateScreenRequestState: (state: string | null) => void;
|
|
15
|
+
updateChatRequestState: (state: string | null) => void;
|
|
16
|
+
updateAudioRequestTime: (time: number) => void;
|
|
17
|
+
updateVideoRequestTime: (time: number) => void;
|
|
18
|
+
updateScreenRequestTime: (time: number) => void;
|
|
19
|
+
updateChatRequestTime: (time: number) => void;
|
|
20
|
+
updateRequestIntervalSeconds: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type HostRequestResponseType = (options: HostRequestResponseOptions) => Promise<void>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Applies a host's response to a pending participant request.
|
|
27
|
+
*
|
|
28
|
+
* This helper removes the resolved request from the pending list, updates the
|
|
29
|
+
* caller's relevant request state, and triggers acceptance or rejection alerts
|
|
30
|
+
* with the correct retry cooldown timestamps.
|
|
31
|
+
*
|
|
32
|
+
* @param options Function options for processing the host response.
|
|
33
|
+
* @returns A promise that resolves after request state has been updated.
|
|
34
|
+
*/
|
|
35
|
+
export const hostRequestResponse = async ({
|
|
36
|
+
requestResponse,
|
|
37
|
+
showAlert,
|
|
38
|
+
requestList,
|
|
39
|
+
updateRequestList,
|
|
40
|
+
updateMicAction,
|
|
41
|
+
updateVideoAction,
|
|
42
|
+
updateScreenAction,
|
|
43
|
+
updateChatAction,
|
|
44
|
+
updateAudioRequestState,
|
|
45
|
+
updateVideoRequestState,
|
|
46
|
+
updateScreenRequestState,
|
|
47
|
+
updateChatRequestState,
|
|
48
|
+
updateAudioRequestTime,
|
|
49
|
+
updateVideoRequestTime,
|
|
50
|
+
updateScreenRequestTime,
|
|
51
|
+
updateChatRequestTime,
|
|
52
|
+
updateRequestIntervalSeconds,
|
|
53
|
+
}: HostRequestResponseOptions): Promise<void> => {
|
|
54
|
+
const requestType = requestResponse.type ?? requestResponse.icon;
|
|
55
|
+
|
|
56
|
+
// Remove only the specific request that received a host response.
|
|
57
|
+
const filteredRequests = requestList.filter(
|
|
58
|
+
(request) => {
|
|
59
|
+
const matchesId = request.id === requestResponse.id;
|
|
60
|
+
const matchesType = requestType == null || request.icon === requestType;
|
|
61
|
+
const matchesName = requestResponse.name == null || request.name === requestResponse.name;
|
|
62
|
+
const matchesUsername =
|
|
63
|
+
requestResponse.username == null || request.username === requestResponse.username;
|
|
64
|
+
|
|
65
|
+
return !(matchesId && matchesType && matchesName && matchesUsername);
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
updateRequestList(filteredRequests);
|
|
69
|
+
|
|
70
|
+
if (requestResponse.action === 'accepted') {
|
|
71
|
+
switch (requestType) {
|
|
72
|
+
case 'fa-microphone':
|
|
73
|
+
showAlert?.({
|
|
74
|
+
message: 'Unmute request was accepted; click the mic button again to begin.',
|
|
75
|
+
type: 'success',
|
|
76
|
+
duration: 10000,
|
|
77
|
+
});
|
|
78
|
+
updateMicAction(true);
|
|
79
|
+
updateAudioRequestState('accepted');
|
|
80
|
+
break;
|
|
81
|
+
case 'fa-video':
|
|
82
|
+
showAlert?.({
|
|
83
|
+
message: 'Video request was accepted; click the video button again to begin.',
|
|
84
|
+
type: 'success',
|
|
85
|
+
duration: 10000,
|
|
86
|
+
});
|
|
87
|
+
updateVideoAction(true);
|
|
88
|
+
updateVideoRequestState('accepted');
|
|
89
|
+
break;
|
|
90
|
+
case 'fa-desktop':
|
|
91
|
+
showAlert?.({
|
|
92
|
+
message: 'Screenshare request was accepted; click the screen button again to begin.',
|
|
93
|
+
type: 'success',
|
|
94
|
+
duration: 10000,
|
|
95
|
+
});
|
|
96
|
+
updateScreenAction(true);
|
|
97
|
+
updateScreenRequestState('accepted');
|
|
98
|
+
break;
|
|
99
|
+
case 'fa-comments':
|
|
100
|
+
showAlert?.({
|
|
101
|
+
message: 'Chat request was accepted; click the chat button again to begin.',
|
|
102
|
+
type: 'success',
|
|
103
|
+
duration: 10000,
|
|
104
|
+
});
|
|
105
|
+
updateChatAction(true);
|
|
106
|
+
updateChatRequestState('accepted');
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
let timerDate: Date;
|
|
111
|
+
switch (requestType) {
|
|
112
|
+
case 'fa-microphone':
|
|
113
|
+
showAlert?.({
|
|
114
|
+
message: 'Unmute request was not accepted',
|
|
115
|
+
type: 'danger',
|
|
116
|
+
duration: 10000,
|
|
117
|
+
});
|
|
118
|
+
updateAudioRequestState('rejected');
|
|
119
|
+
timerDate = new Date();
|
|
120
|
+
timerDate.setSeconds(timerDate.getSeconds() + updateRequestIntervalSeconds);
|
|
121
|
+
updateAudioRequestTime(timerDate.getTime());
|
|
122
|
+
break;
|
|
123
|
+
case 'fa-video':
|
|
124
|
+
showAlert?.({
|
|
125
|
+
message: 'Video request was not accepted',
|
|
126
|
+
type: 'danger',
|
|
127
|
+
duration: 10000,
|
|
128
|
+
});
|
|
129
|
+
updateVideoRequestState('rejected');
|
|
130
|
+
timerDate = new Date();
|
|
131
|
+
timerDate.setSeconds(timerDate.getSeconds() + updateRequestIntervalSeconds);
|
|
132
|
+
updateVideoRequestTime(timerDate.getTime());
|
|
133
|
+
break;
|
|
134
|
+
case 'fa-desktop':
|
|
135
|
+
showAlert?.({
|
|
136
|
+
message: 'Screenshare request was not accepted',
|
|
137
|
+
type: 'danger',
|
|
138
|
+
duration: 10000,
|
|
139
|
+
});
|
|
140
|
+
updateScreenRequestState('rejected');
|
|
141
|
+
timerDate = new Date();
|
|
142
|
+
timerDate.setSeconds(timerDate.getSeconds() + updateRequestIntervalSeconds);
|
|
143
|
+
updateScreenRequestTime(timerDate.getTime());
|
|
144
|
+
break;
|
|
145
|
+
case 'fa-comments':
|
|
146
|
+
showAlert?.({
|
|
147
|
+
message: 'Chat request was not accepted',
|
|
148
|
+
type: 'danger',
|
|
149
|
+
duration: 10000,
|
|
150
|
+
});
|
|
151
|
+
updateChatRequestState('rejected');
|
|
152
|
+
timerDate = new Date();
|
|
153
|
+
timerDate.setSeconds(timerDate.getSeconds() + updateRequestIntervalSeconds);
|
|
154
|
+
updateChatRequestTime(timerDate.getTime());
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
@@ -46,7 +46,7 @@ export type ModifySettingsType = (options: ModifySettingsOptions) => Promise<voi
|
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
48
|
export async function modifySettings({
|
|
49
|
-
showAlert,
|
|
49
|
+
// showAlert,
|
|
50
50
|
roomName,
|
|
51
51
|
audioSet,
|
|
52
52
|
videoSet,
|
|
@@ -59,23 +59,23 @@ export async function modifySettings({
|
|
|
59
59
|
updateChatSetting,
|
|
60
60
|
updateIsSettingsModalVisible,
|
|
61
61
|
}: ModifySettingsOptions): Promise<void> {
|
|
62
|
-
if (roomName.toLowerCase().startsWith('d')) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
// if (roomName.toLowerCase().startsWith('d')) {
|
|
63
|
+
// // none should be approval
|
|
64
|
+
// if (
|
|
65
|
+
// audioSet === 'approval' ||
|
|
66
|
+
// videoSet === 'approval' ||
|
|
67
|
+
// screenshareSet === 'approval' ||
|
|
68
|
+
// chatSet === 'approval'
|
|
69
|
+
// ) {
|
|
70
|
+
// showAlert?.({
|
|
71
|
+
// message: 'You cannot set approval for demo mode.',
|
|
72
|
+
// type: 'danger',
|
|
73
|
+
// duration: 3000,
|
|
74
|
+
// });
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
76
|
+
// return;
|
|
77
|
+
// }
|
|
78
|
+
// }
|
|
79
79
|
|
|
80
80
|
// Check and update state variables based on the provided logic
|
|
81
81
|
if (audioSet) {
|