openvidu-components: Allowed one single string token in webcomponent

pull/732/head
csantosm 2022-06-02 18:00:14 +02:00
parent 2fd764ce7c
commit 5d574fb3d2
3 changed files with 17 additions and 7 deletions

View File

@ -39,6 +39,7 @@ import { PanelType } from '../../models/panel.model';
import { PanelService } from '../../services/panel/panel.service';
import { RecordingService } from '../../services/recording/recording.service';
import { TranslateService } from '../../services/translate/translate.service';
import { OpenViduAngularConfigService } from '../../services/config/openvidu-angular.config.service';
/**
* @internal
@ -80,6 +81,7 @@ export class SessionComponent implements OnInit {
protected loggerSrv: LoggerService,
protected chatService: ChatService,
protected tokenService: TokenService,
private libService: OpenViduAngularConfigService,
protected layoutService: LayoutService,
protected panelService: PanelService,
private recordingService: RecordingService,
@ -121,6 +123,10 @@ export class SessionComponent implements OnInit {
async ngOnInit() {
if (!this.usedInPrejoinPage) {
if(!this.tokenService.getScreenToken()){
// Hide screenshare button if screen token does not exist
this.libService.screenshareButton.next(false);
}
this.session = this.openviduService.getWebcamSession();
this.sessionScreen = this.openviduService.getScreenSession();
this.subscribeToConnectionCreatedAndDestroyed();

View File

@ -279,8 +279,6 @@ export class VideoconferenceComponent implements OnInit, OnDestroy, AfterViewIni
if (tokens.screen) {
this.tokenService.setScreenToken(tokens.screen);
} else {
// Hide screenshare button if screen token does not exist
this.libService.screenshareButton.next(false);
this.log.w('No screen token found. Screenshare feature will be disabled');
}
this.tokensReceived = true;

View File

@ -514,7 +514,10 @@ export class OpenviduWebComponentComponent implements OnInit {
/**
* @example
* <openvidu-webcomponent tokens='{"webcam":"TOKEN1", "screen":"TOKEN2"}'></openvidu-webcomponent>
* * <openvidu-webcomponent tokens='TOKEN'></openvidu-webcomponent>
*
* or
*
* <openvidu-webcomponent tokens='TOKEN1'></openvidu-webcomponent>
*/
@Input('tokens')
set tokens(value: TokenModel | string) {
@ -523,8 +526,12 @@ export class OpenviduWebComponentComponent implements OnInit {
this._tokens = this.castToJson(value);
this.success = !!this._tokens?.webcam && !!this._tokens?.screen;
} catch (error) {
this.log.e(error);
if (!this.success) {
if (typeof value === 'string' && value !== '') {
this.log.d('Sigle token received.');
this._tokens = { webcam: value };
this.success = true;
} else {
this.log.e(error);
this.log.e('Parameters received are incorrect: ', value);
this.log.e('Session cannot start');
}
@ -663,8 +670,7 @@ export class OpenviduWebComponentComponent implements OnInit {
try {
return JSON.parse(value);
} catch (error) {
this.log.e('Unexpected JSON', error);
throw 'Unexpected JSON';
throw 'Unexpected JSON' + error;
}
} else if (typeof value === 'object') {
return value;