From d2778209619499fcbf370ac448ab62b31ee3d495 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Sat, 10 Sep 2022 17:52:53 -0500 Subject: [PATCH] refactor: move rtcConfig to its own file --- src/components/Room/Room.tsx | 24 ++---------------------- src/config/rtcConfig.ts | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 src/config/rtcConfig.ts diff --git a/src/components/Room/Room.tsx b/src/components/Room/Room.tsx index e95ca9d..f48d4f7 100644 --- a/src/components/Room/Room.tsx +++ b/src/components/Room/Room.tsx @@ -3,6 +3,7 @@ import { v4 as uuid } from 'uuid' import Box from '@mui/material/Box' import Divider from '@mui/material/Divider' +import { rtcConfig } from 'config/rtcConfig' import { ShellContext } from 'contexts/ShellContext' import { usePeerRoom, usePeerRoomAction } from 'hooks/usePeerRoom' import { PeerActions } from 'models/network' @@ -36,28 +37,7 @@ export function Room({ trackerUrls: process.env.REACT_APP_TRACKER_URL ? [process.env.REACT_APP_TRACKER_URL] : undefined, - rtcConfig: { - iceServers: [ - { - urls: 'stun:openrelay.metered.ca:80', - }, - { - urls: 'turn:openrelay.metered.ca:80', - username: 'openrelayproject', - credential: 'openrelayproject', - }, - { - urls: 'turn:openrelay.metered.ca:443', - username: 'openrelayproject', - credential: 'openrelayproject', - }, - { - urls: 'turn:openrelay.metered.ca:443?transport=tcp', - username: 'openrelayproject', - credential: 'openrelayproject', - }, - ], - }, + rtcConfig, }, roomId ) diff --git a/src/config/rtcConfig.ts b/src/config/rtcConfig.ts new file mode 100644 index 0000000..ade8b43 --- /dev/null +++ b/src/config/rtcConfig.ts @@ -0,0 +1,22 @@ +export const rtcConfig: RTCConfiguration = { + iceServers: [ + { + urls: 'stun:openrelay.metered.ca:80', + }, + { + urls: 'turn:openrelay.metered.ca:80', + username: 'openrelayproject', + credential: 'openrelayproject', + }, + { + urls: 'turn:openrelay.metered.ca:443', + username: 'openrelayproject', + credential: 'openrelayproject', + }, + { + urls: 'turn:openrelay.metered.ca:443?transport=tcp', + username: 'openrelayproject', + credential: 'openrelayproject', + }, + ], +}