openvidu-browser: get openviduServerUrl from token in VB

pull/722/head
pabloFuente 2022-04-28 12:10:26 +02:00
parent 2e39243070
commit 1517be875a
2 changed files with 8 additions and 13 deletions

View File

@ -1370,13 +1370,14 @@ export class Session extends EventDispatcher {
}, {});
return {
url,
sessionId: queryParams['sessionId'],
secret: queryParams['secret'],
recorder: queryParams['recorder'],
webrtcStatsInterval: queryParams['webrtcStatsInterval'],
sendBrowserLogs: queryParams['sendBrowserLogs'],
edition: queryParams['edition']
edition: queryParams['edition'],
wsUri = 'wss://' + url.host + '/openvidu',
httpUri = 'https://' + url.host
};
} else {
@ -1519,8 +1520,8 @@ export class Session extends EventDispatcher {
this.openvidu.isAtLeastPro = tokenParams.edition === 'pro' || tokenParams.edition === 'enterprise';
this.openvidu.isEnterprise = tokenParams.edition === 'enterprise';
this.openvidu.wsUri = 'wss://' + tokenParams.url.host + '/openvidu';
this.openvidu.httpUri = 'https://' + tokenParams.url.host;
this.openvidu.wsUri = tokenParams.wsUri;
this.openvidu.httpUri = tokenParams.httpUri;
}
private processJoinRoomResponse(opts: LocalConnectionOptions, token: string) {

View File

@ -365,15 +365,9 @@ export class Stream {
return reject(new OpenViduError(OpenViduErrorName.VIRTUAL_BACKGROUND_ERROR, 'Virtual Background requires the client to be connected to a Session or to have a "token" property available in "options" parameter with a valid OpenVidu token'));
}
if (!!this.session.token && !this.session.openvidu.isAtLeastPro) {
// Check OpenVidu edition after connection to the Session
const tokenParams = this.session.getTokenParams(openviduToken);
if (tokenParams.edition !== 'pro' && tokenParams.edition !== 'enterprise') {
return reject(new OpenViduError(OpenViduErrorName.VIRTUAL_BACKGROUND_ERROR, 'OpenVidu Virtual Background API is available from OpenVidu Pro edition onwards'));
} else {
// Check OpenVidu edition with the token
const tokenParams = this.session.getTokenParams(openviduToken);
if (tokenParams.edition !== 'pro' && tokenParams.edition !== 'enterprise') {
return reject(new OpenViduError(OpenViduErrorName.VIRTUAL_BACKGROUND_ERROR, 'OpenVidu Virtual Background API is available from OpenVidu Pro edition onwards'));
}
}
openviduToken = encodeURIComponent(btoa(openviduToken));
@ -400,7 +394,7 @@ export class Stream {
// @ts-ignore
const VB = new VirtualBackground.VirtualBackground({
id,
openviduServerUrl: new URL(this.session.openvidu.httpUri),
openviduServerUrl: new URL(tokenParams.httpUri),
openviduToken,
inputVideo: videoClone,
inputResolution: '160x96',