@whereby.com/core 1.17.0 → 1.18.1
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/dist/index.cjs +694 -420
- package/dist/index.d.cts +84 -6
- package/dist/index.d.mts +84 -6
- package/dist/index.d.ts +84 -6
- package/dist/index.mjs +690 -421
- package/dist/legacy-esm.js +690 -421
- package/dist/redux/index.cjs +667 -417
- package/dist/redux/index.d.cts +333 -33
- package/dist/redux/index.d.mts +333 -33
- package/dist/redux/index.d.ts +333 -33
- package/dist/redux/index.js +637 -418
- package/dist/redux/index.mjs +637 -418
- package/package.json +4 -4
package/dist/legacy-esm.js
CHANGED
|
@@ -1224,7 +1224,7 @@ const createReactor = (selectors, callback) => {
|
|
|
1224
1224
|
});
|
|
1225
1225
|
};
|
|
1226
1226
|
|
|
1227
|
-
const coreVersion = "1.
|
|
1227
|
+
const coreVersion = "1.18.1";
|
|
1228
1228
|
|
|
1229
1229
|
function decodeRoomName(roomName) {
|
|
1230
1230
|
if (!roomName) {
|
|
@@ -1287,6 +1287,9 @@ const signalEvents = {
|
|
|
1287
1287
|
breakoutMoveToGroup: createSignalEventAction("breakoutMoveToGroup"),
|
|
1288
1288
|
breakoutMoveToMain: createSignalEventAction("breakoutMoveToMain"),
|
|
1289
1289
|
breakoutSessionUpdated: createSignalEventAction("breakoutSessionUpdated"),
|
|
1290
|
+
breakoutEnding: createSignalEventAction("breakoutEnding"),
|
|
1291
|
+
breakoutTimerEnded: createSignalEventAction("breakoutTimerEnded"),
|
|
1292
|
+
breakoutTimerExtended: createSignalEventAction("breakoutTimerExtended"),
|
|
1290
1293
|
chatMessage: createSignalEventAction("chatMessage"),
|
|
1291
1294
|
chatMessageRemoved: createSignalEventAction("chatMessageRemoved"),
|
|
1292
1295
|
fileSharingError: createSignalEventAction("fileSharingError"),
|
|
@@ -1327,6 +1330,7 @@ const ROOM_ACTION_PERMISSIONS_BY_ROLE = {
|
|
|
1327
1330
|
canEndMeeting: ["host"],
|
|
1328
1331
|
canAskToSpeak: ["host"],
|
|
1329
1332
|
canSpotlight: ["host"],
|
|
1333
|
+
canManageBreakout: ["host"],
|
|
1330
1334
|
};
|
|
1331
1335
|
const authorizationSliceInitialState = {
|
|
1332
1336
|
roomKey: null,
|
|
@@ -1369,6 +1373,7 @@ const selectIsAuthorizedToKickClient = createSelector(selectAuthorizationRoleNam
|
|
|
1369
1373
|
const selectIsAuthorizedToEndMeeting = createSelector(selectAuthorizationRoleName, (localParticipantRole) => ROOM_ACTION_PERMISSIONS_BY_ROLE.canEndMeeting.includes(localParticipantRole));
|
|
1370
1374
|
const selectIsAuthorizedToAskToSpeak = createSelector(selectAuthorizationRoleName, (localParticipantRole) => ROOM_ACTION_PERMISSIONS_BY_ROLE.canAskToSpeak.includes(localParticipantRole));
|
|
1371
1375
|
const selectIsAuthorizedToSpotlight = createSelector(selectAuthorizationRoleName, (localParticipantRole) => ROOM_ACTION_PERMISSIONS_BY_ROLE.canSpotlight.includes(localParticipantRole));
|
|
1376
|
+
const selectIsAuthorizedToManageBreakout = createSelector(selectAuthorizationRoleName, (localParticipantRole) => ROOM_ACTION_PERMISSIONS_BY_ROLE.canManageBreakout.includes(localParticipantRole));
|
|
1372
1377
|
|
|
1373
1378
|
function createAppAsyncThunk(typePrefix, payloadCreator) {
|
|
1374
1379
|
return createAsyncThunk(typePrefix, payloadCreator);
|
|
@@ -1503,6 +1508,9 @@ function forwardSocketEvents(socket, dispatch) {
|
|
|
1503
1508
|
socket.on("breakout_session_updated", (payload) => dispatch(signalEvents.breakoutSessionUpdated(payload)));
|
|
1504
1509
|
socket.on("breakout_move_to_group", () => dispatch(signalEvents.breakoutMoveToGroup()));
|
|
1505
1510
|
socket.on("breakout_move_to_main", () => dispatch(signalEvents.breakoutMoveToMain()));
|
|
1511
|
+
socket.on("breakout_ending", () => dispatch(signalEvents.breakoutEnding()));
|
|
1512
|
+
socket.on("breakout_timer_ended", () => dispatch(signalEvents.breakoutTimerEnded()));
|
|
1513
|
+
socket.on("breakout_timer_extended", () => dispatch(signalEvents.breakoutTimerExtended()));
|
|
1506
1514
|
}
|
|
1507
1515
|
const SIGNAL_BASE_URL = "wss://signal.appearin.net";
|
|
1508
1516
|
function createSocket() {
|
|
@@ -2204,203 +2212,6 @@ const selectLocalParticipantView = createSelector(selectLocalParticipantRaw, sel
|
|
|
2204
2212
|
return clientView;
|
|
2205
2213
|
});
|
|
2206
2214
|
|
|
2207
|
-
function createBreakout({ assignments, groups, startedAt, initiatedBy, breakoutStartedAt, breakoutEndedAt, breakoutNotification, breakoutTimerDuration, autoMoveToGroup, moveToGroupGracePeriod, autoMoveToMain, moveToMainGracePeriod, enforceAssignment, breakoutTimerSetting, } = {}) {
|
|
2208
|
-
return {
|
|
2209
|
-
assignments: assignments || null,
|
|
2210
|
-
groups: groups || null,
|
|
2211
|
-
startedAt: startedAt ? new Date(startedAt) : null,
|
|
2212
|
-
initiatedBy,
|
|
2213
|
-
breakoutStartedAt: breakoutStartedAt || null,
|
|
2214
|
-
breakoutEndedAt: breakoutEndedAt || null,
|
|
2215
|
-
breakoutNotification: breakoutNotification || null,
|
|
2216
|
-
breakoutTimerDuration: breakoutTimerDuration || 1800,
|
|
2217
|
-
autoMoveToGroup: autoMoveToGroup || false,
|
|
2218
|
-
moveToGroupGracePeriod: moveToGroupGracePeriod || 10,
|
|
2219
|
-
autoMoveToMain: autoMoveToMain || false,
|
|
2220
|
-
moveToMainGracePeriod: moveToMainGracePeriod || 30,
|
|
2221
|
-
enforceAssignment: enforceAssignment || false,
|
|
2222
|
-
breakoutTimerSetting: breakoutTimerSetting || false,
|
|
2223
|
-
};
|
|
2224
|
-
}
|
|
2225
|
-
const breakoutSliceInitialState = Object.assign(Object.assign({}, createBreakout()), { groupId: null });
|
|
2226
|
-
const breakoutSlice = createSlice({
|
|
2227
|
-
name: "breakout",
|
|
2228
|
-
initialState: breakoutSliceInitialState,
|
|
2229
|
-
reducers: {},
|
|
2230
|
-
extraReducers: (builder) => {
|
|
2231
|
-
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
2232
|
-
if ("error" in action.payload) {
|
|
2233
|
-
return state;
|
|
2234
|
-
}
|
|
2235
|
-
const { breakout } = action.payload || {};
|
|
2236
|
-
if (breakout) {
|
|
2237
|
-
return Object.assign(Object.assign({}, state), createBreakout(breakout));
|
|
2238
|
-
}
|
|
2239
|
-
return state;
|
|
2240
|
-
});
|
|
2241
|
-
builder.addCase(signalEvents.breakoutSessionUpdated, (state, action) => {
|
|
2242
|
-
return Object.assign(Object.assign({}, state), createBreakout(action.payload));
|
|
2243
|
-
});
|
|
2244
|
-
builder.addCase(signalEvents.breakoutGroupJoined, (state, action) => {
|
|
2245
|
-
var _a;
|
|
2246
|
-
if (((_a = action.meta) === null || _a === void 0 ? void 0 : _a.localParticipantId) !== action.payload.clientId) {
|
|
2247
|
-
return state;
|
|
2248
|
-
}
|
|
2249
|
-
return Object.assign(Object.assign({}, state), { groupId: action.payload.group });
|
|
2250
|
-
});
|
|
2251
|
-
},
|
|
2252
|
-
});
|
|
2253
|
-
const doBreakoutJoin = createAppThunk((payload) => (_, getState) => {
|
|
2254
|
-
const state = getState();
|
|
2255
|
-
const { socket } = selectSignalConnectionRaw(state);
|
|
2256
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("join_breakout_group", { group: payload.group });
|
|
2257
|
-
});
|
|
2258
|
-
const selectBreakoutRaw = (state) => state.breakout;
|
|
2259
|
-
const selectBreakoutActive = (state) => !!state.breakout.startedAt;
|
|
2260
|
-
const selectBreakoutAssignments = (state) => state.breakout.assignments;
|
|
2261
|
-
const selectBreakoutGroups = (state) => state.breakout.groups;
|
|
2262
|
-
const selectBreakoutCurrentId = createSelector(selectBreakoutRaw, selectLocalParticipantBreakoutGroup, (raw, localParticipantBreakoutGroup) => {
|
|
2263
|
-
return raw.groupId || localParticipantBreakoutGroup || "";
|
|
2264
|
-
});
|
|
2265
|
-
const selectBreakoutCurrentGroup = createSelector(selectBreakoutRaw, selectBreakoutCurrentId, (raw, breakoutCurrentId) => {
|
|
2266
|
-
var _a;
|
|
2267
|
-
const name = (_a = raw.groups) === null || _a === void 0 ? void 0 : _a[breakoutCurrentId];
|
|
2268
|
-
if (!name)
|
|
2269
|
-
return null;
|
|
2270
|
-
return { id: breakoutCurrentId, name };
|
|
2271
|
-
});
|
|
2272
|
-
startAppListening({
|
|
2273
|
-
actionCreator: signalEvents.breakoutMoveToGroup,
|
|
2274
|
-
effect: (_, { dispatch, getState }) => {
|
|
2275
|
-
const state = getState();
|
|
2276
|
-
const localParticipant = selectLocalParticipantRaw(state);
|
|
2277
|
-
const breakoutGroupAssigned = localParticipant.breakoutGroupAssigned;
|
|
2278
|
-
if (breakoutGroupAssigned) {
|
|
2279
|
-
dispatch(doBreakoutJoin({ group: breakoutGroupAssigned }));
|
|
2280
|
-
}
|
|
2281
|
-
},
|
|
2282
|
-
});
|
|
2283
|
-
startAppListening({
|
|
2284
|
-
actionCreator: signalEvents.breakoutMoveToMain,
|
|
2285
|
-
effect: (_, { dispatch }) => {
|
|
2286
|
-
dispatch(doBreakoutJoin({ group: "" }));
|
|
2287
|
-
},
|
|
2288
|
-
});
|
|
2289
|
-
startAppListening({
|
|
2290
|
-
actionCreator: signalEvents.breakoutSessionUpdated,
|
|
2291
|
-
effect: ({ payload }, { dispatch, getState }) => {
|
|
2292
|
-
var _a;
|
|
2293
|
-
const state = getState();
|
|
2294
|
-
const autoMoveToMain = selectBreakoutRaw(state).autoMoveToMain;
|
|
2295
|
-
if (((_a = payload.initiatedBy) === null || _a === void 0 ? void 0 : _a.active) === false) {
|
|
2296
|
-
if (!autoMoveToMain) {
|
|
2297
|
-
dispatch(doBreakoutJoin({ group: "" }));
|
|
2298
|
-
}
|
|
2299
|
-
}
|
|
2300
|
-
},
|
|
2301
|
-
});
|
|
2302
|
-
|
|
2303
|
-
const chatSliceInitialState = {
|
|
2304
|
-
chatMessages: [],
|
|
2305
|
-
};
|
|
2306
|
-
const chatSlice = createSlice({
|
|
2307
|
-
name: "chat",
|
|
2308
|
-
initialState: chatSliceInitialState,
|
|
2309
|
-
reducers: {},
|
|
2310
|
-
extraReducers(builder) {
|
|
2311
|
-
builder.addCase(signalEvents.chatMessage, (state, action) => {
|
|
2312
|
-
const message = Object.assign({ id: action.payload.id, senderId: action.payload.senderId, parentId: action.payload.parentId, timestamp: action.payload.timestamp, text: action.payload.text, sig: action.payload.sig, removed: false }, (action.payload.file && { file: action.payload.file }));
|
|
2313
|
-
return Object.assign(Object.assign({}, state), { chatMessages: [...state.chatMessages, message] });
|
|
2314
|
-
});
|
|
2315
|
-
builder.addCase(signalEvents.chatMessageRemoved, (state, action) => {
|
|
2316
|
-
return Object.assign(Object.assign({}, state), { chatMessages: state.chatMessages.map((m) => {
|
|
2317
|
-
return Object.assign(Object.assign({}, m), (m.id === action.payload.id && {
|
|
2318
|
-
removed: true,
|
|
2319
|
-
}));
|
|
2320
|
-
}) });
|
|
2321
|
-
});
|
|
2322
|
-
},
|
|
2323
|
-
});
|
|
2324
|
-
const doSendChatMessage = createRoomConnectedThunk((payload) => (_, getState) => {
|
|
2325
|
-
const state = getState();
|
|
2326
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
2327
|
-
const breakoutCurrentId = selectBreakoutCurrentId(state);
|
|
2328
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("chat_message", Object.assign(Object.assign(Object.assign({ text: payload.text }, (payload.parentId && { parentId: payload.parentId })), (breakoutCurrentId && { breakoutGroup: breakoutCurrentId })), (payload.isBroadcast && { broadcast: true })));
|
|
2329
|
-
});
|
|
2330
|
-
const doRemoveChatMessage = createRoomConnectedThunk(({ id, sig }) => (_, getState) => {
|
|
2331
|
-
const state = getState();
|
|
2332
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
2333
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("remove_chat_message", {
|
|
2334
|
-
id,
|
|
2335
|
-
sig,
|
|
2336
|
-
});
|
|
2337
|
-
});
|
|
2338
|
-
const selectChatMessages = (state) => state.chat.chatMessages;
|
|
2339
|
-
|
|
2340
|
-
const initialCloudRecordingState = {
|
|
2341
|
-
isInitiator: false,
|
|
2342
|
-
isRecording: false,
|
|
2343
|
-
startedAt: undefined,
|
|
2344
|
-
};
|
|
2345
|
-
const cloudRecordingSlice = createSlice({
|
|
2346
|
-
name: "cloudRecording",
|
|
2347
|
-
initialState: initialCloudRecordingState,
|
|
2348
|
-
reducers: {
|
|
2349
|
-
recordingRequestStarted: (state) => {
|
|
2350
|
-
return Object.assign(Object.assign({}, state), { isInitiator: true, status: "requested" });
|
|
2351
|
-
},
|
|
2352
|
-
},
|
|
2353
|
-
extraReducers: (builder) => {
|
|
2354
|
-
builder.addCase(signalEvents.cloudRecordingStopped, (state) => {
|
|
2355
|
-
return Object.assign(Object.assign({}, state), { isInitiator: false, isRecording: false, status: undefined });
|
|
2356
|
-
});
|
|
2357
|
-
builder.addCase(signalEvents.cloudRecordingStarted, (state, action) => {
|
|
2358
|
-
const { payload } = action;
|
|
2359
|
-
if (!payload.error) {
|
|
2360
|
-
return state;
|
|
2361
|
-
}
|
|
2362
|
-
return Object.assign(Object.assign({}, state), { isInitiator: false, isRecording: false, status: "error", error: payload.error });
|
|
2363
|
-
});
|
|
2364
|
-
builder.addCase(signalEvents.newClient, (state, { payload }) => {
|
|
2365
|
-
var _a;
|
|
2366
|
-
const { client } = payload;
|
|
2367
|
-
if (((_a = client.role) === null || _a === void 0 ? void 0 : _a.roleName) === "recorder") {
|
|
2368
|
-
return Object.assign(Object.assign({}, state), { isRecording: true, status: "recording", startedAt: client.startedCloudRecordingAt
|
|
2369
|
-
? new Date(client.startedCloudRecordingAt).getTime()
|
|
2370
|
-
: new Date().getTime() });
|
|
2371
|
-
}
|
|
2372
|
-
return state;
|
|
2373
|
-
});
|
|
2374
|
-
},
|
|
2375
|
-
});
|
|
2376
|
-
const { recordingRequestStarted } = cloudRecordingSlice.actions;
|
|
2377
|
-
const doStartCloudRecording = createRoomConnectedThunk(() => (dispatch, getState) => {
|
|
2378
|
-
const state = getState();
|
|
2379
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
2380
|
-
const status = selectCloudRecordingStatus(state);
|
|
2381
|
-
if (status && ["recording", "requested"].includes(status)) {
|
|
2382
|
-
return;
|
|
2383
|
-
}
|
|
2384
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("start_recording", {
|
|
2385
|
-
recording: "cloud",
|
|
2386
|
-
});
|
|
2387
|
-
dispatch(recordingRequestStarted());
|
|
2388
|
-
});
|
|
2389
|
-
const doStopCloudRecording = createRoomConnectedThunk(() => (dispatch, getState) => {
|
|
2390
|
-
const state = getState();
|
|
2391
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
2392
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("stop_recording");
|
|
2393
|
-
});
|
|
2394
|
-
const selectCloudRecordingRaw = (state) => state.cloudRecording;
|
|
2395
|
-
const selectCloudRecordingStatus = (state) => state.cloudRecording.status;
|
|
2396
|
-
const selectIsCloudRecording = (state) => state.cloudRecording.isRecording;
|
|
2397
|
-
const selectCloudRecordingIsInitiator = (state) => state.cloudRecording.isInitiator;
|
|
2398
|
-
|
|
2399
|
-
const selectRoomConnectionSessionId = (state) => { var _a; return (_a = state.roomConnection.session) === null || _a === void 0 ? void 0 : _a.id; };
|
|
2400
|
-
const selectRoomConnectionStatus = (state) => state.roomConnection.status;
|
|
2401
|
-
const selectRoomConnectionError = (state) => state.roomConnection.error;
|
|
2402
|
-
const selectRoomConnectionKnockResponse = (state) => state.roomConnection.knockResponse;
|
|
2403
|
-
|
|
2404
2215
|
function createRtcEventAction(name) {
|
|
2405
2216
|
return createAction(`rtcConnection/event/${name}`);
|
|
2406
2217
|
}
|
|
@@ -2563,59 +2374,629 @@ const remoteParticipantsSlice = createSlice({
|
|
|
2563
2374
|
isVideoEnabled,
|
|
2564
2375
|
});
|
|
2565
2376
|
});
|
|
2566
|
-
builder.addCase(signalEvents.clientMetadataReceived, (state, action) => {
|
|
2567
|
-
const { error, payload } = action.payload;
|
|
2568
|
-
if (error || !payload) {
|
|
2569
|
-
console.warn(error || "Client metadata error received");
|
|
2377
|
+
builder.addCase(signalEvents.clientMetadataReceived, (state, action) => {
|
|
2378
|
+
const { error, payload } = action.payload;
|
|
2379
|
+
if (error || !payload) {
|
|
2380
|
+
console.warn(error || "Client metadata error received");
|
|
2381
|
+
return state;
|
|
2382
|
+
}
|
|
2383
|
+
const { clientId, displayName, stickyReaction } = payload;
|
|
2384
|
+
return updateParticipant(state, clientId, {
|
|
2385
|
+
displayName,
|
|
2386
|
+
stickyReaction,
|
|
2387
|
+
});
|
|
2388
|
+
});
|
|
2389
|
+
builder.addCase(signalEvents.breakoutGroupJoined, (state, action) => {
|
|
2390
|
+
const { clientId, group } = action.payload;
|
|
2391
|
+
if (!findParticipant(state, clientId).participant) {
|
|
2392
|
+
return state;
|
|
2393
|
+
}
|
|
2394
|
+
return updateParticipant(state, clientId, {
|
|
2395
|
+
breakoutGroup: group || null,
|
|
2396
|
+
});
|
|
2397
|
+
});
|
|
2398
|
+
builder.addCase(signalEvents.screenshareStarted, (state, action) => {
|
|
2399
|
+
const { clientId, streamId } = action.payload;
|
|
2400
|
+
return addStreamId(state, clientId, streamId);
|
|
2401
|
+
});
|
|
2402
|
+
builder.addCase(signalEvents.screenshareStopped, (state, action) => {
|
|
2403
|
+
const { clientId, streamId } = action.payload;
|
|
2404
|
+
return removeStreamId(state, clientId, streamId);
|
|
2405
|
+
});
|
|
2406
|
+
},
|
|
2407
|
+
});
|
|
2408
|
+
const { participantStreamAdded, participantStreamIdAdded, streamStatusUpdated } = remoteParticipantsSlice.actions;
|
|
2409
|
+
const doRequestAudioEnable = createAuthorizedRoomConnectedThunk((state) => selectIsAuthorizedToRequestAudioEnable(state), (payload) => (_, getState) => {
|
|
2410
|
+
const state = getState();
|
|
2411
|
+
const canEnableRemoteAudio = selectIsAuthorizedToAskToSpeak(state);
|
|
2412
|
+
if (payload.enable && !canEnableRemoteAudio) {
|
|
2413
|
+
console.warn("Not authorized to perform this action");
|
|
2414
|
+
return;
|
|
2415
|
+
}
|
|
2416
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
2417
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("request_audio_enable", payload);
|
|
2418
|
+
});
|
|
2419
|
+
const doRequestVideoEnable = createAuthorizedRoomConnectedThunk((state) => selectIsAuthorizedToRequestVideoEnable(state), (payload) => (_, getState) => {
|
|
2420
|
+
const state = getState();
|
|
2421
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
2422
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("request_video_enable", payload);
|
|
2423
|
+
});
|
|
2424
|
+
const selectRemoteClients = (state) => state.remoteParticipants.remoteParticipants;
|
|
2425
|
+
const selectRemoteParticipants = createSelector(selectRemoteClients, (clients) => clients.filter((c) => !NON_PERSON_ROLES.includes(c.roleName)));
|
|
2426
|
+
const selectNumClients = createSelector(selectRemoteClients, (clients) => clients.length + 1);
|
|
2427
|
+
createSelector(selectRemoteParticipants, selectLocalParticipantRaw, (clients, localParticipant) => {
|
|
2428
|
+
if (NON_PERSON_ROLES.includes(localParticipant.roleName)) {
|
|
2429
|
+
return clients.length;
|
|
2430
|
+
}
|
|
2431
|
+
return clients.length + 1;
|
|
2432
|
+
});
|
|
2433
|
+
|
|
2434
|
+
const selectRoomConnectionSessionId = (state) => { var _a; return (_a = state.roomConnection.session) === null || _a === void 0 ? void 0 : _a.id; };
|
|
2435
|
+
const selectRoomConnectionStatus = (state) => state.roomConnection.status;
|
|
2436
|
+
const selectRoomConnectionError = (state) => state.roomConnection.error;
|
|
2437
|
+
const selectRoomConnectionKnockResponse = (state) => state.roomConnection.knockResponse;
|
|
2438
|
+
|
|
2439
|
+
const emitter = new EventEmitter();
|
|
2440
|
+
function createNotificationEvent(payload) {
|
|
2441
|
+
const notificationEvent = Object.assign(Object.assign({}, payload), { timestamp: Date.now() });
|
|
2442
|
+
return notificationEvent;
|
|
2443
|
+
}
|
|
2444
|
+
const initialNotificationsState = {
|
|
2445
|
+
emitter,
|
|
2446
|
+
events: [],
|
|
2447
|
+
};
|
|
2448
|
+
const notificationsSlice = createSlice({
|
|
2449
|
+
name: "notifications",
|
|
2450
|
+
initialState: initialNotificationsState,
|
|
2451
|
+
reducers: {
|
|
2452
|
+
addNotification: (state, action) => {
|
|
2453
|
+
return Object.assign(Object.assign({}, state), { events: [...state.events, Object.assign({}, action.payload)] });
|
|
2454
|
+
},
|
|
2455
|
+
doClearNotifications: (state) => {
|
|
2456
|
+
return Object.assign(Object.assign({}, state), { events: [] });
|
|
2457
|
+
},
|
|
2458
|
+
},
|
|
2459
|
+
});
|
|
2460
|
+
const { doClearNotifications } = notificationsSlice.actions;
|
|
2461
|
+
const doSetNotification = createAppThunk((payload) => (dispatch, getState) => {
|
|
2462
|
+
dispatch(notificationsSlice.actions.addNotification(payload));
|
|
2463
|
+
const state = getState();
|
|
2464
|
+
const emitter = selectNotificationsEmitter(state);
|
|
2465
|
+
emitter.emit(payload.type, payload);
|
|
2466
|
+
emitter.emit("*", payload);
|
|
2467
|
+
});
|
|
2468
|
+
const selectNotificationsEmitter = (state) => state.notifications.emitter;
|
|
2469
|
+
startAppListening({
|
|
2470
|
+
actionCreator: signalEvents.chatMessage,
|
|
2471
|
+
effect: ({ payload }, { dispatch, getState }) => {
|
|
2472
|
+
const state = getState();
|
|
2473
|
+
const selfId = selectSelfId(state);
|
|
2474
|
+
if (selfId === payload.senderId) {
|
|
2475
|
+
return;
|
|
2476
|
+
}
|
|
2477
|
+
const client = selectRemoteParticipants(state).find(({ id }) => id === payload.senderId);
|
|
2478
|
+
if (!client) {
|
|
2479
|
+
console.warn("Could not find remote client that sent chat message");
|
|
2480
|
+
return;
|
|
2481
|
+
}
|
|
2482
|
+
dispatch(doSetNotification(createNotificationEvent({
|
|
2483
|
+
type: "chatMessageReceived",
|
|
2484
|
+
message: `${client.displayName} says: ${payload.text}`,
|
|
2485
|
+
props: {
|
|
2486
|
+
client,
|
|
2487
|
+
chatMessage: {
|
|
2488
|
+
id: payload.id,
|
|
2489
|
+
senderId: payload.senderId,
|
|
2490
|
+
parentId: payload.parentId,
|
|
2491
|
+
timestamp: payload.timestamp,
|
|
2492
|
+
text: payload.text,
|
|
2493
|
+
sig: payload.sig,
|
|
2494
|
+
removed: false,
|
|
2495
|
+
},
|
|
2496
|
+
},
|
|
2497
|
+
})));
|
|
2498
|
+
},
|
|
2499
|
+
});
|
|
2500
|
+
startAppListening({
|
|
2501
|
+
actionCreator: signalEvents.audioEnableRequested,
|
|
2502
|
+
effect: ({ payload }, { dispatch, getState }) => {
|
|
2503
|
+
const { enable, requestedByClientId } = payload;
|
|
2504
|
+
const state = getState();
|
|
2505
|
+
const client = selectRemoteParticipants(state).find(({ id }) => id === requestedByClientId);
|
|
2506
|
+
if (!client) {
|
|
2507
|
+
console.warn("Could not find remote client that requested a local audio change");
|
|
2508
|
+
return;
|
|
2509
|
+
}
|
|
2510
|
+
dispatch(doSetNotification(createNotificationEvent({
|
|
2511
|
+
type: enable ? "requestAudioEnable" : "requestAudioDisable",
|
|
2512
|
+
message: enable
|
|
2513
|
+
? `${client.displayName} has requested for you to speak`
|
|
2514
|
+
: `${client.displayName} has muted your microphone`,
|
|
2515
|
+
props: {
|
|
2516
|
+
client,
|
|
2517
|
+
enable,
|
|
2518
|
+
},
|
|
2519
|
+
})));
|
|
2520
|
+
},
|
|
2521
|
+
});
|
|
2522
|
+
startAppListening({
|
|
2523
|
+
actionCreator: signalEvents.videoEnableRequested,
|
|
2524
|
+
effect: ({ payload }, { dispatch, getState }) => {
|
|
2525
|
+
const { enable, requestedByClientId } = payload;
|
|
2526
|
+
const state = getState();
|
|
2527
|
+
const client = selectRemoteParticipants(state).find(({ id }) => id === requestedByClientId);
|
|
2528
|
+
if (!client) {
|
|
2529
|
+
console.warn("Could not find remote client that requested a local video change");
|
|
2530
|
+
return;
|
|
2531
|
+
}
|
|
2532
|
+
dispatch(doSetNotification(createNotificationEvent({
|
|
2533
|
+
type: enable ? "requestVideoEnable" : "requestVideoDisable",
|
|
2534
|
+
message: enable
|
|
2535
|
+
? `${client.displayName} has requested for you to start video`
|
|
2536
|
+
: `${client.displayName} has stopped your video`,
|
|
2537
|
+
props: {
|
|
2538
|
+
client,
|
|
2539
|
+
enable,
|
|
2540
|
+
},
|
|
2541
|
+
})));
|
|
2542
|
+
},
|
|
2543
|
+
});
|
|
2544
|
+
startAppListening({
|
|
2545
|
+
actionCreator: signalEvents.clientMetadataReceived,
|
|
2546
|
+
effect: (action, { dispatch, getOriginalState, getState }) => {
|
|
2547
|
+
var _a;
|
|
2548
|
+
const { error, payload } = action.payload;
|
|
2549
|
+
if (error || !payload) {
|
|
2550
|
+
return;
|
|
2551
|
+
}
|
|
2552
|
+
const { clientId, stickyReaction } = payload;
|
|
2553
|
+
const state = getState();
|
|
2554
|
+
const canAskToSpeak = selectIsAuthorizedToAskToSpeak(state);
|
|
2555
|
+
if (!canAskToSpeak) {
|
|
2556
|
+
return;
|
|
2557
|
+
}
|
|
2558
|
+
const client = selectRemoteParticipants(state).find(({ id }) => id === clientId);
|
|
2559
|
+
if (!client) {
|
|
2560
|
+
console.warn("Could not find remote client that provided updated metadata");
|
|
2561
|
+
return;
|
|
2562
|
+
}
|
|
2563
|
+
const previousState = getOriginalState();
|
|
2564
|
+
const previousClient = selectRemoteParticipants(previousState).find(({ id }) => id === clientId);
|
|
2565
|
+
if ((!stickyReaction && !(previousClient === null || previousClient === void 0 ? void 0 : previousClient.stickyReaction)) ||
|
|
2566
|
+
(stickyReaction === null || stickyReaction === void 0 ? void 0 : stickyReaction.timestamp) === ((_a = previousClient === null || previousClient === void 0 ? void 0 : previousClient.stickyReaction) === null || _a === void 0 ? void 0 : _a.timestamp)) {
|
|
2567
|
+
return;
|
|
2568
|
+
}
|
|
2569
|
+
dispatch(doSetNotification(createNotificationEvent({
|
|
2570
|
+
type: stickyReaction ? "remoteHandRaised" : "remoteHandLowered",
|
|
2571
|
+
message: `${client.displayName} ${stickyReaction ? "raised" : "lowered"} their hand`,
|
|
2572
|
+
props: {
|
|
2573
|
+
client,
|
|
2574
|
+
stickyReaction,
|
|
2575
|
+
},
|
|
2576
|
+
})));
|
|
2577
|
+
},
|
|
2578
|
+
});
|
|
2579
|
+
createReactor([selectSignalStatus], ({ dispatch, getState }, signalStatus) => {
|
|
2580
|
+
const state = getState();
|
|
2581
|
+
const roomConnectionStatus = selectRoomConnectionStatus(state);
|
|
2582
|
+
if (["left", "kicked"].includes(roomConnectionStatus)) {
|
|
2583
|
+
return;
|
|
2584
|
+
}
|
|
2585
|
+
if (signalStatus === "disconnected") {
|
|
2586
|
+
dispatch(doSetNotification(createNotificationEvent({
|
|
2587
|
+
type: "signalTrouble",
|
|
2588
|
+
message: `Network connection lost. Trying to reconnect you...`,
|
|
2589
|
+
props: {},
|
|
2590
|
+
})));
|
|
2591
|
+
}
|
|
2592
|
+
else if (signalStatus === "connected") {
|
|
2593
|
+
dispatch(doSetNotification(createNotificationEvent({
|
|
2594
|
+
type: "signalOk",
|
|
2595
|
+
message: `Network connection available`,
|
|
2596
|
+
props: {},
|
|
2597
|
+
})));
|
|
2598
|
+
}
|
|
2599
|
+
});
|
|
2600
|
+
startAppListening({
|
|
2601
|
+
actionCreator: signalEvents.clientUnableToJoin,
|
|
2602
|
+
effect: (action, { dispatch }) => {
|
|
2603
|
+
var _a;
|
|
2604
|
+
if (((_a = action.payload) === null || _a === void 0 ? void 0 : _a.error) === "room_full") {
|
|
2605
|
+
dispatch(doSetNotification(createNotificationEvent({
|
|
2606
|
+
type: "clientUnableToJoinFullRoom",
|
|
2607
|
+
message: "Someone tried to join but the room is full and at capacity.",
|
|
2608
|
+
props: {},
|
|
2609
|
+
})));
|
|
2610
|
+
}
|
|
2611
|
+
},
|
|
2612
|
+
});
|
|
2613
|
+
|
|
2614
|
+
const DEFAULT_BREAKOUT_TIMER_DURATION = 1800;
|
|
2615
|
+
function createBreakout({ assignments, groups, startedAt, initiatedBy, breakoutStartedAt, breakoutEndedAt, breakoutNotification, breakoutTimerDuration, autoMoveToGroup, moveToGroupGracePeriod, autoMoveToMain, moveToMainGracePeriod, enforceAssignment, breakoutTimerSetting, } = {}) {
|
|
2616
|
+
return {
|
|
2617
|
+
assignments: assignments || null,
|
|
2618
|
+
groups: groups || null,
|
|
2619
|
+
startedAt: startedAt ? new Date(startedAt) : null,
|
|
2620
|
+
initiatedBy,
|
|
2621
|
+
breakoutStartedAt: breakoutStartedAt || null,
|
|
2622
|
+
breakoutEndedAt: breakoutEndedAt || null,
|
|
2623
|
+
breakoutNotification: breakoutNotification || null,
|
|
2624
|
+
breakoutTimerDuration: breakoutTimerDuration || DEFAULT_BREAKOUT_TIMER_DURATION,
|
|
2625
|
+
autoMoveToGroup: autoMoveToGroup || false,
|
|
2626
|
+
moveToGroupGracePeriod: moveToGroupGracePeriod || 10,
|
|
2627
|
+
autoMoveToMain: autoMoveToMain || false,
|
|
2628
|
+
moveToMainGracePeriod: moveToMainGracePeriod || 30,
|
|
2629
|
+
enforceAssignment: enforceAssignment || false,
|
|
2630
|
+
breakoutTimerSetting: breakoutTimerSetting || false,
|
|
2631
|
+
};
|
|
2632
|
+
}
|
|
2633
|
+
const breakoutSliceInitialState = Object.assign(Object.assign({}, createBreakout()), { error: null });
|
|
2634
|
+
const BREAKOUT_UNAVAILABLE_ERROR = "Breakout groups are not available in peer-to-peer rooms";
|
|
2635
|
+
const breakoutSlice = createSlice({
|
|
2636
|
+
name: "breakout",
|
|
2637
|
+
initialState: breakoutSliceInitialState,
|
|
2638
|
+
reducers: {
|
|
2639
|
+
setBreakoutError: (state, action) => {
|
|
2640
|
+
return Object.assign(Object.assign({}, state), { error: action.payload.error });
|
|
2641
|
+
},
|
|
2642
|
+
},
|
|
2643
|
+
extraReducers: (builder) => {
|
|
2644
|
+
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
2645
|
+
if ("error" in action.payload) {
|
|
2646
|
+
return state;
|
|
2647
|
+
}
|
|
2648
|
+
const { breakout } = action.payload || {};
|
|
2649
|
+
state = Object.assign(Object.assign({}, state), { error: null });
|
|
2650
|
+
if (breakout) {
|
|
2651
|
+
return Object.assign(Object.assign({}, state), createBreakout(breakout));
|
|
2652
|
+
}
|
|
2653
|
+
return state;
|
|
2654
|
+
});
|
|
2655
|
+
builder.addCase(signalEvents.breakoutSessionUpdated, (state, action) => {
|
|
2656
|
+
return Object.assign(Object.assign({}, state), createBreakout(action.payload));
|
|
2657
|
+
});
|
|
2658
|
+
},
|
|
2659
|
+
});
|
|
2660
|
+
const { setBreakoutError } = breakoutSlice.actions;
|
|
2661
|
+
const doBreakoutJoin = createAppThunk((payload) => (_, getState) => {
|
|
2662
|
+
const state = getState();
|
|
2663
|
+
const { socket } = selectSignalConnectionRaw(state);
|
|
2664
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("join_breakout_group", { group: payload.group });
|
|
2665
|
+
});
|
|
2666
|
+
function ensureDefaults(state, payload) {
|
|
2667
|
+
const { moveToGroupGracePeriod, moveToMainGracePeriod, breakoutTimerDuration } = state.breakout;
|
|
2668
|
+
const next = Object.assign({}, payload);
|
|
2669
|
+
if (next.autoMoveToGroup === true && next.moveToGroupGracePeriod == null) {
|
|
2670
|
+
next.moveToGroupGracePeriod = moveToGroupGracePeriod !== null && moveToGroupGracePeriod !== void 0 ? moveToGroupGracePeriod : 10;
|
|
2671
|
+
}
|
|
2672
|
+
if (next.autoMoveToMain === true && next.moveToMainGracePeriod == null) {
|
|
2673
|
+
next.moveToMainGracePeriod = moveToMainGracePeriod !== null && moveToMainGracePeriod !== void 0 ? moveToMainGracePeriod : 30;
|
|
2674
|
+
}
|
|
2675
|
+
if (next.breakoutTimerSetting === true && !next.breakoutTimerDuration) {
|
|
2676
|
+
next.breakoutTimerDuration = breakoutTimerDuration || DEFAULT_BREAKOUT_TIMER_DURATION;
|
|
2677
|
+
}
|
|
2678
|
+
return next;
|
|
2679
|
+
}
|
|
2680
|
+
function emitBreakoutSessionUpdate(state, payload) {
|
|
2681
|
+
const { socket } = selectSignalConnectionRaw(state);
|
|
2682
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("update_breakout_session", ensureDefaults(state, payload));
|
|
2683
|
+
}
|
|
2684
|
+
function resolveClientAssignmentsToDeviceAssignments(state, clientAssignments) {
|
|
2685
|
+
const deviceIdByClientId = {};
|
|
2686
|
+
for (const participant of selectRemoteParticipants(state)) {
|
|
2687
|
+
deviceIdByClientId[participant.id] = participant.deviceId;
|
|
2688
|
+
}
|
|
2689
|
+
const localParticipant = selectLocalParticipantRaw(state);
|
|
2690
|
+
const localDeviceId = selectDeviceId(state);
|
|
2691
|
+
if (localParticipant.id && localDeviceId) {
|
|
2692
|
+
deviceIdByClientId[localParticipant.id] = localDeviceId;
|
|
2693
|
+
}
|
|
2694
|
+
const deviceAssignments = {};
|
|
2695
|
+
for (const [clientId, group] of Object.entries(clientAssignments)) {
|
|
2696
|
+
const deviceId = deviceIdByClientId[clientId];
|
|
2697
|
+
if (deviceId) {
|
|
2698
|
+
deviceAssignments[deviceId] = group;
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
return deviceAssignments;
|
|
2702
|
+
}
|
|
2703
|
+
const doStartBreakoutSession = createAppAuthorizedThunk((state) => selectIsAuthorizedToManageBreakout(state), (payload) => (dispatch, getState) => {
|
|
2704
|
+
const state = getState();
|
|
2705
|
+
if (!selectBreakoutIsAvailable(state)) {
|
|
2706
|
+
dispatch(setBreakoutError({ error: BREAKOUT_UNAVAILABLE_ERROR }));
|
|
2707
|
+
console.warn(BREAKOUT_UNAVAILABLE_ERROR);
|
|
2708
|
+
return;
|
|
2709
|
+
}
|
|
2710
|
+
dispatch(setBreakoutError({ error: null }));
|
|
2711
|
+
const { assignments } = payload, rest = __rest(payload, ["assignments"]);
|
|
2712
|
+
emitBreakoutSessionUpdate(state, Object.assign(Object.assign(Object.assign({}, rest), (assignments ? { assignments: resolveClientAssignmentsToDeviceAssignments(state, assignments) } : {})), { active: true }));
|
|
2713
|
+
});
|
|
2714
|
+
const doUpdateBreakoutSession = createAppAuthorizedThunk((state) => selectIsAuthorizedToManageBreakout(state), (payload) => (_, getState) => {
|
|
2715
|
+
const state = getState();
|
|
2716
|
+
const { assignments } = payload, rest = __rest(payload, ["assignments"]);
|
|
2717
|
+
emitBreakoutSessionUpdate(state, Object.assign(Object.assign({}, rest), (assignments ? { assignments: resolveClientAssignmentsToDeviceAssignments(state, assignments) } : {})));
|
|
2718
|
+
});
|
|
2719
|
+
const doStopBreakoutSession = createAppAuthorizedThunk((state) => selectIsAuthorizedToManageBreakout(state), () => (_, getState) => {
|
|
2720
|
+
emitBreakoutSessionUpdate(getState(), { active: false });
|
|
2721
|
+
});
|
|
2722
|
+
const doAssignBreakoutParticipants = createAppAuthorizedThunk((state) => selectIsAuthorizedToManageBreakout(state), (payload) => (_, getState) => {
|
|
2723
|
+
const state = getState();
|
|
2724
|
+
const deviceAssignments = resolveClientAssignmentsToDeviceAssignments(state, payload.assignments);
|
|
2725
|
+
const mergedAssignments = Object.assign(Object.assign({}, (selectBreakoutAssignments(state) || {})), deviceAssignments);
|
|
2726
|
+
emitBreakoutSessionUpdate(state, { assignments: mergedAssignments });
|
|
2727
|
+
});
|
|
2728
|
+
const BREAKOUT_GROUPS_MIN_MAX = [2, 20];
|
|
2729
|
+
const GROUP_ID_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
|
|
2730
|
+
function defaultBreakoutGroupName(groupId) {
|
|
2731
|
+
return `Group ${groupId.toUpperCase()}`;
|
|
2732
|
+
}
|
|
2733
|
+
function createBreakoutGroups(count = BREAKOUT_GROUPS_MIN_MAX[0]) {
|
|
2734
|
+
const [min, max] = BREAKOUT_GROUPS_MIN_MAX;
|
|
2735
|
+
const amount = Math.min(Math.max(count, min), max);
|
|
2736
|
+
const groups = {};
|
|
2737
|
+
for (let i = 0; i < amount; i++) {
|
|
2738
|
+
const id = GROUP_ID_ALPHABET[i];
|
|
2739
|
+
groups[id] = defaultBreakoutGroupName(id);
|
|
2740
|
+
}
|
|
2741
|
+
return groups;
|
|
2742
|
+
}
|
|
2743
|
+
function shuffle(items) {
|
|
2744
|
+
return [...items].sort(() => Math.random() - 0.5);
|
|
2745
|
+
}
|
|
2746
|
+
function chunk(items, chunkCount) {
|
|
2747
|
+
let remaining = [...items];
|
|
2748
|
+
let count = chunkCount;
|
|
2749
|
+
const chunks = [];
|
|
2750
|
+
while (remaining.length && count > 0) {
|
|
2751
|
+
const size = Math.ceil(remaining.length / count);
|
|
2752
|
+
chunks.push(remaining.slice(0, size));
|
|
2753
|
+
remaining = remaining.slice(size);
|
|
2754
|
+
count -= 1;
|
|
2755
|
+
}
|
|
2756
|
+
return chunks;
|
|
2757
|
+
}
|
|
2758
|
+
function randomizeAssignments(deviceIds, groupIds) {
|
|
2759
|
+
const assignments = {};
|
|
2760
|
+
chunk(deviceIds, groupIds.length).forEach((chunkOfDevices, index) => {
|
|
2761
|
+
chunkOfDevices.forEach((deviceId) => {
|
|
2762
|
+
assignments[deviceId] = groupIds[index];
|
|
2763
|
+
});
|
|
2764
|
+
});
|
|
2765
|
+
return assignments;
|
|
2766
|
+
}
|
|
2767
|
+
const doAssignAllBreakoutParticipants = createAppAuthorizedThunk((state) => selectIsAuthorizedToManageBreakout(state), () => (_, getState) => {
|
|
2768
|
+
const state = getState();
|
|
2769
|
+
const groupIds = Object.keys(selectBreakoutGroups(state) || {});
|
|
2770
|
+
if (!groupIds.length)
|
|
2771
|
+
return;
|
|
2772
|
+
const deviceIds = shuffle(selectRemoteParticipants(state).map((participant) => participant.deviceId));
|
|
2773
|
+
emitBreakoutSessionUpdate(state, { assignments: randomizeAssignments(deviceIds, groupIds) });
|
|
2774
|
+
});
|
|
2775
|
+
const doUnassignAllBreakoutParticipants = createAppAuthorizedThunk((state) => selectIsAuthorizedToManageBreakout(state), () => (_, getState) => {
|
|
2776
|
+
const state = getState();
|
|
2777
|
+
const assignments = selectBreakoutAssignments(state) || {};
|
|
2778
|
+
const cleared = Object.keys(assignments).reduce((acc, deviceId) => {
|
|
2779
|
+
acc[deviceId] = "";
|
|
2780
|
+
return acc;
|
|
2781
|
+
}, {});
|
|
2782
|
+
emitBreakoutSessionUpdate(state, { assignments: cleared });
|
|
2783
|
+
});
|
|
2784
|
+
const doShuffleBreakoutParticipants = createAppAuthorizedThunk((state) => selectIsAuthorizedToManageBreakout(state), () => (_, getState) => {
|
|
2785
|
+
const state = getState();
|
|
2786
|
+
const groupIds = Object.keys(selectBreakoutGroups(state) || {});
|
|
2787
|
+
if (!groupIds.length)
|
|
2788
|
+
return;
|
|
2789
|
+
const assignments = selectBreakoutAssignments(state) || {};
|
|
2790
|
+
const deviceIds = shuffle(Object.entries(assignments)
|
|
2791
|
+
.filter(([, groupId]) => !!groupId)
|
|
2792
|
+
.map(([deviceId]) => deviceId));
|
|
2793
|
+
emitBreakoutSessionUpdate(state, { assignments: randomizeAssignments(deviceIds, groupIds) });
|
|
2794
|
+
});
|
|
2795
|
+
const doExtendBreakoutTimer = createAppAuthorizedThunk((state) => selectIsAuthorizedToManageBreakout(state), (payload) => (_, getState) => {
|
|
2796
|
+
var _a;
|
|
2797
|
+
const state = getState();
|
|
2798
|
+
const additionalSeconds = (_a = payload === null || payload === void 0 ? void 0 : payload.seconds) !== null && _a !== void 0 ? _a : 60;
|
|
2799
|
+
const breakoutTimerDuration = (selectBreakoutTimerDuration(state) || 0) + additionalSeconds;
|
|
2800
|
+
emitBreakoutSessionUpdate(state, { breakoutTimerDuration });
|
|
2801
|
+
});
|
|
2802
|
+
const doStopBreakoutTimer = createAppAuthorizedThunk((state) => selectIsAuthorizedToManageBreakout(state), () => (_, getState) => {
|
|
2803
|
+
emitBreakoutSessionUpdate(getState(), { breakoutTimerSetting: false });
|
|
2804
|
+
});
|
|
2805
|
+
const selectBreakoutRaw = (state) => state.breakout;
|
|
2806
|
+
const selectBreakoutError = (state) => state.breakout.error;
|
|
2807
|
+
const selectBreakoutIsAvailable = (state) => state.room.mode === "group";
|
|
2808
|
+
const selectBreakoutActive = (state) => !!state.breakout.startedAt;
|
|
2809
|
+
const selectBreakoutAssignments = (state) => state.breakout.assignments;
|
|
2810
|
+
const selectBreakoutGroups = (state) => state.breakout.groups;
|
|
2811
|
+
const selectBreakoutEnforceAssignment = (state) => state.breakout.enforceAssignment;
|
|
2812
|
+
const selectBreakoutTimerSetting = (state) => state.breakout.breakoutTimerSetting;
|
|
2813
|
+
const selectBreakoutTimerDuration = (state) => state.breakout.breakoutTimerDuration;
|
|
2814
|
+
const selectBreakoutAutoMoveToGroup = (state) => state.breakout.autoMoveToGroup;
|
|
2815
|
+
const selectBreakoutMoveToGroupGracePeriod = (state) => state.breakout.moveToGroupGracePeriod;
|
|
2816
|
+
const selectBreakoutAutoMoveToMain = (state) => state.breakout.autoMoveToMain;
|
|
2817
|
+
const selectBreakoutMoveToMainGracePeriod = (state) => state.breakout.moveToMainGracePeriod;
|
|
2818
|
+
const selectBreakoutStartedAt = (state) => state.breakout.startedAt;
|
|
2819
|
+
const selectBreakoutEndTime = createSelector(selectBreakoutRaw, (raw) => {
|
|
2820
|
+
if (!raw.breakoutStartedAt)
|
|
2821
|
+
return null;
|
|
2822
|
+
const startTime = new Date(raw.breakoutStartedAt).getTime();
|
|
2823
|
+
const gracePeriod = raw.autoMoveToGroup ? raw.moveToGroupGracePeriod || 0 : 0;
|
|
2824
|
+
return startTime + ((raw.breakoutTimerDuration || 0) + gracePeriod) * 1000;
|
|
2825
|
+
});
|
|
2826
|
+
const selectBreakoutMoveToGroupAt = createSelector(selectBreakoutRaw, (raw) => {
|
|
2827
|
+
if (!raw.autoMoveToGroup || !raw.breakoutStartedAt)
|
|
2828
|
+
return null;
|
|
2829
|
+
return new Date(raw.breakoutStartedAt).getTime() + (raw.moveToGroupGracePeriod || 0) * 1000;
|
|
2830
|
+
});
|
|
2831
|
+
const selectBreakoutMoveToMainAt = createSelector(selectBreakoutRaw, (raw) => {
|
|
2832
|
+
if (!raw.autoMoveToMain || !raw.breakoutEndedAt)
|
|
2833
|
+
return null;
|
|
2834
|
+
return new Date(raw.breakoutEndedAt).getTime() + (raw.moveToMainGracePeriod || 0) * 1000;
|
|
2835
|
+
});
|
|
2836
|
+
const selectBreakoutCurrentId = createSelector(selectLocalParticipantBreakoutGroup, (localParticipantBreakoutGroup) => localParticipantBreakoutGroup || "");
|
|
2837
|
+
const selectBreakoutCurrentGroup = createSelector(selectBreakoutRaw, selectBreakoutCurrentId, (raw, breakoutCurrentId) => {
|
|
2838
|
+
var _a;
|
|
2839
|
+
const name = (_a = raw.groups) === null || _a === void 0 ? void 0 : _a[breakoutCurrentId];
|
|
2840
|
+
if (!name)
|
|
2841
|
+
return null;
|
|
2842
|
+
return { id: breakoutCurrentId, name };
|
|
2843
|
+
});
|
|
2844
|
+
startAppListening({
|
|
2845
|
+
actionCreator: signalEvents.breakoutMoveToGroup,
|
|
2846
|
+
effect: (_, { dispatch, getState }) => {
|
|
2847
|
+
const state = getState();
|
|
2848
|
+
const localParticipant = selectLocalParticipantRaw(state);
|
|
2849
|
+
const breakoutGroupAssigned = localParticipant.breakoutGroupAssigned;
|
|
2850
|
+
if (breakoutGroupAssigned) {
|
|
2851
|
+
dispatch(doBreakoutJoin({ group: breakoutGroupAssigned }));
|
|
2852
|
+
}
|
|
2853
|
+
},
|
|
2854
|
+
});
|
|
2855
|
+
startAppListening({
|
|
2856
|
+
actionCreator: signalEvents.breakoutMoveToMain,
|
|
2857
|
+
effect: (_, { dispatch }) => {
|
|
2858
|
+
dispatch(doBreakoutJoin({ group: "" }));
|
|
2859
|
+
},
|
|
2860
|
+
});
|
|
2861
|
+
startAppListening({
|
|
2862
|
+
actionCreator: signalEvents.breakoutSessionUpdated,
|
|
2863
|
+
effect: ({ payload }, { dispatch, getState }) => {
|
|
2864
|
+
var _a;
|
|
2865
|
+
const state = getState();
|
|
2866
|
+
const autoMoveToMain = selectBreakoutRaw(state).autoMoveToMain;
|
|
2867
|
+
if (((_a = payload.initiatedBy) === null || _a === void 0 ? void 0 : _a.active) === false) {
|
|
2868
|
+
if (!autoMoveToMain) {
|
|
2869
|
+
dispatch(doBreakoutJoin({ group: "" }));
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
},
|
|
2873
|
+
});
|
|
2874
|
+
startAppListening({
|
|
2875
|
+
actionCreator: signalEvents.breakoutEnding,
|
|
2876
|
+
effect: (_, { dispatch }) => {
|
|
2877
|
+
dispatch(doSetNotification(createNotificationEvent({
|
|
2878
|
+
type: "breakoutTimerEnding",
|
|
2879
|
+
message: "The breakout session is ending soon",
|
|
2880
|
+
props: {},
|
|
2881
|
+
})));
|
|
2882
|
+
},
|
|
2883
|
+
});
|
|
2884
|
+
startAppListening({
|
|
2885
|
+
actionCreator: signalEvents.breakoutTimerExtended,
|
|
2886
|
+
effect: (_, { dispatch }) => {
|
|
2887
|
+
dispatch(doSetNotification(createNotificationEvent({
|
|
2888
|
+
type: "breakoutTimerExtended",
|
|
2889
|
+
message: "The breakout timer was extended",
|
|
2890
|
+
props: {},
|
|
2891
|
+
})));
|
|
2892
|
+
},
|
|
2893
|
+
});
|
|
2894
|
+
startAppListening({
|
|
2895
|
+
actionCreator: signalEvents.breakoutTimerEnded,
|
|
2896
|
+
effect: (_, { dispatch }) => {
|
|
2897
|
+
dispatch(doSetNotification(createNotificationEvent({
|
|
2898
|
+
type: "breakoutTimerEnded",
|
|
2899
|
+
message: "The breakout timer ended",
|
|
2900
|
+
props: {},
|
|
2901
|
+
})));
|
|
2902
|
+
},
|
|
2903
|
+
});
|
|
2904
|
+
|
|
2905
|
+
const chatSliceInitialState = {
|
|
2906
|
+
chatMessages: [],
|
|
2907
|
+
};
|
|
2908
|
+
const chatSlice = createSlice({
|
|
2909
|
+
name: "chat",
|
|
2910
|
+
initialState: chatSliceInitialState,
|
|
2911
|
+
reducers: {},
|
|
2912
|
+
extraReducers(builder) {
|
|
2913
|
+
builder.addCase(signalEvents.chatMessage, (state, action) => {
|
|
2914
|
+
const message = Object.assign({ id: action.payload.id, senderId: action.payload.senderId, parentId: action.payload.parentId, timestamp: action.payload.timestamp, text: action.payload.text, sig: action.payload.sig, removed: false }, (action.payload.file && { file: action.payload.file }));
|
|
2915
|
+
return Object.assign(Object.assign({}, state), { chatMessages: [...state.chatMessages, message] });
|
|
2916
|
+
});
|
|
2917
|
+
builder.addCase(signalEvents.chatMessageRemoved, (state, action) => {
|
|
2918
|
+
return Object.assign(Object.assign({}, state), { chatMessages: state.chatMessages.map((m) => {
|
|
2919
|
+
return Object.assign(Object.assign({}, m), (m.id === action.payload.id && {
|
|
2920
|
+
removed: true,
|
|
2921
|
+
}));
|
|
2922
|
+
}) });
|
|
2923
|
+
});
|
|
2924
|
+
},
|
|
2925
|
+
});
|
|
2926
|
+
const doSendChatMessage = createRoomConnectedThunk((payload) => (_, getState) => {
|
|
2927
|
+
const state = getState();
|
|
2928
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
2929
|
+
const breakoutCurrentId = selectBreakoutCurrentId(state);
|
|
2930
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("chat_message", Object.assign(Object.assign(Object.assign({ text: payload.text }, (payload.parentId && { parentId: payload.parentId })), (breakoutCurrentId && { breakoutGroup: breakoutCurrentId })), (payload.isBroadcast && { broadcast: true })));
|
|
2931
|
+
});
|
|
2932
|
+
const doRemoveChatMessage = createRoomConnectedThunk(({ id, sig }) => (_, getState) => {
|
|
2933
|
+
const state = getState();
|
|
2934
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
2935
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("remove_chat_message", {
|
|
2936
|
+
id,
|
|
2937
|
+
sig,
|
|
2938
|
+
});
|
|
2939
|
+
});
|
|
2940
|
+
const selectChatMessages = (state) => state.chat.chatMessages;
|
|
2941
|
+
|
|
2942
|
+
const initialCloudRecordingState = {
|
|
2943
|
+
isInitiator: false,
|
|
2944
|
+
isRecording: false,
|
|
2945
|
+
startedAt: undefined,
|
|
2946
|
+
};
|
|
2947
|
+
const cloudRecordingSlice = createSlice({
|
|
2948
|
+
name: "cloudRecording",
|
|
2949
|
+
initialState: initialCloudRecordingState,
|
|
2950
|
+
reducers: {
|
|
2951
|
+
recordingRequestStarted: (state) => {
|
|
2952
|
+
return Object.assign(Object.assign({}, state), { isInitiator: true, status: "requested" });
|
|
2953
|
+
},
|
|
2954
|
+
},
|
|
2955
|
+
extraReducers: (builder) => {
|
|
2956
|
+
builder.addCase(signalEvents.cloudRecordingStopped, (state) => {
|
|
2957
|
+
return Object.assign(Object.assign({}, state), { isInitiator: false, isRecording: false, status: undefined });
|
|
2958
|
+
});
|
|
2959
|
+
builder.addCase(signalEvents.cloudRecordingStarted, (state, action) => {
|
|
2960
|
+
const { payload } = action;
|
|
2961
|
+
if (!payload.error) {
|
|
2570
2962
|
return state;
|
|
2571
2963
|
}
|
|
2572
|
-
|
|
2573
|
-
return updateParticipant(state, clientId, {
|
|
2574
|
-
displayName,
|
|
2575
|
-
stickyReaction,
|
|
2576
|
-
});
|
|
2577
|
-
});
|
|
2578
|
-
builder.addCase(signalEvents.breakoutGroupJoined, (state, action) => {
|
|
2579
|
-
const { clientId, group } = action.payload;
|
|
2580
|
-
return updateParticipant(state, clientId, {
|
|
2581
|
-
breakoutGroup: group || null,
|
|
2582
|
-
});
|
|
2583
|
-
});
|
|
2584
|
-
builder.addCase(signalEvents.screenshareStarted, (state, action) => {
|
|
2585
|
-
const { clientId, streamId } = action.payload;
|
|
2586
|
-
return addStreamId(state, clientId, streamId);
|
|
2964
|
+
return Object.assign(Object.assign({}, state), { isInitiator: false, isRecording: false, status: "error", error: payload.error });
|
|
2587
2965
|
});
|
|
2588
|
-
builder.addCase(signalEvents.
|
|
2589
|
-
|
|
2590
|
-
|
|
2966
|
+
builder.addCase(signalEvents.newClient, (state, { payload }) => {
|
|
2967
|
+
var _a;
|
|
2968
|
+
const { client } = payload;
|
|
2969
|
+
if (((_a = client.role) === null || _a === void 0 ? void 0 : _a.roleName) === "recorder") {
|
|
2970
|
+
return Object.assign(Object.assign({}, state), { isRecording: true, status: "recording", startedAt: client.startedCloudRecordingAt
|
|
2971
|
+
? new Date(client.startedCloudRecordingAt).getTime()
|
|
2972
|
+
: new Date().getTime() });
|
|
2973
|
+
}
|
|
2974
|
+
return state;
|
|
2591
2975
|
});
|
|
2592
2976
|
},
|
|
2593
2977
|
});
|
|
2594
|
-
const {
|
|
2595
|
-
const
|
|
2978
|
+
const { recordingRequestStarted } = cloudRecordingSlice.actions;
|
|
2979
|
+
const doStartCloudRecording = createRoomConnectedThunk(() => (dispatch, getState) => {
|
|
2596
2980
|
const state = getState();
|
|
2597
|
-
const
|
|
2598
|
-
|
|
2599
|
-
|
|
2981
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
2982
|
+
const status = selectCloudRecordingStatus(state);
|
|
2983
|
+
if (status && ["recording", "requested"].includes(status)) {
|
|
2600
2984
|
return;
|
|
2601
2985
|
}
|
|
2602
|
-
|
|
2603
|
-
|
|
2986
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("start_recording", {
|
|
2987
|
+
recording: "cloud",
|
|
2988
|
+
});
|
|
2989
|
+
dispatch(recordingRequestStarted());
|
|
2604
2990
|
});
|
|
2605
|
-
const
|
|
2991
|
+
const doStopCloudRecording = createRoomConnectedThunk(() => (dispatch, getState) => {
|
|
2606
2992
|
const state = getState();
|
|
2607
2993
|
const socket = selectSignalConnectionRaw(state).socket;
|
|
2608
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("
|
|
2609
|
-
});
|
|
2610
|
-
const selectRemoteClients = (state) => state.remoteParticipants.remoteParticipants;
|
|
2611
|
-
const selectRemoteParticipants = createSelector(selectRemoteClients, (clients) => clients.filter((c) => !NON_PERSON_ROLES.includes(c.roleName)));
|
|
2612
|
-
const selectNumClients = createSelector(selectRemoteClients, (clients) => clients.length + 1);
|
|
2613
|
-
createSelector(selectRemoteParticipants, selectLocalParticipantRaw, (clients, localParticipant) => {
|
|
2614
|
-
if (NON_PERSON_ROLES.includes(localParticipant.roleName)) {
|
|
2615
|
-
return clients.length;
|
|
2616
|
-
}
|
|
2617
|
-
return clients.length + 1;
|
|
2994
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("stop_recording");
|
|
2618
2995
|
});
|
|
2996
|
+
const selectCloudRecordingRaw = (state) => state.cloudRecording;
|
|
2997
|
+
const selectCloudRecordingStatus = (state) => state.cloudRecording.status;
|
|
2998
|
+
const selectIsCloudRecording = (state) => state.cloudRecording.isRecording;
|
|
2999
|
+
const selectCloudRecordingIsInitiator = (state) => state.cloudRecording.isInitiator;
|
|
2619
3000
|
|
|
2620
3001
|
const localScreenshareSliceInitialState = {
|
|
2621
3002
|
status: "inactive",
|
|
@@ -2709,6 +3090,7 @@ function isRecorderClient(client) {
|
|
|
2709
3090
|
}
|
|
2710
3091
|
const roomSliceInitialState = {
|
|
2711
3092
|
isLocked: false,
|
|
3093
|
+
mode: null,
|
|
2712
3094
|
};
|
|
2713
3095
|
const roomSlice = createSlice({
|
|
2714
3096
|
name: "room",
|
|
@@ -2716,6 +3098,7 @@ const roomSlice = createSlice({
|
|
|
2716
3098
|
reducers: {},
|
|
2717
3099
|
extraReducers: (builder) => {
|
|
2718
3100
|
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
3101
|
+
var _a;
|
|
2719
3102
|
if ("error" in action.payload) {
|
|
2720
3103
|
if (action.payload.error === "room_locked") {
|
|
2721
3104
|
return Object.assign(Object.assign({}, state), { isLocked: Boolean(action.payload.isLocked) });
|
|
@@ -2723,7 +3106,7 @@ const roomSlice = createSlice({
|
|
|
2723
3106
|
return state;
|
|
2724
3107
|
}
|
|
2725
3108
|
const { room } = action.payload;
|
|
2726
|
-
return Object.assign(Object.assign({}, state), { isLocked: Boolean(room.isLocked) });
|
|
3109
|
+
return Object.assign(Object.assign({}, state), { isLocked: Boolean(room.isLocked), mode: (_a = room.mode) !== null && _a !== void 0 ? _a : (room.sfuServer ? "group" : "normal") });
|
|
2727
3110
|
});
|
|
2728
3111
|
builder.addCase(signalEvents.roomLocked, (state, action) => {
|
|
2729
3112
|
const { isLocked } = action.payload;
|
|
@@ -3092,8 +3475,7 @@ const doHandleAcceptStreams = createAppThunk((payload) => (dispatch, getState) =
|
|
|
3092
3475
|
const participant = remoteClients.find((p) => p.id === clientId);
|
|
3093
3476
|
if (!participant)
|
|
3094
3477
|
continue;
|
|
3095
|
-
if (state === "to_accept" ||
|
|
3096
|
-
(state === "new_accept" && shouldAcceptNewClients)) {
|
|
3478
|
+
if (state === "to_accept" || (state === "new_accept" && shouldAcceptNewClients)) {
|
|
3097
3479
|
rtcManager.acceptNewStream({
|
|
3098
3480
|
streamId: streamId === CAMERA_STREAM_ID ? clientId : streamId,
|
|
3099
3481
|
clientId,
|
|
@@ -3136,7 +3518,10 @@ const doRtcManagerInitialize = createAppThunk(() => (dispatch, getState) => {
|
|
|
3136
3518
|
const isCameraEnabled = selectIsCameraEnabled(getState());
|
|
3137
3519
|
const isMicrophoneEnabled = selectIsMicrophoneEnabled(getState());
|
|
3138
3520
|
if (localMediaStream && rtcManager) {
|
|
3139
|
-
rtcManager.addCameraStream(localMediaStream, {
|
|
3521
|
+
rtcManager.addCameraStream(localMediaStream, {
|
|
3522
|
+
audioPaused: !isMicrophoneEnabled,
|
|
3523
|
+
videoPaused: !isCameraEnabled,
|
|
3524
|
+
});
|
|
3140
3525
|
}
|
|
3141
3526
|
dispatch(rtcManagerInitialized());
|
|
3142
3527
|
});
|
|
@@ -3279,7 +3664,7 @@ const selectStreamsToAccept = createSelector(selectRtcStatus, selectRemoteClient
|
|
|
3279
3664
|
}
|
|
3280
3665
|
if ((!client.breakoutGroup && !breakoutCurrentId) ||
|
|
3281
3666
|
client.breakoutGroup === breakoutCurrentId ||
|
|
3282
|
-
(
|
|
3667
|
+
(!client.breakoutGroup && clientSpotlight) ||
|
|
3283
3668
|
ignoreBreakoutGroups) {
|
|
3284
3669
|
if (state === "done_accept")
|
|
3285
3670
|
continue;
|
|
@@ -3839,188 +4224,21 @@ createReactor([
|
|
|
3839
4224
|
dispatch(doSendClientMetadata());
|
|
3840
4225
|
}
|
|
3841
4226
|
});
|
|
3842
|
-
createReactor([selectBreakoutAssignments, selectDeviceId, selectLocalParticipantRaw], ({ dispatch }, breakoutAssignments, deviceId, localParticipant) => {
|
|
4227
|
+
createReactor([selectBreakoutAssignments, selectDeviceId, selectLocalParticipantRaw, selectBreakoutGroups, selectBreakoutActive], ({ dispatch }, breakoutAssignments, deviceId, localParticipant, breakoutGroups, breakoutActive) => {
|
|
3843
4228
|
const breakoutGroupAssigned = (breakoutAssignments === null || breakoutAssignments === void 0 ? void 0 : breakoutAssignments[deviceId || ""]) || "";
|
|
3844
4229
|
if (localParticipant.breakoutGroupAssigned === breakoutGroupAssigned) {
|
|
3845
4230
|
return;
|
|
3846
4231
|
}
|
|
3847
4232
|
dispatch(setBreakoutGroupAssigned({ breakoutGroupAssigned }));
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
const emitter = new EventEmitter();
|
|
3851
|
-
function createNotificationEvent(payload) {
|
|
3852
|
-
const notificationEvent = Object.assign(Object.assign({}, payload), { timestamp: Date.now() });
|
|
3853
|
-
return notificationEvent;
|
|
3854
|
-
}
|
|
3855
|
-
const initialNotificationsState = {
|
|
3856
|
-
emitter,
|
|
3857
|
-
events: [],
|
|
3858
|
-
};
|
|
3859
|
-
const notificationsSlice = createSlice({
|
|
3860
|
-
name: "notifications",
|
|
3861
|
-
initialState: initialNotificationsState,
|
|
3862
|
-
reducers: {
|
|
3863
|
-
addNotification: (state, action) => {
|
|
3864
|
-
return Object.assign(Object.assign({}, state), { events: [...state.events, Object.assign({}, action.payload)] });
|
|
3865
|
-
},
|
|
3866
|
-
doClearNotifications: (state) => {
|
|
3867
|
-
return Object.assign(Object.assign({}, state), { events: [] });
|
|
3868
|
-
},
|
|
3869
|
-
},
|
|
3870
|
-
});
|
|
3871
|
-
const { doClearNotifications } = notificationsSlice.actions;
|
|
3872
|
-
const doSetNotification = createAppThunk((payload) => (dispatch, getState) => {
|
|
3873
|
-
dispatch(notificationsSlice.actions.addNotification(payload));
|
|
3874
|
-
const state = getState();
|
|
3875
|
-
const emitter = selectNotificationsEmitter(state);
|
|
3876
|
-
emitter.emit(payload.type, payload);
|
|
3877
|
-
emitter.emit("*", payload);
|
|
3878
|
-
});
|
|
3879
|
-
const selectNotificationsEmitter = (state) => state.notifications.emitter;
|
|
3880
|
-
startAppListening({
|
|
3881
|
-
actionCreator: signalEvents.chatMessage,
|
|
3882
|
-
effect: ({ payload }, { dispatch, getState }) => {
|
|
3883
|
-
const state = getState();
|
|
3884
|
-
const selfId = selectSelfId(state);
|
|
3885
|
-
if (selfId === payload.senderId) {
|
|
3886
|
-
return;
|
|
3887
|
-
}
|
|
3888
|
-
const client = selectRemoteParticipants(state).find(({ id }) => id === payload.senderId);
|
|
3889
|
-
if (!client) {
|
|
3890
|
-
console.warn("Could not find remote client that sent chat message");
|
|
3891
|
-
return;
|
|
3892
|
-
}
|
|
3893
|
-
dispatch(doSetNotification(createNotificationEvent({
|
|
3894
|
-
type: "chatMessageReceived",
|
|
3895
|
-
message: `${client.displayName} says: ${payload.text}`,
|
|
3896
|
-
props: {
|
|
3897
|
-
client,
|
|
3898
|
-
chatMessage: {
|
|
3899
|
-
id: payload.id,
|
|
3900
|
-
senderId: payload.senderId,
|
|
3901
|
-
parentId: payload.parentId,
|
|
3902
|
-
timestamp: payload.timestamp,
|
|
3903
|
-
text: payload.text,
|
|
3904
|
-
sig: payload.sig,
|
|
3905
|
-
removed: false,
|
|
3906
|
-
},
|
|
3907
|
-
},
|
|
3908
|
-
})));
|
|
3909
|
-
},
|
|
3910
|
-
});
|
|
3911
|
-
startAppListening({
|
|
3912
|
-
actionCreator: signalEvents.audioEnableRequested,
|
|
3913
|
-
effect: ({ payload }, { dispatch, getState }) => {
|
|
3914
|
-
const { enable, requestedByClientId } = payload;
|
|
3915
|
-
const state = getState();
|
|
3916
|
-
const client = selectRemoteParticipants(state).find(({ id }) => id === requestedByClientId);
|
|
3917
|
-
if (!client) {
|
|
3918
|
-
console.warn("Could not find remote client that requested a local audio change");
|
|
3919
|
-
return;
|
|
3920
|
-
}
|
|
3921
|
-
dispatch(doSetNotification(createNotificationEvent({
|
|
3922
|
-
type: enable ? "requestAudioEnable" : "requestAudioDisable",
|
|
3923
|
-
message: enable
|
|
3924
|
-
? `${client.displayName} has requested for you to speak`
|
|
3925
|
-
: `${client.displayName} has muted your microphone`,
|
|
3926
|
-
props: {
|
|
3927
|
-
client,
|
|
3928
|
-
enable,
|
|
3929
|
-
},
|
|
3930
|
-
})));
|
|
3931
|
-
},
|
|
3932
|
-
});
|
|
3933
|
-
startAppListening({
|
|
3934
|
-
actionCreator: signalEvents.videoEnableRequested,
|
|
3935
|
-
effect: ({ payload }, { dispatch, getState }) => {
|
|
3936
|
-
const { enable, requestedByClientId } = payload;
|
|
3937
|
-
const state = getState();
|
|
3938
|
-
const client = selectRemoteParticipants(state).find(({ id }) => id === requestedByClientId);
|
|
3939
|
-
if (!client) {
|
|
3940
|
-
console.warn("Could not find remote client that requested a local video change");
|
|
3941
|
-
return;
|
|
3942
|
-
}
|
|
3943
|
-
dispatch(doSetNotification(createNotificationEvent({
|
|
3944
|
-
type: enable ? "requestVideoEnable" : "requestVideoDisable",
|
|
3945
|
-
message: enable
|
|
3946
|
-
? `${client.displayName} has requested for you to start video`
|
|
3947
|
-
: `${client.displayName} has stopped your video`,
|
|
3948
|
-
props: {
|
|
3949
|
-
client,
|
|
3950
|
-
enable,
|
|
3951
|
-
},
|
|
3952
|
-
})));
|
|
3953
|
-
},
|
|
3954
|
-
});
|
|
3955
|
-
startAppListening({
|
|
3956
|
-
actionCreator: signalEvents.clientMetadataReceived,
|
|
3957
|
-
effect: (action, { dispatch, getOriginalState, getState }) => {
|
|
3958
|
-
var _a;
|
|
3959
|
-
const { error, payload } = action.payload;
|
|
3960
|
-
if (error || !payload) {
|
|
3961
|
-
return;
|
|
3962
|
-
}
|
|
3963
|
-
const { clientId, stickyReaction } = payload;
|
|
3964
|
-
const state = getState();
|
|
3965
|
-
const canAskToSpeak = selectIsAuthorizedToAskToSpeak(state);
|
|
3966
|
-
if (!canAskToSpeak) {
|
|
3967
|
-
return;
|
|
3968
|
-
}
|
|
3969
|
-
const client = selectRemoteParticipants(state).find(({ id }) => id === clientId);
|
|
3970
|
-
if (!client) {
|
|
3971
|
-
console.warn("Could not find remote client that provided updated metadata");
|
|
3972
|
-
return;
|
|
3973
|
-
}
|
|
3974
|
-
const previousState = getOriginalState();
|
|
3975
|
-
const previousClient = selectRemoteParticipants(previousState).find(({ id }) => id === clientId);
|
|
3976
|
-
if ((!stickyReaction && !(previousClient === null || previousClient === void 0 ? void 0 : previousClient.stickyReaction)) ||
|
|
3977
|
-
(stickyReaction === null || stickyReaction === void 0 ? void 0 : stickyReaction.timestamp) === ((_a = previousClient === null || previousClient === void 0 ? void 0 : previousClient.stickyReaction) === null || _a === void 0 ? void 0 : _a.timestamp)) {
|
|
3978
|
-
return;
|
|
3979
|
-
}
|
|
3980
|
-
dispatch(doSetNotification(createNotificationEvent({
|
|
3981
|
-
type: stickyReaction ? "remoteHandRaised" : "remoteHandLowered",
|
|
3982
|
-
message: `${client.displayName} ${stickyReaction ? "raised" : "lowered"} their hand`,
|
|
3983
|
-
props: {
|
|
3984
|
-
client,
|
|
3985
|
-
stickyReaction,
|
|
3986
|
-
},
|
|
3987
|
-
})));
|
|
3988
|
-
},
|
|
3989
|
-
});
|
|
3990
|
-
createReactor([selectSignalStatus], ({ dispatch, getState }, signalStatus) => {
|
|
3991
|
-
const state = getState();
|
|
3992
|
-
const roomConnectionStatus = selectRoomConnectionStatus(state);
|
|
3993
|
-
if (["left", "kicked"].includes(roomConnectionStatus)) {
|
|
3994
|
-
return;
|
|
3995
|
-
}
|
|
3996
|
-
if (signalStatus === "disconnected") {
|
|
3997
|
-
dispatch(doSetNotification(createNotificationEvent({
|
|
3998
|
-
type: "signalTrouble",
|
|
3999
|
-
message: `Network connection lost. Trying to reconnect you...`,
|
|
4000
|
-
props: {},
|
|
4001
|
-
})));
|
|
4002
|
-
}
|
|
4003
|
-
else if (signalStatus === "connected") {
|
|
4233
|
+
if (breakoutGroupAssigned && breakoutActive) {
|
|
4234
|
+
const groupName = (breakoutGroups === null || breakoutGroups === void 0 ? void 0 : breakoutGroups[breakoutGroupAssigned]) || "";
|
|
4004
4235
|
dispatch(doSetNotification(createNotificationEvent({
|
|
4005
|
-
type: "
|
|
4006
|
-
message: `
|
|
4007
|
-
props: {},
|
|
4236
|
+
type: "breakoutGroupAssigned",
|
|
4237
|
+
message: groupName ? `You've been assigned to ${groupName}` : "You've been assigned to a group",
|
|
4238
|
+
props: { group: breakoutGroupAssigned, groupName },
|
|
4008
4239
|
})));
|
|
4009
4240
|
}
|
|
4010
4241
|
});
|
|
4011
|
-
startAppListening({
|
|
4012
|
-
actionCreator: signalEvents.clientUnableToJoin,
|
|
4013
|
-
effect: (action, { dispatch }) => {
|
|
4014
|
-
var _a;
|
|
4015
|
-
if (((_a = action.payload) === null || _a === void 0 ? void 0 : _a.error) === "room_full") {
|
|
4016
|
-
dispatch(doSetNotification(createNotificationEvent({
|
|
4017
|
-
type: "clientUnableToJoinFullRoom",
|
|
4018
|
-
message: "Someone tried to join but the room is full and at capacity.",
|
|
4019
|
-
props: {},
|
|
4020
|
-
})));
|
|
4021
|
-
}
|
|
4022
|
-
},
|
|
4023
|
-
});
|
|
4024
4242
|
|
|
4025
4243
|
const organizationSliceInitialState = {
|
|
4026
4244
|
data: null,
|
|
@@ -5241,7 +5459,10 @@ const SPOTLIGHT_PARTICIPANT_REMOVED = "spotlight:participant-removed";
|
|
|
5241
5459
|
const ROOM_JOINED = "room:joined";
|
|
5242
5460
|
const ROOM_JOINED_ERROR = "room:joined:error";
|
|
5243
5461
|
|
|
5244
|
-
const selectRoomConnectionState = createSelector(selectChatMessages, selectFileUploads, selectCloudRecordingRaw, selectBreakoutCurrentGroup, selectBreakoutActive, selectBreakoutGroupedParticipants, selectAllClientViewsInCurrentGroup, selectLiveCaptionsRaw, selectLiveTranscriptionRaw, selectLocalParticipantRaw, selectLocalMediaStream, selectRemoteParticipants, selectScreenshares, selectRoomConnectionStatus, selectRoomConnectionError, selectRoomConnectionKnockResponse, selectStreamingRaw, selectWaitingParticipants, selectNotificationsEmitter, selectSpotlightedClientViews, selectIsCameraEnabled, selectIsMicrophoneEnabled, (chatMessages, fileUploads, cloudRecording, breakoutCurrentGroup, breakoutActive, breakoutGroupedParticipants, clientViewsInCurrentGroup, liveCaptions, liveTranscription, localParticipant, localMediaStream, remoteParticipants, screenshares, connectionStatus, connectionError, knockResponse, streaming, waitingParticipants, notificationsEmitter, spotlightedClientViews, isCameraEnabled, isMicrophoneEnabled) => {
|
|
5462
|
+
const selectRoomConnectionState = createSelector(selectChatMessages, selectFileUploads, selectCloudRecordingRaw, selectBreakoutCurrentGroup, selectBreakoutCurrentId, selectBreakoutActive, selectBreakoutGroupedParticipants, selectBreakoutGroups, selectBreakoutAssignments, selectBreakoutEnforceAssignment, selectBreakoutTimerSetting, selectBreakoutTimerDuration, selectBreakoutAutoMoveToGroup, selectBreakoutMoveToGroupGracePeriod, selectBreakoutAutoMoveToMain, selectBreakoutMoveToMainGracePeriod, selectBreakoutStartedAt, selectBreakoutEndTime, selectBreakoutMoveToGroupAt, selectBreakoutMoveToMainAt, selectBreakoutIsAvailable, selectBreakoutError, selectAllClientViewsInCurrentGroup, selectLiveCaptionsRaw, selectLiveTranscriptionRaw, selectLocalParticipantRaw, selectLocalMediaStream, selectRemoteParticipants, selectScreenshares, selectRoomConnectionStatus, selectRoomConnectionError, selectRoomConnectionKnockResponse, selectStreamingRaw, selectWaitingParticipants, selectNotificationsEmitter, selectSpotlightedClientViews, selectIsCameraEnabled, selectIsMicrophoneEnabled, (chatMessages, fileUploads, cloudRecording, breakoutCurrentGroup, breakoutCurrentId, breakoutActive, breakoutGroupedParticipants, breakoutGroups, breakoutAssignments, breakoutEnforceAssignment, breakoutTimerSetting, breakoutTimerDuration, breakoutAutoMoveToGroup, breakoutMoveToGroupGracePeriod, breakoutAutoMoveToMain, breakoutMoveToMainGracePeriod, breakoutStartedAt, breakoutEndTime, breakoutMoveToGroupAt, breakoutMoveToMainAt, breakoutIsAvailable, breakoutError, clientViewsInCurrentGroup, liveCaptions, liveTranscription, localParticipant, localMediaStream, remoteParticipants, screenshares, connectionStatus, connectionError, knockResponse, streaming, waitingParticipants, notificationsEmitter, spotlightedClientViews, isCameraEnabled, isMicrophoneEnabled) => {
|
|
5463
|
+
const broadcastingParticipants = breakoutActive && breakoutCurrentId
|
|
5464
|
+
? spotlightedClientViews.filter((c) => !c.breakoutGroup && c.isAudioEnabled && !c.isPresentation)
|
|
5465
|
+
: [];
|
|
5245
5466
|
const state = {
|
|
5246
5467
|
chatMessages,
|
|
5247
5468
|
fileUploads,
|
|
@@ -5253,10 +5474,25 @@ const selectRoomConnectionState = createSelector(selectChatMessages, selectFileU
|
|
|
5253
5474
|
}
|
|
5254
5475
|
: undefined,
|
|
5255
5476
|
breakout: {
|
|
5477
|
+
isAvailable: breakoutIsAvailable,
|
|
5478
|
+
error: breakoutError,
|
|
5256
5479
|
isActive: breakoutActive,
|
|
5257
5480
|
currentGroup: breakoutCurrentGroup,
|
|
5481
|
+
groups: breakoutGroups !== null && breakoutGroups !== void 0 ? breakoutGroups : null,
|
|
5482
|
+
enforceAssignment: breakoutEnforceAssignment !== null && breakoutEnforceAssignment !== void 0 ? breakoutEnforceAssignment : false,
|
|
5483
|
+
autoMoveToGroup: breakoutAutoMoveToGroup !== null && breakoutAutoMoveToGroup !== void 0 ? breakoutAutoMoveToGroup : false,
|
|
5484
|
+
moveToGroupGracePeriod: breakoutMoveToGroupGracePeriod !== null && breakoutMoveToGroupGracePeriod !== void 0 ? breakoutMoveToGroupGracePeriod : null,
|
|
5485
|
+
autoMoveToMain: breakoutAutoMoveToMain !== null && breakoutAutoMoveToMain !== void 0 ? breakoutAutoMoveToMain : false,
|
|
5486
|
+
moveToMainGracePeriod: breakoutMoveToMainGracePeriod !== null && breakoutMoveToMainGracePeriod !== void 0 ? breakoutMoveToMainGracePeriod : null,
|
|
5487
|
+
breakoutTimerSetting: breakoutTimerSetting !== null && breakoutTimerSetting !== void 0 ? breakoutTimerSetting : false,
|
|
5488
|
+
breakoutTimerDuration: breakoutTimerDuration !== null && breakoutTimerDuration !== void 0 ? breakoutTimerDuration : 0,
|
|
5489
|
+
startedAt: breakoutStartedAt !== null && breakoutStartedAt !== void 0 ? breakoutStartedAt : null,
|
|
5490
|
+
endTime: breakoutEndTime,
|
|
5491
|
+
moveToGroupAt: breakoutMoveToGroupAt,
|
|
5492
|
+
moveToMainAt: breakoutMoveToMainAt,
|
|
5258
5493
|
groupedParticipants: breakoutGroupedParticipants,
|
|
5259
5494
|
participantsInCurrentGroup: clientViewsInCurrentGroup,
|
|
5495
|
+
broadcastingParticipants,
|
|
5260
5496
|
},
|
|
5261
5497
|
connectionStatus,
|
|
5262
5498
|
connectionError,
|
|
@@ -5287,7 +5523,7 @@ const selectRoomConnectionState = createSelector(selectChatMessages, selectFileU
|
|
|
5287
5523
|
: undefined,
|
|
5288
5524
|
localScreenshareStatus: localParticipant.isScreenSharing ? "active" : undefined,
|
|
5289
5525
|
localParticipant: Object.assign(Object.assign({}, localParticipant), { stream: localMediaStream }),
|
|
5290
|
-
remoteParticipants,
|
|
5526
|
+
remoteParticipants: remoteParticipants.map((participant) => (Object.assign(Object.assign({}, participant), { breakoutGroupAssigned: (breakoutAssignments === null || breakoutAssignments === void 0 ? void 0 : breakoutAssignments[participant.deviceId]) || "" }))),
|
|
5291
5527
|
screenshares,
|
|
5292
5528
|
waitingParticipants,
|
|
5293
5529
|
spotlightedParticipants: spotlightedClientViews,
|
|
@@ -5553,8 +5789,8 @@ class RoomConnectionClient extends BaseClient {
|
|
|
5553
5789
|
return promise;
|
|
5554
5790
|
});
|
|
5555
5791
|
}
|
|
5556
|
-
sendChatMessage(text, parentId) {
|
|
5557
|
-
this.store.dispatch(doSendChatMessage({ text, parentId }));
|
|
5792
|
+
sendChatMessage(text, parentId, isBroadcast) {
|
|
5793
|
+
this.store.dispatch(doSendChatMessage({ text, parentId, isBroadcast }));
|
|
5558
5794
|
}
|
|
5559
5795
|
removeChatMessage(id, sig) {
|
|
5560
5796
|
this.store.dispatch(doRemoveChatMessage({ id, sig }));
|
|
@@ -5662,6 +5898,39 @@ class RoomConnectionClient extends BaseClient {
|
|
|
5662
5898
|
joinBreakoutMainRoom() {
|
|
5663
5899
|
this.store.dispatch(doBreakoutJoin({ group: "" }));
|
|
5664
5900
|
}
|
|
5901
|
+
startBreakoutSession(options) {
|
|
5902
|
+
this.store.dispatch(doStartBreakoutSession(options));
|
|
5903
|
+
}
|
|
5904
|
+
updateBreakoutSession(options) {
|
|
5905
|
+
this.store.dispatch(doUpdateBreakoutSession(options));
|
|
5906
|
+
}
|
|
5907
|
+
stopBreakoutSession() {
|
|
5908
|
+
this.store.dispatch(doStopBreakoutSession());
|
|
5909
|
+
}
|
|
5910
|
+
assignBreakoutParticipants(assignments) {
|
|
5911
|
+
this.store.dispatch(doAssignBreakoutParticipants({ assignments }));
|
|
5912
|
+
}
|
|
5913
|
+
assignAllBreakoutParticipants() {
|
|
5914
|
+
this.store.dispatch(doAssignAllBreakoutParticipants());
|
|
5915
|
+
}
|
|
5916
|
+
unassignAllBreakoutParticipants() {
|
|
5917
|
+
this.store.dispatch(doUnassignAllBreakoutParticipants());
|
|
5918
|
+
}
|
|
5919
|
+
shuffleBreakoutParticipants() {
|
|
5920
|
+
this.store.dispatch(doShuffleBreakoutParticipants());
|
|
5921
|
+
}
|
|
5922
|
+
extendBreakoutTimer(seconds) {
|
|
5923
|
+
this.store.dispatch(doExtendBreakoutTimer({ seconds }));
|
|
5924
|
+
}
|
|
5925
|
+
stopBreakoutTimer() {
|
|
5926
|
+
this.store.dispatch(doStopBreakoutTimer());
|
|
5927
|
+
}
|
|
5928
|
+
broadcastToGroups(participantId) {
|
|
5929
|
+
this.store.dispatch(doSpotlightParticipant({ id: participantId }));
|
|
5930
|
+
}
|
|
5931
|
+
stopBroadcastToGroups(participantId) {
|
|
5932
|
+
this.store.dispatch(doRemoveSpotlight({ id: participantId }));
|
|
5933
|
+
}
|
|
5665
5934
|
reportStreamResolution(streamId, width, height) {
|
|
5666
5935
|
this.store.dispatch(doRtcReportStreamResolution({ streamId, width, height }));
|
|
5667
5936
|
}
|
|
@@ -5773,4 +6042,4 @@ class WherebyClient {
|
|
|
5773
6042
|
}
|
|
5774
6043
|
}
|
|
5775
6044
|
|
|
5776
|
-
export { ACCEPTED_FILE_TYPES, ApiClient, BREAKOUT_CONFIG_CHANGED, CAMERA_DEVICES_CHANGED, CAMERA_DEVICE_ERROR_CHANGED, CAMERA_STATE_CHANGED, CHAT_NEW_MESSAGE, CLIENT_VIEW_CHANGED, CLIENT_VIEW_SPOTLIGHTS_CHANGED, CLOUD_RECORDING_STATUS_CHANGED, CONNECTION_ERROR_CHANGED, CONNECTION_STATUS_CHANGED, CURRENT_CAMERA_CHANGED, CURRENT_MICROPHONE_CHANGED, CURRENT_SPEAKER_CHANGED, Credentials, CredentialsService, GridClient, IS_SETTING_CAMERA_DEVICE, IS_SETTING_MICROPHONE_DEVICE, LIVE_CAPTIONS_STATUS_CHANGED, LIVE_TRANSCRIPTION_STATUS_CHANGED, LOCAL_MEDIA_STARTING, LOCAL_MEDIA_START_ERROR_CHANGED, LOCAL_PARTICIPANT_CHANGED, LOCAL_SCREENSHARE_STATUS_CHANGED, LOCAL_STREAM_CHANGED, LiveCaption, LocalMediaClient, LocalParticipant, MAX_FILES_PER_UPLOAD, MAX_FILE_SIZE, MICROPHONE_DEVICES_CHANGED, MICROPHONE_DEVICE_ERROR_CHANGED, MICROPHONE_STATE_CHANGED, NUMBER_OF_CLIENT_VIEWS_CHANGED, Organization, OrganizationApiClient, OrganizationService, OrganizationServiceCache, REMOTE_PARTICIPANTS_CHANGED, ROOM_JOINED, ROOM_JOINED_ERROR, RoomConnectionClient, RoomService, SCREENSHARE_STARTED, SCREENSHARE_STOPPED, SPEAKER_DEVICES_CHANGED, SPOTLIGHT_PARTICIPANT_ADDED, SPOTLIGHT_PARTICIPANT_REMOVED, STREAMING_STARTED, STREAMING_STOPPED, WAITING_PARTICIPANT_JOINED, WAITING_PARTICIPANT_LEFT, WherebyClient, createServices, debounce, getAudioTrack, getFakeMediaStream, getUsableCameraEffectPresets, getVideoTrack, hasValue, isAudioDenoiserSupported, parseUnverifiedRoomKeyData };
|
|
6045
|
+
export { ACCEPTED_FILE_TYPES, ApiClient, BREAKOUT_CONFIG_CHANGED, BREAKOUT_GROUPS_MIN_MAX, BREAKOUT_UNAVAILABLE_ERROR, CAMERA_DEVICES_CHANGED, CAMERA_DEVICE_ERROR_CHANGED, CAMERA_STATE_CHANGED, CHAT_NEW_MESSAGE, CLIENT_VIEW_CHANGED, CLIENT_VIEW_SPOTLIGHTS_CHANGED, CLOUD_RECORDING_STATUS_CHANGED, CONNECTION_ERROR_CHANGED, CONNECTION_STATUS_CHANGED, CURRENT_CAMERA_CHANGED, CURRENT_MICROPHONE_CHANGED, CURRENT_SPEAKER_CHANGED, Credentials, CredentialsService, DEFAULT_BREAKOUT_TIMER_DURATION, GridClient, IS_SETTING_CAMERA_DEVICE, IS_SETTING_MICROPHONE_DEVICE, LIVE_CAPTIONS_STATUS_CHANGED, LIVE_TRANSCRIPTION_STATUS_CHANGED, LOCAL_MEDIA_STARTING, LOCAL_MEDIA_START_ERROR_CHANGED, LOCAL_PARTICIPANT_CHANGED, LOCAL_SCREENSHARE_STATUS_CHANGED, LOCAL_STREAM_CHANGED, LiveCaption, LocalMediaClient, LocalParticipant, MAX_FILES_PER_UPLOAD, MAX_FILE_SIZE, MICROPHONE_DEVICES_CHANGED, MICROPHONE_DEVICE_ERROR_CHANGED, MICROPHONE_STATE_CHANGED, NUMBER_OF_CLIENT_VIEWS_CHANGED, Organization, OrganizationApiClient, OrganizationService, OrganizationServiceCache, REMOTE_PARTICIPANTS_CHANGED, ROOM_JOINED, ROOM_JOINED_ERROR, RoomConnectionClient, RoomService, SCREENSHARE_STARTED, SCREENSHARE_STOPPED, SPEAKER_DEVICES_CHANGED, SPOTLIGHT_PARTICIPANT_ADDED, SPOTLIGHT_PARTICIPANT_REMOVED, STREAMING_STARTED, STREAMING_STOPPED, WAITING_PARTICIPANT_JOINED, WAITING_PARTICIPANT_LEFT, WherebyClient, createBreakoutGroups, createServices, debounce, defaultBreakoutGroupName, getAudioTrack, getFakeMediaStream, getUsableCameraEffectPresets, getVideoTrack, hasValue, isAudioDenoiserSupported, parseUnverifiedRoomKeyData };
|