-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: moved symphony-connection-items into own component and added va…
…riables to global state
- Loading branch information
Showing
4 changed files
with
104 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/components/production-line/symphony-rtc-connection-component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { useEffect } from "react"; | ||
import { TJoinProductionOptions } from "./types"; | ||
import { TGlobalStateAction } from "../../global-state/global-state-actions"; | ||
import { useEstablishSession } from "./use-establish-session"; | ||
import { useRtcConnection } from "./use-rtc-connection"; | ||
import { useHeartbeat } from "./use-heartbeat"; | ||
import { TUseAudioInputValues } from "./use-audio-input"; | ||
|
||
type SymphonyRtcConnectionComponentProps = { | ||
joinProductionOptions: TJoinProductionOptions | null; | ||
inputAudioStream: TUseAudioInputValues; | ||
callId: string; | ||
dispatch: React.Dispatch<TGlobalStateAction>; | ||
}; | ||
|
||
export const SymphonyRtcConnectionComponent = ({ | ||
joinProductionOptions, | ||
inputAudioStream, | ||
callId, | ||
dispatch, | ||
}: SymphonyRtcConnectionComponentProps) => { | ||
const { sessionId, sdpOffer } = useEstablishSession({ | ||
joinProductionOptions, | ||
callId, | ||
dispatch, | ||
}); | ||
|
||
const { connectionState, audioElements } = useRtcConnection({ | ||
inputAudioStream, | ||
sdpOffer, | ||
joinProductionOptions, | ||
sessionId, | ||
callId, | ||
}); | ||
|
||
useHeartbeat({ sessionId }); | ||
|
||
useEffect(() => { | ||
dispatch({ | ||
type: "UPDATE_CALL", | ||
payload: { | ||
id: callId, | ||
updates: { | ||
connectionState, | ||
}, | ||
}, | ||
}); | ||
}, [callId, connectionState, dispatch]); | ||
|
||
useEffect(() => { | ||
dispatch({ | ||
type: "UPDATE_CALL", | ||
payload: { | ||
id: callId, | ||
updates: { | ||
audioElements, | ||
}, | ||
}, | ||
}); | ||
}, [audioElements, callId, dispatch]); | ||
|
||
useEffect(() => { | ||
dispatch({ | ||
type: "UPDATE_CALL", | ||
payload: { | ||
id: callId, | ||
updates: { | ||
sessionId, | ||
}, | ||
}, | ||
}); | ||
}, [sessionId, callId, dispatch]); | ||
|
||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters