Skip to content

Commit

Permalink
Add TURN support
Browse files Browse the repository at this point in the history
The TURN server url can be set via environment variable VUE_APP_TURN_URL.
  • Loading branch information
farao authored and janlelis committed Jun 21, 2020
1 parent 32b5eb1 commit 8498704
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
17 changes: 9 additions & 8 deletions src/views/Room.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 8498704

Please sign in to comment.