diff --git a/README.md b/README.md index 7a0287e..615edd8 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,10 @@ Sets the location to the palava signaling server. By default, it tries to reach The (required) [STUN server](https://en.wikipedia.org/wiki/STUN) to use, defaults to `stun: stun:stun.palava.tv` +### `VUE_APP_STUN_URL` + +The (optional) [TURN server](https://en.wikipedia.org/wiki/TURN) to use. + ### `BUILD_NOT_MINIFIED` When set, the production build will not be minified. diff --git a/src/config.js b/src/config.js index e8ed65d..8452d1e 100644 --- a/src/config.js +++ b/src/config.js @@ -2,6 +2,7 @@ export default { env: { rtcUrl: process.env.VUE_APP_RTC_URL, stunUrl: process.env.VUE_APP_STUN_URL, + turnUrl: process.env.VUE_APP_TURN_URL, }, defaultRtcUrl: 'ws://localhost:4233', defaultStunUrl: 'stun:stun.palava.tv', diff --git a/src/views/Room.vue b/src/views/Room.vue index 5e93af4..0fee2e3 100644 --- a/src/views/Room.vue +++ b/src/views/Room.vue @@ -54,14 +54,15 @@ export default { created() { const roomId = this.$route.params.roomId this.catchInvalidRoomId(roomId) - this.rtc = this.setupRtc( - new Session({ - roomId, - webSocketAddress: config.env.rtcUrl || config.defaultRtcUrl, - stun: config.env.stunUrl || config.defaultStunUrl, - joinTimeout: config.defaultJoinTimeout, - }) - ) + + const sessionConfig = { + webSocketAddress: config.env.rtcUrl || config.defaultRtcUrl, + stun: config.env.stunUrl || config.defaultStunUrl, + joinTimeout: config.defaultJoinTimeout, + } + if (config.env.turnUrl) { sessionConfig.turn = config.env.turnUrl } + + this.rtc = this.setupRtc(new Session(roomId, sessionConfig)) }, beforeDestroy() { this.rtc.destroy()