mediasfu-shared 1.0.0
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 -0
- package/README.md +228 -0
- package/dist/index.cjs +7707 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7285 -0
- package/dist/index.js +7690 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -0
- package/src/ProducerClient/producerClientEmits/createDeviceClient.ts +68 -0
- package/src/consumers/addVideosGrid.ts +18 -0
- package/src/consumers/autoAdjust.ts +100 -0
- package/src/consumers/calculateRowsAndColumns.ts +51 -0
- package/src/consumers/changeVids.ts +753 -0
- package/src/consumers/checkGrid.ts +100 -0
- package/src/consumers/checkPermission.ts +89 -0
- package/src/consumers/checkScreenShare.ts +114 -0
- package/src/consumers/closeAndResize.ts +401 -0
- package/src/consumers/compareActiveNames.ts +122 -0
- package/src/consumers/compareScreenStates.ts +117 -0
- package/src/consumers/connectIps.ts +175 -0
- package/src/consumers/connectLocalIps.ts +103 -0
- package/src/consumers/connectRecvTransport.ts +158 -0
- package/src/consumers/connectSendTransport.ts +150 -0
- package/src/consumers/connectSendTransportAudio.ts +161 -0
- package/src/consumers/connectSendTransportScreen.ts +169 -0
- package/src/consumers/connectSendTransportVideo.ts +149 -0
- package/src/consumers/consumerResume.ts +25 -0
- package/src/consumers/controlMedia.ts +118 -0
- package/src/consumers/createSendTransport.ts +312 -0
- package/src/consumers/disconnectSendTransportAudio.ts +170 -0
- package/src/consumers/disconnectSendTransportScreen.ts +130 -0
- package/src/consumers/disconnectSendTransportVideo.ts +161 -0
- package/src/consumers/dispStreams.ts +694 -0
- package/src/consumers/generatePageContent.ts +118 -0
- package/src/consumers/getEstimate.ts +124 -0
- package/src/consumers/getPipedProducersAlt.ts +96 -0
- package/src/consumers/getProducersPiped.ts +89 -0
- package/src/consumers/getVideos.ts +107 -0
- package/src/consumers/mixStreams.ts +97 -0
- package/src/consumers/onScreenChanges.ts +106 -0
- package/src/consumers/prepopulateUserMedia.ts +18 -0
- package/src/consumers/processConsumerTransports.ts +157 -0
- package/src/consumers/processConsumerTransportsAudio.ts +121 -0
- package/src/consumers/rePort.ts +123 -0
- package/src/consumers/reUpdateInter.ts +289 -0
- package/src/consumers/readjust.ts +170 -0
- package/src/consumers/receiveAllPipedTransports.ts +77 -0
- package/src/consumers/receiveRoomMessages.ts +55 -0
- package/src/consumers/reorderStreams.ts +246 -0
- package/src/consumers/requestScreenShare.ts +103 -0
- package/src/consumers/resumePauseAudioStreams.ts +174 -0
- package/src/consumers/resumePauseStreams.ts +110 -0
- package/src/consumers/resumeSendTransportAudio.ts +143 -0
- package/src/consumers/signalNewConsumerTransport.ts +179 -0
- package/src/consumers/socketReceiveMethods/joinConsumeRoom.ts +130 -0
- package/src/consumers/socketReceiveMethods/newPipeProducer.ts +138 -0
- package/src/consumers/socketReceiveMethods/producerClosed.ts +102 -0
- package/src/consumers/startShareScreen.ts +124 -0
- package/src/consumers/stopShareScreen.ts +241 -0
- package/src/consumers/streamSuccessAudio.ts +297 -0
- package/src/consumers/streamSuccessAudioSwitch.ts +315 -0
- package/src/consumers/streamSuccessScreen.ts +255 -0
- package/src/consumers/streamSuccessVideo.ts +373 -0
- package/src/consumers/switchUserAudio.ts +140 -0
- package/src/consumers/switchUserVideo.ts +201 -0
- package/src/consumers/switchUserVideoAlt.ts +331 -0
- package/src/consumers/trigger.ts +250 -0
- package/src/consumers/updateMiniCardsGrid.ts +150 -0
- package/src/consumers/updateParticipantAudioDecibels.ts +56 -0
- package/src/index.ts +119 -0
- package/src/methods/background/launchBackground.ts +16 -0
- package/src/methods/breakoutRooms/breakoutRoomUpdated.ts +161 -0
- package/src/methods/breakoutRooms/handleStartBreakout.ts +96 -0
- package/src/methods/breakoutRooms/handleStopBreakout.ts +72 -0
- package/src/methods/breakoutRooms/index.ts +4 -0
- package/src/methods/breakoutRooms/launchBreakoutRooms.ts +31 -0
- package/src/methods/coHost/launchCoHost.ts +28 -0
- package/src/methods/coHostMethods/index.ts +2 -0
- package/src/methods/coHostMethods/modifyCoHostSettings.ts +94 -0
- package/src/methods/displaySettings/index.ts +1 -0
- package/src/methods/displaySettings/launchDisplaySettings.ts +31 -0
- package/src/methods/displaySettings/modifyDisplaySettings.ts +242 -0
- package/src/methods/exit/confirmExit.ts +60 -0
- package/src/methods/exit/index.ts +2 -0
- package/src/methods/exit/launchConfirmExit.ts +29 -0
- package/src/methods/index.ts +5 -0
- package/src/methods/mediaSettings/launchMediaSettings.ts +61 -0
- package/src/methods/menu/launchMenuModal.ts +28 -0
- package/src/methods/message/index.ts +1 -0
- package/src/methods/message/launchMessages.ts +27 -0
- package/src/methods/message/sendMessage.ts +175 -0
- package/src/methods/participants/index.ts +3 -0
- package/src/methods/participants/launchParticipants.ts +25 -0
- package/src/methods/participants/messageParticipants.ts +78 -0
- package/src/methods/participants/muteParticipants.ts +79 -0
- package/src/methods/participants/removeParticipants.ts +97 -0
- package/src/methods/polls/handleCreatePoll.ts +66 -0
- package/src/methods/polls/handleEndPoll.ts +64 -0
- package/src/methods/polls/handleVotePoll.ts +76 -0
- package/src/methods/polls/index.ts +3 -0
- package/src/methods/polls/launchPoll.ts +25 -0
- package/src/methods/prejoin/handleCreateRoom.ts +441 -0
- package/src/methods/prejoin/handleJoinRoom.ts +153 -0
- package/src/methods/prejoin/index.ts +14 -0
- package/src/methods/recording/checkPauseState.ts +57 -0
- package/src/methods/recording/checkResumeState.ts +42 -0
- package/src/methods/recording/confirmRecording.ts +241 -0
- package/src/methods/recording/launchRecording.ts +114 -0
- package/src/methods/recording/recordPauseTimer.ts +52 -0
- package/src/methods/recording/recordResumeTimer.ts +92 -0
- package/src/methods/recording/recordStartTimer.ts +106 -0
- package/src/methods/recording/recordUpdateTimer.ts +49 -0
- package/src/methods/recording/startRecording.ts +268 -0
- package/src/methods/recording/stopRecording.ts +124 -0
- package/src/methods/recording/updateRecording.ts +245 -0
- package/src/methods/requests/index.ts +1 -0
- package/src/methods/requests/launchRequests.ts +25 -0
- package/src/methods/requests/respondToRequests.ts +108 -0
- package/src/methods/settings/index.ts +2 -0
- package/src/methods/settings/launchSettings.ts +25 -0
- package/src/methods/settings/modifySettings.ts +99 -0
- package/src/methods/stream/clickVideo.ts +337 -0
- package/src/methods/stream/index.ts +3 -0
- package/src/methods/stream/switchAudio.ts +73 -0
- package/src/methods/stream/switchVideo.ts +148 -0
- package/src/methods/stream/switchVideoAlt.ts +152 -0
- package/src/methods/utils/checkLimitsAndMakeRequest.ts +103 -0
- package/src/methods/utils/validateAlphanumeric.ts +41 -0
- package/src/methods/waiting/index.ts +1 -0
- package/src/methods/waiting/launchWaiting.ts +26 -0
- package/src/methods/waiting/respondToWaiting.ts +82 -0
- package/src/methods/welcome/handleWelcomeRequest.ts +189 -0
- package/src/methods/welcome/index.ts +5 -0
- package/src/methods/whiteboard/handleStartWhiteboard.ts +65 -0
- package/src/methods/whiteboard/handleStopWhiteboard.ts +48 -0
- package/src/methods/whiteboard/index.ts +4 -0
- package/src/methods/whiteboard/launchConfigureWhiteboard.ts +29 -0
- package/src/producers/producerEmits/joinConRoom.ts +153 -0
- package/src/sockets/SocketManager.ts +232 -0
- package/src/types/shared-base-types.ts +752 -0
- package/src/types/types.ts +84 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BreakoutParticipant,
|
|
3
|
+
BreakoutRoomUpdatedData,
|
|
4
|
+
OnScreenChangesParameters,
|
|
5
|
+
OnScreenChangesType,
|
|
6
|
+
Participant,
|
|
7
|
+
RePortParameters,
|
|
8
|
+
RePortType,
|
|
9
|
+
} from '../../types/types'
|
|
10
|
+
|
|
11
|
+
export interface BreakoutRoomUpdatedParameters extends OnScreenChangesParameters, RePortParameters {
|
|
12
|
+
breakOutRoomStarted: boolean
|
|
13
|
+
breakOutRoomEnded: boolean
|
|
14
|
+
breakoutRooms: BreakoutParticipant[][]
|
|
15
|
+
hostNewRoom: number
|
|
16
|
+
islevel: string
|
|
17
|
+
participantsAll: Participant[]
|
|
18
|
+
participants: Participant[]
|
|
19
|
+
meetingDisplayType: string
|
|
20
|
+
prevMeetingDisplayType: string
|
|
21
|
+
updateBreakoutRooms: (rooms: BreakoutParticipant[][]) => void
|
|
22
|
+
updateBreakOutRoomStarted: (started: boolean) => void
|
|
23
|
+
updateBreakOutRoomEnded: (ended: boolean) => void
|
|
24
|
+
updateHostNewRoom: (room: number) => void
|
|
25
|
+
updateMeetingDisplayType: (type: string) => void
|
|
26
|
+
updateParticipantsAll: (participants: Participant[]) => void
|
|
27
|
+
updateParticipants: (participants: Participant[]) => void
|
|
28
|
+
onScreenChanges: OnScreenChangesType
|
|
29
|
+
rePort: RePortType
|
|
30
|
+
getUpdatedAllParams: () => BreakoutRoomUpdatedParameters
|
|
31
|
+
[key: string]: any
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface BreakoutRoomUpdatedOptions {
|
|
35
|
+
data: BreakoutRoomUpdatedData
|
|
36
|
+
parameters: BreakoutRoomUpdatedParameters
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type BreakoutRoomUpdatedType = (options: BreakoutRoomUpdatedOptions) => Promise<void>
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Updates the state of breakout rooms based on the provided data and parameters.
|
|
43
|
+
*
|
|
44
|
+
* @param {BreakoutRoomUpdatedOptions} options - The options object.
|
|
45
|
+
* @param {BreakoutRoomUpdatedData} options.data - The data object containing information about the breakout rooms.
|
|
46
|
+
* @param {BreakoutRoomUpdatedParameters} options.parameters - The parameters object containing various state update functions and other parameters.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const breakoutOptions: BreakoutRoomUpdatedOptions = {
|
|
51
|
+
* data: breakoutData,
|
|
52
|
+
* parameters: {
|
|
53
|
+
* breakOutRoomStarted: false,
|
|
54
|
+
* breakOutRoomEnded: false,
|
|
55
|
+
* breakoutRooms: [[]],
|
|
56
|
+
* hostNewRoom: 1,
|
|
57
|
+
* islevel: '2',
|
|
58
|
+
* participantsAll: allParticipants,
|
|
59
|
+
* participants: activeParticipants,
|
|
60
|
+
* meetingDisplayType: 'all',
|
|
61
|
+
* prevMeetingDisplayType: 'video',
|
|
62
|
+
* updateBreakoutRooms: setBreakoutRooms,
|
|
63
|
+
* updateBreakOutRoomStarted: setBreakOutRoomStarted,
|
|
64
|
+
* updateBreakOutRoomEnded: setBreakOutRoomEnded,
|
|
65
|
+
* updateHostNewRoom: setHostNewRoom,
|
|
66
|
+
* updateMeetingDisplayType: setMeetingDisplayType,
|
|
67
|
+
* updateParticipantsAll: setAllParticipants,
|
|
68
|
+
* updateParticipants: setActiveParticipants,
|
|
69
|
+
* onScreenChanges: handleScreenChanges,
|
|
70
|
+
* rePort: reportFunction,
|
|
71
|
+
* getUpdatedAllParams: () => breakoutOptions.parameters,
|
|
72
|
+
* },
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
* await breakoutRoomUpdated(breakoutOptions)
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export const breakoutRoomUpdated: BreakoutRoomUpdatedType = async ({ data, parameters }) => {
|
|
79
|
+
try {
|
|
80
|
+
let {
|
|
81
|
+
breakOutRoomStarted,
|
|
82
|
+
breakOutRoomEnded,
|
|
83
|
+
breakoutRooms,
|
|
84
|
+
hostNewRoom,
|
|
85
|
+
islevel,
|
|
86
|
+
participantsAll,
|
|
87
|
+
participants,
|
|
88
|
+
meetingDisplayType,
|
|
89
|
+
prevMeetingDisplayType,
|
|
90
|
+
updateBreakoutRooms,
|
|
91
|
+
updateBreakOutRoomStarted,
|
|
92
|
+
updateBreakOutRoomEnded,
|
|
93
|
+
updateHostNewRoom,
|
|
94
|
+
updateMeetingDisplayType,
|
|
95
|
+
updateParticipantsAll,
|
|
96
|
+
updateParticipants,
|
|
97
|
+
onScreenChanges,
|
|
98
|
+
rePort,
|
|
99
|
+
} = parameters
|
|
100
|
+
|
|
101
|
+
if (data.forHost) {
|
|
102
|
+
hostNewRoom = data.newRoom!
|
|
103
|
+
updateHostNewRoom(hostNewRoom!)
|
|
104
|
+
await onScreenChanges({ changed: true, parameters })
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (islevel === '2' && data.members) {
|
|
109
|
+
participantsAll = data.members.map((participant) => ({
|
|
110
|
+
isBanned: participant.isBanned,
|
|
111
|
+
name: participant.name,
|
|
112
|
+
audioID: participant.audioID,
|
|
113
|
+
videoID: participant.videoID,
|
|
114
|
+
}))
|
|
115
|
+
updateParticipantsAll(participantsAll)
|
|
116
|
+
|
|
117
|
+
participants = data.members.filter((participant) => !participant.isBanned)
|
|
118
|
+
updateParticipants(participants)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
breakoutRooms = data.breakoutRooms || []
|
|
122
|
+
updateBreakoutRooms(breakoutRooms)
|
|
123
|
+
|
|
124
|
+
if (data.status === 'started' && (!breakOutRoomStarted || breakOutRoomEnded)) {
|
|
125
|
+
breakOutRoomStarted = true
|
|
126
|
+
breakOutRoomEnded = false
|
|
127
|
+
updateBreakOutRoomStarted(true)
|
|
128
|
+
updateBreakOutRoomEnded(false)
|
|
129
|
+
prevMeetingDisplayType = meetingDisplayType
|
|
130
|
+
if (meetingDisplayType !== 'all') {
|
|
131
|
+
meetingDisplayType = 'all'
|
|
132
|
+
updateMeetingDisplayType('all')
|
|
133
|
+
}
|
|
134
|
+
await onScreenChanges({ changed: true, parameters })
|
|
135
|
+
if (islevel === '2') {
|
|
136
|
+
await rePort({ restart: true, parameters })
|
|
137
|
+
}
|
|
138
|
+
} else if (data.status === 'ended') {
|
|
139
|
+
breakOutRoomEnded = true
|
|
140
|
+
updateBreakOutRoomEnded(true)
|
|
141
|
+
if (meetingDisplayType !== prevMeetingDisplayType) {
|
|
142
|
+
updateMeetingDisplayType(prevMeetingDisplayType)
|
|
143
|
+
}
|
|
144
|
+
await onScreenChanges({ changed: true, parameters })
|
|
145
|
+
if (islevel === '2') {
|
|
146
|
+
await rePort({ restart: true, parameters })
|
|
147
|
+
}
|
|
148
|
+
} else if (data.status === 'started' && breakOutRoomStarted) {
|
|
149
|
+
breakOutRoomStarted = true
|
|
150
|
+
breakOutRoomEnded = false
|
|
151
|
+
updateBreakOutRoomStarted(true)
|
|
152
|
+
updateBreakOutRoomEnded(false)
|
|
153
|
+
await onScreenChanges({ changed: true, parameters })
|
|
154
|
+
if (islevel === '2') {
|
|
155
|
+
await rePort({ restart: true, parameters })
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} catch {
|
|
159
|
+
// Handle error
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Socket } from 'socket.io-client';
|
|
2
|
+
import type { ShowAlert } from '../../types/types';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export interface HandleStartBreakoutOptions {
|
|
7
|
+
socket: Socket;
|
|
8
|
+
localSocket?: Socket;
|
|
9
|
+
breakoutRooms: Array<Array<{ name: string; breakRoom?: number | null }>>;
|
|
10
|
+
newParticipantAction: string;
|
|
11
|
+
roomName: string;
|
|
12
|
+
breakOutRoomStarted: boolean;
|
|
13
|
+
breakOutRoomEnded: boolean;
|
|
14
|
+
showAlert?: ShowAlert;
|
|
15
|
+
updateBreakOutRoomStarted: (started: boolean) => void;
|
|
16
|
+
updateBreakOutRoomEnded: (ended: boolean) => void;
|
|
17
|
+
onBreakoutRoomsClose: () => void;
|
|
18
|
+
meetingDisplayType: string;
|
|
19
|
+
updateMeetingDisplayType: (displayType: string) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type HandleStartBreakoutType = (options: HandleStartBreakoutOptions) => void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Handles the start of breakout rooms.
|
|
26
|
+
* @function
|
|
27
|
+
* @param {HandleStartBreakoutOptions} options - The options for starting breakout rooms.
|
|
28
|
+
* @param {Socket} options.socket - The main socket instance.
|
|
29
|
+
* @param {Socket} [options.localSocket] - The local socket instance (optional).
|
|
30
|
+
* @param {Array<Array<{name: string, breakRoom: number | null}>>} options.breakoutRooms - The array of breakout rooms with participant data.
|
|
31
|
+
* @param {string} options.newParticipantAction - The action to take for new participants.
|
|
32
|
+
* @param {string} options.roomName - The name of the main room.
|
|
33
|
+
* @param {boolean} options.breakOutRoomStarted - Whether breakout rooms have already started.
|
|
34
|
+
* @param {boolean} options.breakOutRoomEnded - Whether breakout rooms have ended.
|
|
35
|
+
* @param {ShowAlert} [options.showAlert] - Function to show alerts.
|
|
36
|
+
* @param {Function} options.updateBreakOutRoomStarted - Function to update breakout room started state.
|
|
37
|
+
* @param {Function} options.updateBreakOutRoomEnded - Function to update breakout room ended state.
|
|
38
|
+
* @param {Function} options.onBreakoutRoomsClose - Function to close breakout rooms modal.
|
|
39
|
+
* @param {string} options.meetingDisplayType - Current meeting display type.
|
|
40
|
+
* @param {Function} options.updateMeetingDisplayType - Function to update meeting display type.
|
|
41
|
+
* @returns {void}
|
|
42
|
+
*/
|
|
43
|
+
export const handleStartBreakout = ({
|
|
44
|
+
socket,
|
|
45
|
+
localSocket,
|
|
46
|
+
breakoutRooms,
|
|
47
|
+
newParticipantAction,
|
|
48
|
+
roomName,
|
|
49
|
+
breakOutRoomStarted,
|
|
50
|
+
breakOutRoomEnded,
|
|
51
|
+
showAlert,
|
|
52
|
+
updateBreakOutRoomStarted,
|
|
53
|
+
updateBreakOutRoomEnded,
|
|
54
|
+
onBreakoutRoomsClose,
|
|
55
|
+
meetingDisplayType,
|
|
56
|
+
updateMeetingDisplayType,
|
|
57
|
+
}: HandleStartBreakoutOptions): void => {
|
|
58
|
+
const emitName = breakOutRoomStarted && !breakOutRoomEnded ? 'updateBreakout' : 'startBreakout';
|
|
59
|
+
const filteredBreakoutRooms = breakoutRooms.map((room) =>
|
|
60
|
+
room.map(({ name, breakRoom }) => ({ name, breakRoom }))
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
socket.emit(
|
|
64
|
+
emitName,
|
|
65
|
+
{ breakoutRooms: filteredBreakoutRooms, newParticipantAction, roomName },
|
|
66
|
+
(response: { success: boolean; reason: string }) => {
|
|
67
|
+
if (response.success) {
|
|
68
|
+
showAlert?.({ message: 'Breakout rooms active', type: 'success' });
|
|
69
|
+
updateBreakOutRoomStarted(true);
|
|
70
|
+
updateBreakOutRoomEnded(false);
|
|
71
|
+
onBreakoutRoomsClose();
|
|
72
|
+
if (meetingDisplayType !== 'all') {
|
|
73
|
+
updateMeetingDisplayType('all');
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
showAlert?.({ message: response.reason, type: 'danger' });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (localSocket && localSocket.id) {
|
|
82
|
+
try {
|
|
83
|
+
localSocket.emit(
|
|
84
|
+
emitName,
|
|
85
|
+
{ breakoutRooms: filteredBreakoutRooms, newParticipantAction, roomName },
|
|
86
|
+
(response: { success: boolean; reason: string }) => {
|
|
87
|
+
if (response.success) {
|
|
88
|
+
// do nothing
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
} catch {
|
|
93
|
+
console.log('Error starting local breakout rooms:');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Socket } from 'socket.io-client';
|
|
2
|
+
import type { ShowAlert } from '../../types/types';
|
|
3
|
+
|
|
4
|
+
export interface HandleStopBreakoutOptions {
|
|
5
|
+
socket: Socket;
|
|
6
|
+
localSocket?: Socket;
|
|
7
|
+
roomName: string;
|
|
8
|
+
showAlert?: ShowAlert;
|
|
9
|
+
updateBreakOutRoomStarted: (started: boolean) => void;
|
|
10
|
+
updateBreakOutRoomEnded: (ended: boolean) => void;
|
|
11
|
+
onBreakoutRoomsClose: () => void;
|
|
12
|
+
meetingDisplayType: string;
|
|
13
|
+
prevMeetingDisplayType: string;
|
|
14
|
+
updateMeetingDisplayType: (displayType: string) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type HandleStopBreakoutType = (options: HandleStopBreakoutOptions) => void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Handles stopping breakout rooms.
|
|
21
|
+
* @function
|
|
22
|
+
* @param {HandleStopBreakoutOptions} options - The options for stopping breakout rooms.
|
|
23
|
+
* @param {Socket} options.socket - The main socket instance.
|
|
24
|
+
* @param {Socket} [options.localSocket] - The local socket instance (optional).
|
|
25
|
+
* @param {string} options.roomName - The name of the main room.
|
|
26
|
+
* @param {ShowAlert} [options.showAlert] - Function to show alerts.
|
|
27
|
+
* @param {Function} options.updateBreakOutRoomStarted - Function to update breakout room started state.
|
|
28
|
+
* @param {Function} options.updateBreakOutRoomEnded - Function to update breakout room ended state.
|
|
29
|
+
* @param {Function} options.onBreakoutRoomsClose - Function to close breakout rooms modal.
|
|
30
|
+
* @param {string} options.meetingDisplayType - Current meeting display type.
|
|
31
|
+
* @param {string} options.prevMeetingDisplayType - Previous meeting display type.
|
|
32
|
+
* @param {Function} options.updateMeetingDisplayType - Function to update meeting display type.
|
|
33
|
+
* @returns {void}
|
|
34
|
+
*/
|
|
35
|
+
export const handleStopBreakout = ({
|
|
36
|
+
socket,
|
|
37
|
+
localSocket,
|
|
38
|
+
roomName,
|
|
39
|
+
showAlert,
|
|
40
|
+
updateBreakOutRoomStarted,
|
|
41
|
+
updateBreakOutRoomEnded,
|
|
42
|
+
onBreakoutRoomsClose,
|
|
43
|
+
meetingDisplayType,
|
|
44
|
+
prevMeetingDisplayType,
|
|
45
|
+
updateMeetingDisplayType,
|
|
46
|
+
}: HandleStopBreakoutOptions): void => {
|
|
47
|
+
socket.emit('stopBreakout', { roomName }, (response: { success: boolean; reason: string }) => {
|
|
48
|
+
if (response.success) {
|
|
49
|
+
showAlert?.({ message: 'Breakout rooms stopped', type: 'success' });
|
|
50
|
+
updateBreakOutRoomStarted(false);
|
|
51
|
+
updateBreakOutRoomEnded(true);
|
|
52
|
+
onBreakoutRoomsClose();
|
|
53
|
+
if (meetingDisplayType !== prevMeetingDisplayType) {
|
|
54
|
+
updateMeetingDisplayType(prevMeetingDisplayType);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
showAlert?.({ message: response.reason, type: 'danger' });
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (localSocket && localSocket.id) {
|
|
62
|
+
try {
|
|
63
|
+
localSocket.emit('stopBreakout', { roomName }, (response: { success: boolean; reason: string }) => {
|
|
64
|
+
if (response.success) {
|
|
65
|
+
// do nothing
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
} catch {
|
|
69
|
+
console.log('Error stopping local breakout rooms:');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { handleStartBreakout } from './handleStartBreakout';
|
|
2
|
+
export type { HandleStartBreakoutOptions, HandleStartBreakoutType } from './handleStartBreakout';
|
|
3
|
+
export { handleStopBreakout } from './handleStopBreakout';
|
|
4
|
+
export type { HandleStopBreakoutOptions, HandleStopBreakoutType } from './handleStopBreakout';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface LaunchBreakoutRoomsOptions {
|
|
2
|
+
updateIsBreakoutRoomsModalVisible: (isVisible: boolean) => void
|
|
3
|
+
isBreakoutRoomsModalVisible: boolean
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type LaunchBreakoutRoomsType = (options: LaunchBreakoutRoomsOptions) => void
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Launches the breakout rooms by toggling the visibility of the breakout rooms modal.
|
|
10
|
+
*
|
|
11
|
+
* @param {LaunchBreakoutRoomsOptions} options - The options object.
|
|
12
|
+
* @param {Function} options.updateIsBreakoutRoomsModalVisible - Function to update the visibility state of the breakout rooms modal.
|
|
13
|
+
* @param {boolean} options.isBreakoutRoomsModalVisible - Current visibility state of the breakout rooms modal.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const options: LaunchBreakoutRoomsOptions = {
|
|
18
|
+
* updateIsBreakoutRoomsModalVisible: setModalVisible,
|
|
19
|
+
* isBreakoutRoomsModalVisible: false,
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* launchBreakoutRooms(options)
|
|
23
|
+
* // Toggles the breakout rooms modal to visible.
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export const launchBreakoutRooms: LaunchBreakoutRoomsType = ({
|
|
27
|
+
updateIsBreakoutRoomsModalVisible,
|
|
28
|
+
isBreakoutRoomsModalVisible,
|
|
29
|
+
}) => {
|
|
30
|
+
updateIsBreakoutRoomsModalVisible(!isBreakoutRoomsModalVisible)
|
|
31
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface LaunchCoHostOptions {
|
|
2
|
+
updateIsCoHostModalVisible: (isVisible: boolean) => void
|
|
3
|
+
isCoHostModalVisible: boolean
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type LaunchCoHostType = (options: LaunchCoHostOptions) => void
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Toggles the visibility of the co-host modal.
|
|
10
|
+
*
|
|
11
|
+
* @param {LaunchCoHostOptions} options - The options object.
|
|
12
|
+
* @param {Function} options.updateIsCoHostModalVisible - Function to update the visibility state of the co-host modal.
|
|
13
|
+
* @param {boolean} options.isCoHostModalVisible - Current visibility state of the co-host modal.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const options: LaunchCoHostOptions = {
|
|
18
|
+
* updateIsCoHostModalVisible: setModalVisible,
|
|
19
|
+
* isCoHostModalVisible: false,
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* launchCoHost(options)
|
|
23
|
+
* // Toggles the co-host modal to visible.
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export const launchCoHost: LaunchCoHostType = ({ updateIsCoHostModalVisible, isCoHostModalVisible }) => {
|
|
27
|
+
updateIsCoHostModalVisible(!isCoHostModalVisible)
|
|
28
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Socket } from 'socket.io-client';
|
|
2
|
+
import type { ShowAlert, CoHostResponsibility } from '../../types/types';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export interface ModifyCoHostSettingsOptions {
|
|
6
|
+
roomName: string;
|
|
7
|
+
showAlert?: ShowAlert;
|
|
8
|
+
selectedParticipant: string;
|
|
9
|
+
coHost: string;
|
|
10
|
+
coHostResponsibility: CoHostResponsibility[];
|
|
11
|
+
updateIsCoHostModalVisible: (isVisible: boolean) => void;
|
|
12
|
+
updateCoHostResponsibility: (coHostResponsibility: CoHostResponsibility[]) => void;
|
|
13
|
+
updateCoHost: (coHost: string) => void;
|
|
14
|
+
socket: Socket;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type ModifyCoHostSettingsType = (options: ModifyCoHostSettingsOptions) => Promise<void>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Modifies the co-host settings for a given room.
|
|
21
|
+
* @function
|
|
22
|
+
* @param {ModifyCoHostSettingsOptions} options - The options for modifying co-host settings.
|
|
23
|
+
* @param {string} options.roomName - The name of the room.
|
|
24
|
+
* @param {ShowAlert} [options.showAlert] - Function to show an alert message.
|
|
25
|
+
* @param {string} options.selectedParticipant - The participant selected to be co-host.
|
|
26
|
+
* @param {string} options.coHost - The current co-host.
|
|
27
|
+
* @param {CoHostResponsibility[]} options.coHostResponsibility - The responsibilities assigned to the co-host.
|
|
28
|
+
* @param {Function} options.updateIsCoHostModalVisible - Function to update the visibility of the co-host modal.
|
|
29
|
+
* @param {Function} options.updateCoHostResponsibility - Function to update the co-host responsibility.
|
|
30
|
+
* @param {Function} options.updateCoHost - Function to update the co-host.
|
|
31
|
+
* @param {Socket} options.socket - The socket instance for emitting events.
|
|
32
|
+
* @returns {Promise<void>} A promise that resolves when the co-host settings have been modified.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const options: ModifyCoHostSettingsOptions = {
|
|
37
|
+
* roomName: "mainRoom",
|
|
38
|
+
* showAlert: (alert) => console.log(alert.message),
|
|
39
|
+
* selectedParticipant: "User123",
|
|
40
|
+
* coHost: "No coHost",
|
|
41
|
+
* coHostResponsibility: [{ name: "media", value: true, dedicated: false }],
|
|
42
|
+
* updateIsCoHostModalVisible: setModalVisible,
|
|
43
|
+
* updateCoHostResponsibility: setCoHostResponsibility,
|
|
44
|
+
* updateCoHost: setCoHost,
|
|
45
|
+
* socket: socketInstance,
|
|
46
|
+
* };
|
|
47
|
+
*
|
|
48
|
+
* modifyCoHostSettings(options);
|
|
49
|
+
* // Sets User123 as the new co-host with specific responsibilities and emits the update event.
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export const modifyCoHostSettings = async ({
|
|
53
|
+
roomName,
|
|
54
|
+
showAlert,
|
|
55
|
+
selectedParticipant,
|
|
56
|
+
coHost,
|
|
57
|
+
coHostResponsibility,
|
|
58
|
+
updateIsCoHostModalVisible,
|
|
59
|
+
updateCoHostResponsibility,
|
|
60
|
+
updateCoHost,
|
|
61
|
+
socket,
|
|
62
|
+
}: ModifyCoHostSettingsOptions): Promise<void> => {
|
|
63
|
+
// Check if the chat room is in demo mode
|
|
64
|
+
if (roomName.toLowerCase().startsWith('d')) {
|
|
65
|
+
showAlert?.({
|
|
66
|
+
message: 'You cannot add co-host in demo mode.',
|
|
67
|
+
type: 'danger',
|
|
68
|
+
duration: 3000,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let newCoHost = coHost;
|
|
75
|
+
|
|
76
|
+
if (coHost !== 'No coHost' || (selectedParticipant && selectedParticipant !== 'Select a participant')) {
|
|
77
|
+
if (selectedParticipant && selectedParticipant !== 'Select a participant') {
|
|
78
|
+
newCoHost = selectedParticipant;
|
|
79
|
+
updateCoHost(newCoHost);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
updateCoHostResponsibility(coHostResponsibility);
|
|
83
|
+
|
|
84
|
+
// Emit a socket event to update co-host information
|
|
85
|
+
socket.emit('updateCoHost', {
|
|
86
|
+
roomName,
|
|
87
|
+
coHost: newCoHost,
|
|
88
|
+
coHostResponsibility,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Close the co-host modal
|
|
93
|
+
updateIsCoHostModalVisible(false);
|
|
94
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './modifyDisplaySettings'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface LaunchDisplaySettingsOptions {
|
|
2
|
+
updateIsDisplaySettingsModalVisible: (isVisible: boolean) => void
|
|
3
|
+
isDisplaySettingsModalVisible: boolean
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type LaunchDisplaySettingsType = (options: LaunchDisplaySettingsOptions) => void
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Toggles the visibility of the display settings modal.
|
|
10
|
+
*
|
|
11
|
+
* @param {LaunchDisplaySettingsOptions} options - The options object.
|
|
12
|
+
* @param {Function} options.updateIsDisplaySettingsModalVisible - Function to update the visibility state of the display settings modal.
|
|
13
|
+
* @param {boolean} options.isDisplaySettingsModalVisible - Current visibility state of the display settings modal.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const options: LaunchDisplaySettingsOptions = {
|
|
18
|
+
* updateIsDisplaySettingsModalVisible: setModalVisibilityFunction,
|
|
19
|
+
* isDisplaySettingsModalVisible: false,
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* launchDisplaySettings(options)
|
|
23
|
+
* // This will open the display settings modal if it's currently closed, or close it if it's open.
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export const launchDisplaySettings: LaunchDisplaySettingsType = ({
|
|
27
|
+
updateIsDisplaySettingsModalVisible,
|
|
28
|
+
isDisplaySettingsModalVisible,
|
|
29
|
+
}) => {
|
|
30
|
+
updateIsDisplaySettingsModalVisible(!isDisplaySettingsModalVisible)
|
|
31
|
+
}
|