Update to use update function scene
This commit is contained in:
parent
69f3e511ab
commit
997acd17ad
@ -634,7 +634,6 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||||||
this.gameMap.setPosition(event.x, event.y);
|
this.gameMap.setPosition(event.x, event.y);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
this.scene.wake();
|
this.scene.wake();
|
||||||
this.scene.sleep(ReconnectingSceneName);
|
this.scene.sleep(ReconnectingSceneName);
|
||||||
|
|
||||||
@ -973,6 +972,8 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||||||
this.scene.remove(this.scene.key);
|
this.scene.remove(this.scene.key);
|
||||||
this.scene.start(nextSceneKey.key);
|
this.scene.start(nextSceneKey.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mediaManager.setLastUpdateScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkToExit(): {key: string, hash: string} | null {
|
private checkToExit(): {key: string, hash: string} | null {
|
||||||
|
@ -39,7 +39,10 @@ export class MediaManager {
|
|||||||
private monitorBtn: HTMLDivElement;
|
private monitorBtn: HTMLDivElement;
|
||||||
|
|
||||||
private previousConstraint : MediaStreamConstraints;
|
private previousConstraint : MediaStreamConstraints;
|
||||||
private timeoutBlurWindows?: NodeJS.Timeout;
|
private focused : boolean = true;
|
||||||
|
|
||||||
|
private lastUpdateScene : Date = new Date();
|
||||||
|
private setTimeOutlastUpdateScene? : NodeJS.Timeout;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
||||||
@ -94,22 +97,30 @@ export class MediaManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.previousConstraint = JSON.parse(JSON.stringify(this.constraintsMedia));
|
this.previousConstraint = JSON.parse(JSON.stringify(this.constraintsMedia));
|
||||||
window.addEventListener('blur', () => {
|
this.pingCameraStatus();
|
||||||
if(this.timeoutBlurWindows){
|
|
||||||
clearTimeout(this.timeoutBlurWindows);
|
this.checkActiveUser();
|
||||||
}
|
}
|
||||||
this.timeoutBlurWindows = setTimeout(() => {
|
|
||||||
|
public setLastUpdateScene(){
|
||||||
|
this.lastUpdateScene = new Date();
|
||||||
|
}
|
||||||
|
|
||||||
|
public blurCamera() {
|
||||||
|
if(!this.focused){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.focused = false;
|
||||||
this.previousConstraint = JSON.parse(JSON.stringify(this.constraintsMedia));
|
this.previousConstraint = JSON.parse(JSON.stringify(this.constraintsMedia));
|
||||||
this.disableCamera();
|
this.disableCamera();
|
||||||
}, 10000);
|
|
||||||
});
|
|
||||||
window.addEventListener('focus', () => {
|
|
||||||
if(this.timeoutBlurWindows){
|
|
||||||
clearTimeout(this.timeoutBlurWindows);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public focusCamera() {
|
||||||
|
if(this.focused){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.focused = true;
|
||||||
this.applyPreviousConfig();
|
this.applyPreviousConfig();
|
||||||
});
|
|
||||||
this.pingCameraStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onUpdateLocalStream(callback: UpdatedLocalStreamCallback): void {
|
public onUpdateLocalStream(callback: UpdatedLocalStreamCallback): void {
|
||||||
@ -631,7 +642,22 @@ export class MediaManager {
|
|||||||
}, 30000);
|
}, 30000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check if user is active
|
||||||
|
private checkActiveUser(){
|
||||||
|
if(this.setTimeOutlastUpdateScene){
|
||||||
|
clearTimeout(this.setTimeOutlastUpdateScene);
|
||||||
|
}
|
||||||
|
this.setTimeOutlastUpdateScene = setTimeout(() => {
|
||||||
|
const now = new Date();
|
||||||
|
//if last update is more of 10 sec
|
||||||
|
if( (now.getTime() - this.lastUpdateScene.getTime()) > 10000) {
|
||||||
|
this.blurCamera();
|
||||||
|
}else{
|
||||||
|
this.focusCamera();
|
||||||
|
}
|
||||||
|
this.checkActiveUser();
|
||||||
|
}, this.focused ? 10000 : 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mediaManager = new MediaManager();
|
export const mediaManager = new MediaManager();
|
||||||
|
Loading…
Reference in New Issue
Block a user