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