change(ui) - peerjs iceserver env config

This commit is contained in:
Shekar Siri 2021-11-21 22:41:37 +05:30
parent 95e3083e9c
commit 069d7a2338
3 changed files with 36 additions and 4 deletions

View file

@ -6,8 +6,8 @@ import type { Message } from '../messages'
import { ID_TP_MAP } from '../messages';
import store from 'App/store';
import type { LocalStream } from './LocalStream';
import { update, getState } from '../../store';
import { iceServerConfigFromString } from 'App/utils'
export enum CallingState {
@ -149,12 +149,20 @@ export default class AssistManager {
this.setStatus(ConnectionStatus.Connecting)
import('peerjs').then(({ default: Peer }) => {
// @ts-ignore
const peer = new Peer({
const iceServers = iceServerConfigFromString(window.ENV.ICE_SERVERS);
const _config = {
// @ts-ignore
host: new URL(window.ENV.API_EDP).host,
path: '/assist',
port: location.protocol === 'https:' ? 443 : 80,
});
sdpSemantics: 'unified-plan'
}
if (iceServers) {
_config['config'] = iceServers;
}
const peer = new Peer(_config);
this.peer = peer;
peer.on('error', e => {
if (e.type !== 'peer-unavailable') {

View file

@ -203,4 +203,27 @@ export const colorScale = (values, colors) => {
.range([colors[0], colors[colors.length - 1]]);
}
export const truncate = (input, max = 10) => input.length > max ? `${input.substring(0, max)}...` : input;
export const truncate = (input, max = 10) => input.length > max ? `${input.substring(0, max)}...` : input;
export const iceServerConfigFromString = (str) => {
if (!str || typeof str !== 'string'|| str.length === 0) {
return null;
}
return str.split("|").map(function(c) {
let server = null
const arr = c.split(",")
if (!!arr[0] !== "") {
server = {}
server.urls = arr[0]
if (!!arr[1]) {
server.username = arr[1]
if (!!arr[2]) {
server.password = arr[2]
}
}
return server
}
})
}

View file

@ -20,6 +20,7 @@ const oss = {
MINIO_USE_SSL: process.env.MINIO_USE_SSL,
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
ICE_SERVERS: process.env.ICE_SERVERS,
TRACKER_VERSION: '3.4.7', // trackerInfo.version,
}