From dfd594ec172810cdd6c7194369ae2b972c66d674 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Fri, 28 Jan 2022 18:33:42 +0100 Subject: [PATCH] Fix screen sharing spinner Check if the peer connection is already connected status. In this case, the status store must be set to 'connected'. In the case or player A send stream and player B send a stream, it's same peer connection, also the status must be changed to connect. Signed-off-by: Gregoire Parant --- front/src/Phaser/Game/GameScene.ts | 1 + front/src/WebRtc/ScreenSharingPeer.ts | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index e24a01a6..23a211a6 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -1605,6 +1605,7 @@ ${escapedMessage} //When we leave game, the camera is stop to be reopen after. // I think that we could keep camera status and the scene can manage camera setup + //TODO find wy chrome don't manage correctly a multiple ask mediaDevices //mediaManager.hideMyCamera(); for (const iframeEvents of this.iframeSubscriptionList) { diff --git a/front/src/WebRtc/ScreenSharingPeer.ts b/front/src/WebRtc/ScreenSharingPeer.ts index 738e2515..292dc35d 100644 --- a/front/src/WebRtc/ScreenSharingPeer.ts +++ b/front/src/WebRtc/ScreenSharingPeer.ts @@ -2,7 +2,7 @@ import type * as SimplePeerNamespace from "simple-peer"; import type { RoomConnection } from "../Connexion/RoomConnection"; import { MESSAGE_TYPE_CONSTRAINT, PeerStatus } from "./VideoPeer"; import type { UserSimplePeerInterface } from "./SimplePeer"; -import { Readable, readable } from "svelte/store"; +import { Readable, readable, writable, Writable } from "svelte/store"; import { getIceServersConfig } from "../Components/Video/utils"; import { highlightedEmbedScreen } from "../Stores/EmbedScreensStore"; import { isMediaBreakpointUp } from "../Utils/BreakpointsUtils"; @@ -22,7 +22,7 @@ export class ScreenSharingPeer extends Peer { public readonly userId: number; public readonly uniqueId: string; public readonly streamStore: Readable; - public readonly statusStore: Readable; + public readonly statusStore: Writable; constructor( user: UserSimplePeerInterface, @@ -70,7 +70,7 @@ export class ScreenSharingPeer extends Peer { }; }); - this.statusStore = readable("connecting", (set) => { + this.statusStore = writable("connecting", (set) => { const onConnect = () => { set("connected"); }; @@ -141,6 +141,11 @@ export class ScreenSharingPeer extends Peer { if (!stream) { this.isReceivingStream = false; } else { + //Check if the peer connection is already in connect status. In this case, the status store must be set to 'connected'. + //In the case or player A send stream and player B send a stream, it's same peer connection, also the status must be changed to connected. + if (this._connected) { + this.statusStore.set("connected"); + } this.isReceivingStream = true; } }