Skip to content

Commit

Permalink
core: Do not send client metadata before connecting to room
Browse files Browse the repository at this point in the history
  • Loading branch information
thyal committed Dec 10, 2024
1 parent 1b6e43c commit 8266f4e
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-shrimps-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@whereby.com/core": minor
---

Do not send client metadata before connecting to room
1 change: 1 addition & 0 deletions packages/core/src/redux/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export * from "./slices/organization";
export * from "./slices/remoteParticipants";
export * from "./slices/room";
export * from "./slices/roomConnection";
export * from "./slices/roomConnection/selectors";
export * from "./slices/rtcAnalytics";
export * from "./slices/spotlights";
export * from "./slices/streaming";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/redux/slices/connectionMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { setClientProvider, subscribeIssues } from "@whereby.com/media";
import { RootState } from "../store";
import { createAppThunk } from "../thunk";
import { createReactor } from "../listenerMiddleware";
import { selectRoomConnectionStatus } from "./roomConnection";
import { selectRoomConnectionStatus } from "./roomConnection/selectors";
import { selectRtcManager } from "./rtcConnection";
import { selectAllClientViews } from "./room";

Expand Down
15 changes: 10 additions & 5 deletions packages/core/src/redux/slices/localParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { LocalParticipant } from "../../RoomParticipant";
import { selectSignalConnectionRaw } from "./signalConnection";
import { doAppStart } from "./app";
import { selectLocalMediaStream, toggleCameraEnabled, toggleMicrophoneEnabled } from "./localMedia";
import { createReactor, startAppListening } from "../listenerMiddleware";
import { startAppListening } from "../listenerMiddleware";
import { signalEvents } from "./signalConnection/actions";
import { ClientView } from "../types";
import { NON_PERSON_ROLES } from "../constants";
import { selectRoomConnectionStatus } from "./roomConnection/selectors";

export interface LocalParticipantState extends LocalParticipant {
isScreenSharing: boolean;
Expand Down Expand Up @@ -217,7 +218,11 @@ startAppListening({
effect: ({ payload }, { dispatch, getState }) => {
const { enabled } = payload;
const { isVideoEnabled } = selectLocalParticipantRaw(getState());
const roomConnectionStatus = selectRoomConnectionStatus(getState());

if (roomConnectionStatus !== "connected") {
return;
}
dispatch(doEnableVideo({ enabled: enabled || !isVideoEnabled }));
},
});
Expand All @@ -227,11 +232,11 @@ startAppListening({
effect: ({ payload }, { dispatch, getState }) => {
const { enabled } = payload;
const { isAudioEnabled } = selectLocalParticipantRaw(getState());
const roomConnectionStatus = selectRoomConnectionStatus(getState());

if (roomConnectionStatus !== "connected") {
return;
}
dispatch(doEnableAudio({ enabled: enabled || !isAudioEnabled }));
},
});

createReactor([selectLocalParticipantDisplayName, selectLocalParticipantStickyReaction], ({ dispatch }) => {
dispatch(doSendClientMetadata());
});
2 changes: 1 addition & 1 deletion packages/core/src/redux/slices/notifications/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createReactor, startAppListening } from "../../listenerMiddleware";
import { signalEvents } from "../signalConnection/actions";
import { selectRemoteParticipants } from "../remoteParticipants";
import { selectSignalStatus } from "../signalConnection";
import { selectRoomConnectionStatus } from "../roomConnection";
import { selectRoomConnectionStatus } from "../roomConnection/selectors";
import { selectIsAuthorizedToAskToSpeak } from "../authorization";
import {
Notification,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PayloadAction, createSelector, createSlice } from "@reduxjs/toolkit";

import { createReactor, startAppListening } from "../listenerMiddleware";
import { RootState } from "../store";
import { createAppThunk } from "../thunk";
import { createReactor, startAppListening } from "../../listenerMiddleware";
import { selectRoomConnectionError, selectRoomConnectionStatus } from "./selectors";
import { createAppThunk } from "../../thunk";
import {
doAppStop,
selectAppDisplayName,
Expand All @@ -11,19 +11,25 @@ import {
selectAppExternalId,
selectAppIsActive,
selectAppIsDialIn,
} from "./app";
import { selectRoomKey, setRoomKey } from "./authorization";
} from "../app";
import { selectRoomKey, setRoomKey } from "../authorization";

import { selectOrganizationId } from "./organization";
import { signalEvents } from "./signalConnection/actions";
import { selectOrganizationId } from "../organization";
import { signalEvents } from "../signalConnection/actions";
import {
doSignalDisconnect,
selectSignalConnectionDeviceIdentified,
selectSignalConnectionRaw,
socketReconnecting,
} from "./signalConnection";
import { selectIsCameraEnabled, selectIsMicrophoneEnabled, selectLocalMediaStatus } from "./localMedia";
import { selectSelfId, selectLocalParticipantClientClaim } from "./localParticipant";
} from "../signalConnection";
import { selectIsCameraEnabled, selectIsMicrophoneEnabled, selectLocalMediaStatus } from "../localMedia";
import {
selectSelfId,
selectLocalParticipantClientClaim,
selectLocalParticipantDisplayName,
selectLocalParticipantStickyReaction,
doSendClientMetadata,
} from "../localParticipant";

export type ConnectionStatus =
| "ready"
Expand Down Expand Up @@ -219,16 +225,6 @@ export const doConnectRoom = createAppThunk(() => (dispatch, getState) => {
dispatch(connectionStatusChanged("connecting"));
});

/**
* Selectors
*/

export const selectRoomConnectionRaw = (state: RootState) => state.roomConnection;
export const selectRoomConnectionSession = (state: RootState) => state.roomConnection.session;
export const selectRoomConnectionSessionId = (state: RootState) => state.roomConnection.session?.id;
export const selectRoomConnectionStatus = (state: RootState) => state.roomConnection.status;
export const selectRoomConnectionError = (state: RootState) => state.roomConnection.error;

/**
* Reactors
*/
Expand Down Expand Up @@ -309,3 +305,12 @@ startAppListening({
}
},
});

createReactor(
[selectLocalParticipantDisplayName, selectLocalParticipantStickyReaction, selectRoomConnectionStatus],
({ dispatch }, diplayName, stickyReaction, roomConnectionStatus) => {
if (roomConnectionStatus === "connected") {
dispatch(doSendClientMetadata());
}
},
);
10 changes: 10 additions & 0 deletions packages/core/src/redux/slices/roomConnection/selectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { RootState } from "../../store";
/**
* Selectors
*/

export const selectRoomConnectionRaw = (state: RootState) => state.roomConnection;
export const selectRoomConnectionSession = (state: RootState) => state.roomConnection.session;
export const selectRoomConnectionSessionId = (state: RootState) => state.roomConnection.session?.id;
export const selectRoomConnectionStatus = (state: RootState) => state.roomConnection.status;
export const selectRoomConnectionError = (state: RootState) => state.roomConnection.error;
2 changes: 1 addition & 1 deletion packages/core/src/redux/slices/rtcAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { selectSignalStatus } from "./signalConnection";
import { selectDeviceId } from "./deviceCredentials";
import { doSetDevice, selectIsCameraEnabled, selectIsMicrophoneEnabled, selectLocalMediaStream } from "./localMedia";
import { doStartScreenshare, selectLocalScreenshareStream, stopScreenshare } from "./localScreenshare";
import { selectRoomConnectionSessionId } from "./roomConnection";
import { selectRoomConnectionSessionId } from "./roomConnection/selectors";
import { signalEvents } from "./signalConnection/actions";

type RtcAnalyticsCustomEvent = {
Expand Down

0 comments on commit 8266f4e

Please sign in to comment.