From 12ef2820bfc73f7d6935d77e1ec67ec090cb01c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 16 Feb 2021 11:08:03 +0100 Subject: [PATCH] Refactoring parameters passed to ScreenSharingPeer --- front/src/WebRtc/ScreenSharingPeer.ts | 10 +++++++--- front/src/WebRtc/SimplePeer.ts | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/front/src/WebRtc/ScreenSharingPeer.ts b/front/src/WebRtc/ScreenSharingPeer.ts index 2491d1e6..1c67e519 100644 --- a/front/src/WebRtc/ScreenSharingPeer.ts +++ b/front/src/WebRtc/ScreenSharingPeer.ts @@ -3,6 +3,7 @@ import {mediaManager} from "./MediaManager"; import {STUN_SERVER, TURN_SERVER, TURN_USER, TURN_PASSWORD} from "../Enum/EnvironmentVariable"; import {RoomConnection} from "../Connexion/RoomConnection"; import {MESSAGE_TYPE_CONSTRAINT} from "./VideoPeer"; +import {UserSimplePeerInterface} from "./SimplePeer"; const Peer: SimplePeerNamespace.SimplePeer = require('simple-peer'); @@ -16,8 +17,9 @@ export class ScreenSharingPeer extends Peer { private isReceivingStream:boolean = false; public toClose: boolean = false; public _connected: boolean = false; + private userId: number; - constructor(private userId: number, initiator: boolean, private connection: RoomConnection, webRtcUser: string | undefined, webRtcPassword: string | undefined) { + constructor(user: UserSimplePeerInterface, initiator: boolean, private connection: RoomConnection) { super({ initiator: initiator ? initiator : false, reconnectTimer: 10000, @@ -28,13 +30,15 @@ export class ScreenSharingPeer extends Peer { }, { urls: TURN_SERVER.split(','), - username: webRtcUser || TURN_USER, - credential: webRtcPassword || TURN_PASSWORD + username: user.webRtcUser || TURN_USER, + credential: user.webRtcPassword || TURN_PASSWORD }, ] } }); + this.userId = user.userId; + //start listen signal for the peer connection this.on('signal', (data: unknown) => { this.sendWebrtcScreenSharingSignal(data); diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index 889d3748..e1486b46 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -191,7 +191,7 @@ export class SimplePeer { mediaManager.addScreenSharingActiveVideo("" + user.userId); } - const peer = new ScreenSharingPeer(user.userId, user.initiator ? user.initiator : false, this.Connection, user.webRtcUser, user.webRtcPassword); + const peer = new ScreenSharingPeer(user, user.initiator ? user.initiator : false, this.Connection); this.PeerScreenSharingConnectionArray.set(user.userId, peer); for (const peerConnectionListener of this.peerConnectionListeners) {