change(ui) - peerjs iceserver env config
This commit is contained in:
parent
95e3083e9c
commit
069d7a2338
3 changed files with 36 additions and 4 deletions
|
|
@ -6,8 +6,8 @@ import type { Message } from '../messages'
|
||||||
import { ID_TP_MAP } from '../messages';
|
import { ID_TP_MAP } from '../messages';
|
||||||
import store from 'App/store';
|
import store from 'App/store';
|
||||||
import type { LocalStream } from './LocalStream';
|
import type { LocalStream } from './LocalStream';
|
||||||
|
|
||||||
import { update, getState } from '../../store';
|
import { update, getState } from '../../store';
|
||||||
|
import { iceServerConfigFromString } from 'App/utils'
|
||||||
|
|
||||||
|
|
||||||
export enum CallingState {
|
export enum CallingState {
|
||||||
|
|
@ -149,12 +149,20 @@ export default class AssistManager {
|
||||||
this.setStatus(ConnectionStatus.Connecting)
|
this.setStatus(ConnectionStatus.Connecting)
|
||||||
import('peerjs').then(({ default: Peer }) => {
|
import('peerjs').then(({ default: Peer }) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const peer = new Peer({
|
const iceServers = iceServerConfigFromString(window.ENV.ICE_SERVERS);
|
||||||
|
const _config = {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
host: new URL(window.ENV.API_EDP).host,
|
host: new URL(window.ENV.API_EDP).host,
|
||||||
path: '/assist',
|
path: '/assist',
|
||||||
port: location.protocol === 'https:' ? 443 : 80,
|
port: location.protocol === 'https:' ? 443 : 80,
|
||||||
});
|
sdpSemantics: 'unified-plan'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iceServers) {
|
||||||
|
_config['config'] = iceServers;
|
||||||
|
}
|
||||||
|
|
||||||
|
const peer = new Peer(_config);
|
||||||
this.peer = peer;
|
this.peer = peer;
|
||||||
peer.on('error', e => {
|
peer.on('error', e => {
|
||||||
if (e.type !== 'peer-unavailable') {
|
if (e.type !== 'peer-unavailable') {
|
||||||
|
|
|
||||||
|
|
@ -203,4 +203,27 @@ export const colorScale = (values, colors) => {
|
||||||
.range([colors[0], colors[colors.length - 1]]);
|
.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
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -20,6 +20,7 @@ const oss = {
|
||||||
MINIO_USE_SSL: process.env.MINIO_USE_SSL,
|
MINIO_USE_SSL: process.env.MINIO_USE_SSL,
|
||||||
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
||||||
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
||||||
|
ICE_SERVERS: process.env.ICE_SERVERS,
|
||||||
TRACKER_VERSION: '3.4.7', // trackerInfo.version,
|
TRACKER_VERSION: '3.4.7', // trackerInfo.version,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue