fixup! Jitsi config properties
This commit is contained in:
parent
9c4d0aa32f
commit
5cb9624b0b
2 changed files with 20 additions and 44 deletions
|
@ -631,6 +631,15 @@ export class GameScene extends ResizableScene implements CenterListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private safeParseJSONstring(jsonString: string|undefined) {
|
||||||
|
try {
|
||||||
|
return jsonString ? JSON.parse(jsonString) : {};
|
||||||
|
} catch(e) {
|
||||||
|
console.warn(jsonString, e);
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private triggerOnMapLayerPropertyChange(){
|
private triggerOnMapLayerPropertyChange(){
|
||||||
this.gameMap.onPropertyChange('exitSceneUrl', (newValue, oldValue) => {
|
this.gameMap.onPropertyChange('exitSceneUrl', (newValue, oldValue) => {
|
||||||
if (newValue) this.onMapExit(newValue as string);
|
if (newValue) this.onMapExit(newValue as string);
|
||||||
|
@ -669,13 +678,10 @@ export class GameScene extends ResizableScene implements CenterListener {
|
||||||
|
|
||||||
this.connection.emitQueryJitsiJwtMessage(this.instance.replace('/', '-') + "-" + newValue, adminTag);
|
this.connection.emitQueryJitsiJwtMessage(this.instance.replace('/', '-') + "-" + newValue, adminTag);
|
||||||
} else {
|
} else {
|
||||||
const jitsiConfig = allProps.get("jitsiConfig") as string|undefined;
|
const jitsiConfig = this.safeParseJSONstring(allProps.get("jitsiConfig") as string|undefined);
|
||||||
jitsiFactory.setJitsiConfig(jitsiConfig || undefined);
|
const jitsiInterfaceConfig = this.safeParseJSONstring(allProps.get("jitsiInterfaceConfig") as string|undefined);
|
||||||
|
|
||||||
const jitsiInterfaceConfig = allProps.get("jitsiInterfaceConfig") as string|undefined;
|
this.startJitsi(newValue as string, undefined, jitsiConfig, jitsiInterfaceConfig);
|
||||||
jitsiFactory.setJitsiInterfaceConfig(jitsiInterfaceConfig || undefined);
|
|
||||||
|
|
||||||
this.startJitsi(newValue as string);
|
|
||||||
}
|
}
|
||||||
layoutManager.removeActionButton('jitsiRoom', this.userInputManager);
|
layoutManager.removeActionButton('jitsiRoom', this.userInputManager);
|
||||||
}
|
}
|
||||||
|
@ -1234,8 +1240,8 @@ export class GameScene extends ResizableScene implements CenterListener {
|
||||||
this.updateCameraOffset();
|
this.updateCameraOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public startJitsi(roomName: string, jwt?: string): void {
|
public startJitsi(roomName: string, jwt?: string, config: object = {}, interfaceConfig: object = {}): void {
|
||||||
jitsiFactory.start(roomName, this.playerName, jwt);
|
jitsiFactory.start(roomName, this.playerName, jwt, config, interfaceConfig);
|
||||||
this.connection.setSilent(true);
|
this.connection.setSilent(true);
|
||||||
mediaManager.hideGameOverlay();
|
mediaManager.hideGameOverlay();
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,13 @@ import {mediaManager} from "./MediaManager";
|
||||||
import {coWebsiteManager} from "./CoWebsiteManager";
|
import {coWebsiteManager} from "./CoWebsiteManager";
|
||||||
declare const window:any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
declare const window:any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
|
|
||||||
const config = {
|
const defaultConfig = {
|
||||||
startWithAudioMuted: !mediaManager.constraintsMedia.audio,
|
startWithAudioMuted: !mediaManager.constraintsMedia.audio,
|
||||||
startWithVideoMuted: mediaManager.constraintsMedia.video === false,
|
startWithVideoMuted: mediaManager.constraintsMedia.video === false,
|
||||||
prejoinPageEnabled: false
|
prejoinPageEnabled: false
|
||||||
}
|
}
|
||||||
|
|
||||||
const interfaceConfig = {
|
const defaultInterfaceConfig = {
|
||||||
SHOW_CHROME_EXTENSION_BANNER: false,
|
SHOW_CHROME_EXTENSION_BANNER: false,
|
||||||
MOBILE_APP_PROMO: false,
|
MOBILE_APP_PROMO: false,
|
||||||
|
|
||||||
|
@ -32,13 +32,11 @@ const interfaceConfig = {
|
||||||
};
|
};
|
||||||
|
|
||||||
class JitsiFactory {
|
class JitsiFactory {
|
||||||
public jitsiConfig: object = config;
|
|
||||||
public jitsiInterfaceConfig: object = interfaceConfig;
|
|
||||||
private jitsiApi: any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
private jitsiApi: any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
private audioCallback = this.onAudioChange.bind(this);
|
private audioCallback = this.onAudioChange.bind(this);
|
||||||
private videoCallback = this.onVideoChange.bind(this);
|
private videoCallback = this.onVideoChange.bind(this);
|
||||||
|
|
||||||
public start(roomName: string, playerName:string, jwt?: string): void {
|
public start(roomName: string, playerName:string, jwt?: string, config?: object, interfaceConfig?: object): void {
|
||||||
coWebsiteManager.insertCoWebsite((cowebsiteDiv => {
|
coWebsiteManager.insertCoWebsite((cowebsiteDiv => {
|
||||||
const domain = JITSI_URL;
|
const domain = JITSI_URL;
|
||||||
const options: any = { // eslint-disable-line @typescript-eslint/no-explicit-any
|
const options: any = { // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
|
@ -47,8 +45,8 @@ class JitsiFactory {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
parentNode: cowebsiteDiv,
|
parentNode: cowebsiteDiv,
|
||||||
configOverwrite: this.jitsiConfig,
|
configOverwrite: {...defaultConfig, ...config},
|
||||||
interfaceConfigOverwrite: this.jitsiInterfaceConfig
|
interfaceConfigOverwrite: {...defaultInterfaceConfig, ...interfaceConfig}
|
||||||
};
|
};
|
||||||
if (!options.jwt) {
|
if (!options.jwt) {
|
||||||
delete options.jwt;
|
delete options.jwt;
|
||||||
|
@ -91,34 +89,6 @@ class JitsiFactory {
|
||||||
mediaManager.enableCamera();
|
mediaManager.enableCamera();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setJitsiConfig(jitsiConfig: string|undefined): void {
|
|
||||||
if(jitsiConfig) {
|
|
||||||
try {
|
|
||||||
const parsedConfig = JSON.parse(jitsiConfig);
|
|
||||||
this.jitsiConfig = {...config, ...parsedConfig};
|
|
||||||
} catch (e) {
|
|
||||||
console.warn('jitsiConfig', e);
|
|
||||||
this.jitsiConfig = config;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.jitsiConfig = config;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public setJitsiInterfaceConfig(jitsiInterfaceConfig: string|undefined): void {
|
|
||||||
if(jitsiInterfaceConfig) {
|
|
||||||
try {
|
|
||||||
const parsedInterfaceConfig = JSON.parse(jitsiInterfaceConfig);
|
|
||||||
this.jitsiInterfaceConfig = {...interfaceConfig, ...parsedInterfaceConfig};
|
|
||||||
} catch (e) {
|
|
||||||
console.warn('jitsiInterfaceConfig', e);
|
|
||||||
this.jitsiInterfaceConfig = interfaceConfig;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.jitsiInterfaceConfig = interfaceConfig;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const jitsiFactory = new JitsiFactory();
|
export const jitsiFactory = new JitsiFactory();
|
Loading…
Add table
Add a link
Reference in a new issue