From 227575043b9b4d0c80a565f88046620caf93531d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 17 Jun 2021 18:48:56 +0200 Subject: [PATCH] Removing dead code --- front/src/Phaser/Game/GameScene.ts | 11 +---- front/src/WebRtc/LayoutManager.ts | 8 ---- front/src/WebRtc/MediaManager.ts | 63 +-------------------------- front/src/WebRtc/ScreenSharingPeer.ts | 21 --------- front/src/WebRtc/SimplePeer.ts | 12 ----- front/src/WebRtc/VideoPeer.ts | 2 - 6 files changed, 3 insertions(+), 114 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 9cb70020..050c3e06 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -34,10 +34,8 @@ import {SimplePeer} from "../../WebRtc/SimplePeer"; import {ReconnectingSceneName} from "../Reconnecting/ReconnectingScene"; import {lazyLoadPlayerCharacterTextures, loadCustomTexture} from "../Entity/PlayerTexturesLoadingManager"; import { - CenterListener, JITSI_MESSAGE_PROPERTIES, layoutManager, - LayoutMode, ON_ACTION_TRIGGER_BUTTON, TRIGGER_JITSI_PROPERTIES, TRIGGER_WEBSITE_PROPERTIES, @@ -135,7 +133,7 @@ interface DeleteGroupEventInterface { const defaultStartLayerName = 'start'; -export class GameScene extends DirtyScene /*implements CenterListener*/ { +export class GameScene extends DirtyScene { Terrains : Array; CurrentPlayer!: Player; MapPlayers!: Phaser.Physics.Arcade.Group; @@ -1117,7 +1115,6 @@ ${escapedMessage} initCamera() { this.cameras.main.setBounds(0,0, this.Map.widthInPixels, this.Map.heightInPixels); this.cameras.main.startFollow(this.CurrentPlayer, true); - //this.updateCameraOffset(); biggestAvailableArrayStore.recompute(); } @@ -1498,7 +1495,6 @@ ${escapedMessage} this.openChatIcon.setY(this.game.renderer.height - 2); // Recompute camera offset if needed - //this.updateCameraOffset(); biggestAvailableArrayStore.recompute(); } @@ -1516,10 +1512,6 @@ ${escapedMessage} this.cameras.main.setFollowOffset((xCenter - game.offsetWidth/2) * window.devicePixelRatio / this.scale.zoom , (yCenter - game.offsetHeight/2) * window.devicePixelRatio / this.scale.zoom); } - /*public onCenterChange(): void { - this.updateCameraOffset(); - }*/ - public startJitsi(roomName: string, jwt?: string): void { const allProps = this.gameMap.getCurrentProperties(); const jitsiConfig = this.safeParseJSONstring(allProps.get("jitsiConfig") as string|undefined, 'jitsiConfig'); @@ -1579,7 +1571,6 @@ ${escapedMessage} zoomByFactor(zoomFactor: number) { waScaleManager.zoomModifier *= zoomFactor; - //this.updateCameraOffset(); biggestAvailableArrayStore.recompute(); } } diff --git a/front/src/WebRtc/LayoutManager.ts b/front/src/WebRtc/LayoutManager.ts index 5275a030..da295a98 100644 --- a/front/src/WebRtc/LayoutManager.ts +++ b/front/src/WebRtc/LayoutManager.ts @@ -15,14 +15,6 @@ export enum DivImportance { Normal = "Normal", } -/** - * Classes implementing this interface can be notified when the center of the screen (the player position) should be - * changed. - */ -export interface CenterListener { - onCenterChange(): void; -} - export const ON_ACTION_TRIGGER_BUTTON = 'onaction'; export const TRIGGER_WEBSITE_PROPERTIES = 'openWebsiteTrigger'; diff --git a/front/src/WebRtc/MediaManager.ts b/front/src/WebRtc/MediaManager.ts index 56afd4ab..06eec099 100644 --- a/front/src/WebRtc/MediaManager.ts +++ b/front/src/WebRtc/MediaManager.ts @@ -31,21 +31,8 @@ export class MediaManager { private userInputManager?: UserInputManager; - //FIX ME SOUNDMETER: check stalability of sound meter calculation - /*private mySoundMeter?: SoundMeter|null; - private soundMeters: Map = new Map(); - private soundMeterElements: Map = new Map();*/ - constructor() { - this.pingCameraStatus(); - - //FIX ME SOUNDMETER: check stability of sound meter calculation - /*this.mySoundMeterElement = (HtmlUtils.getElementByIdOrFail('mySoundMeter')); - this.mySoundMeterElement.childNodes.forEach((value: ChildNode, index) => { - this.mySoundMeterElement.children.item(index)?.classList.remove('active'); - });*/ - //Check of ask notification navigator permission this.getNotification(); @@ -59,7 +46,6 @@ export class MediaManager { } }); - //let isScreenSharing = false; screenSharingLocalStreamStore.subscribe((result) => { if (result.type === 'error') { console.error(result.error); @@ -150,22 +136,6 @@ export class MediaManager { show ? blockLogoElement.classList.add('active') : blockLogoElement.classList.remove('active'); } - isConnecting(userId: string): void { - const connectingSpinnerDiv = this.getSpinner(userId); - if (connectingSpinnerDiv === null) { - return; - } - connectingSpinnerDiv.style.display = 'block'; - } - - isConnected(userId: string): void { - const connectingSpinnerDiv = this.getSpinner(userId); - if (connectingSpinnerDiv === null) { - return; - } - connectingSpinnerDiv.style.display = 'none'; - } - isError(userId: string): void { console.info("isError", `div-${userId}`); const element = document.getElementById(`div-${userId}`); @@ -188,23 +158,8 @@ export class MediaManager { if(!element){ return null; } - const connnectingSpinnerDiv = element.getElementsByClassName('connecting-spinner').item(0) as HTMLDivElement|null; - return connnectingSpinnerDiv; - } - - private getColorByString(str: String) : String|null { - let hash = 0; - if (str.length === 0) return null; - for (let i = 0; i < str.length; i++) { - hash = str.charCodeAt(i) + ((hash << 5) - hash); - hash = hash & hash; - } - let color = '#'; - for (let i = 0; i < 3; i++) { - const value = (hash >> (i * 8)) & 255; - color += ('00' + value.toString(16)).substr(-2); - } - return color; + const connectingSpinnerDiv = element.getElementsByClassName('connecting-spinner').item(0) as HTMLDivElement|null; + return connectingSpinnerDiv; } public addTriggerCloseJitsiFrameButton(id: String, Function: Function){ @@ -220,16 +175,6 @@ export class MediaManager { callback(); } } - /** - * For some reasons, the microphone muted icon or the stream is not always up to date. - * Here, every 30 seconds, we are "reseting" the streams and sending again the constraints to the other peers via the data channel again (see SimplePeer::pushVideoToRemoteUser) - **/ - private pingCameraStatus(){ - /*setInterval(() => { - console.log('ping camera status'); - this.triggerUpdatedLocalStreamCallbacks(this.localStream); - }, 30000);*/ - } public addNewMessage(name: string, message: string, isMe: boolean = false){ discussionManager.addMessage(name, message, isMe); @@ -244,10 +189,6 @@ export class MediaManager { discussionManager.onSendMessageCallback(userId, callback); } - get activatedDiscussion(){ - return discussionManager.activatedDiscussion; - } - public setUserInputManager(userInputManager : UserInputManager){ this.userInputManager = userInputManager; discussionManager.setUserInputManager(userInputManager); diff --git a/front/src/WebRtc/ScreenSharingPeer.ts b/front/src/WebRtc/ScreenSharingPeer.ts index 4f5ceaeb..3a87429b 100644 --- a/front/src/WebRtc/ScreenSharingPeer.ts +++ b/front/src/WebRtc/ScreenSharingPeer.ts @@ -108,28 +108,13 @@ export class ScreenSharingPeer extends Peer { this.destroy(); }); - /*this.on('data', (chunk: Buffer) => { - // We unfortunately need to rely on an event to let the other party know a stream has stopped. - // It seems there is no native way to detect that. - // TODO: we might rely on the "ended" event: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/ended_event - const message = JSON.parse(chunk.toString('utf8')); - if (message.streamEnded !== true) { - console.error('Unexpected message on screen sharing peer connection'); - return; - } - mediaManager.removeActiveScreenSharingVideo("" + this.userId); - });*/ - // eslint-disable-next-line @typescript-eslint/no-explicit-any this.on('error', (err: any) => { console.error(`screen sharing error => ${this.userId} => ${err.code}`, err); - //mediaManager.isErrorScreenSharing(this.userId); }); this.on('connect', () => { this._connected = true; - // FIXME: we need to put the loader on the screen sharing connection - mediaManager.isConnected("" + this.userId); console.info(`connect => ${this.userId}`); }); @@ -143,7 +128,6 @@ export class ScreenSharingPeer extends Peer { } private sendWebrtcScreenSharingSignal(data: unknown) { - //console.log("sendWebrtcScreenSharingSignal", data); try { this.connection.sendWebrtcScreenSharingSignal(data, this.userId); }catch (e) { @@ -155,13 +139,9 @@ export class ScreenSharingPeer extends Peer { * Sends received stream to screen. */ private stream(stream?: MediaStream) { - //console.log(`ScreenSharingPeer::stream => ${this.userId}`, stream); - //console.log(`stream => ${this.userId} => `, stream); if(!stream){ - //mediaManager.removeActiveScreenSharingVideo("" + this.userId); this.isReceivingStream = false; } else { - //mediaManager.addStreamRemoteScreenSharing("" + this.userId, stream); this.isReceivingStream = true; } } @@ -176,7 +156,6 @@ export class ScreenSharingPeer extends Peer { if(!this.toClose){ return; } - //mediaManager.removeActiveScreenSharingVideo("" + this.userId); // FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray" // I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel. //console.log('Closing connection with '+userId); diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index 2d068b41..68400176 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -6,19 +6,14 @@ import { mediaManager, StartScreenSharingCallback, StopScreenSharingCallback, - UpdatedLocalStreamCallback } from "./MediaManager"; import {ScreenSharingPeer} from "./ScreenSharingPeer"; import {MESSAGE_TYPE_BLOCKED, MESSAGE_TYPE_CONSTRAINT, MESSAGE_TYPE_MESSAGE, VideoPeer} from "./VideoPeer"; import type {RoomConnection} from "../Connexion/RoomConnection"; -import {connectionManager} from "../Connexion/ConnectionManager"; -import {GameConnexionTypes} from "../Url/UrlManager"; import {blackListManager} from "./BlackListManager"; import {get} from "svelte/store"; import {localStreamStore, LocalStreamStoreValue, obtainedMediaConstraintStore} from "../Stores/MediaStore"; import {screenSharingLocalStreamStore} from "../Stores/ScreenSharingStore"; -import {DivImportance, layoutManager} from "./LayoutManager"; -import {HtmlUtils} from "./HtmlUtils"; import {discussionManager} from "./DiscussionManager"; export interface UserSimplePeerInterface{ @@ -127,7 +122,6 @@ export class SimplePeer { // This would be symmetrical to the way we handle disconnection. //start connection - //console.log('receiveWebrtcStart. Initiator: ', user.initiator) if(!user.initiator){ return; } @@ -230,12 +224,6 @@ export class SimplePeer { return null; } - // We should display the screen sharing ONLY if we are not initiator -/* if (!user.initiator) { - mediaManager.removeActiveScreenSharingVideo("" + user.userId); - mediaManager.addScreenSharingActiveVideo("" + user.userId); - }*/ - // Enrich the user with last known credentials (if they are not set in the user object, which happens when a user triggers the screen sharing) if (user.webRtcUser === undefined) { user.webRtcUser = this.lastWebrtcUserName; diff --git a/front/src/WebRtc/VideoPeer.ts b/front/src/WebRtc/VideoPeer.ts index 805b7fb4..12d6143b 100644 --- a/front/src/WebRtc/VideoPeer.ts +++ b/front/src/WebRtc/VideoPeer.ts @@ -135,8 +135,6 @@ export class VideoPeer extends Peer { this.on('connect', () => { this._connected = true; - mediaManager.isConnected("" + this.userId); - console.info(`connect => ${this.userId}`); }); this.on('data', (chunk: Buffer) => {