From f92b728a8e0e2c8df45f04e3c103a36baaa4a810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 13 Sep 2021 14:48:19 +0200 Subject: [PATCH 1/2] Fixing broken chat API --- front/src/Api/IframeListener.ts | 14 +------------- front/src/Api/ScriptUtils.ts | 8 ++++++++ front/src/WebRtc/DiscussionManager.ts | 14 -------------- front/src/WebRtc/VideoPeer.ts | 6 +----- 4 files changed, 10 insertions(+), 32 deletions(-) delete mode 100644 front/src/WebRtc/DiscussionManager.ts diff --git a/front/src/Api/IframeListener.ts b/front/src/Api/IframeListener.ts index 140d2f34..5a9aca85 100644 --- a/front/src/Api/IframeListener.ts +++ b/front/src/Api/IframeListener.ts @@ -46,30 +46,18 @@ type AnswererCallback = ( * Also allows to send messages to those iframes. */ class IframeListener { - private readonly _readyStream: Subject = new Subject(); - public readonly readyStream = this._readyStream.asObservable(); - - private readonly _chatStream: Subject = new Subject(); - public readonly chatStream = this._chatStream.asObservable(); - private readonly _openPopupStream: Subject = new Subject(); public readonly openPopupStream = this._openPopupStream.asObservable(); private readonly _openTabStream: Subject = new Subject(); public readonly openTabStream = this._openTabStream.asObservable(); - private readonly _goToPageStream: Subject = new Subject(); - public readonly goToPageStream = this._goToPageStream.asObservable(); - private readonly _loadPageStream: Subject = new Subject(); public readonly loadPageStream = this._loadPageStream.asObservable(); private readonly _openCoWebSiteStream: Subject = new Subject(); public readonly openCoWebSiteStream = this._openCoWebSiteStream.asObservable(); - private readonly _closeCoWebSiteStream: Subject = new Subject(); - public readonly closeCoWebSiteStream = this._closeCoWebSiteStream.asObservable(); - private readonly _disablePlayerControlStream: Subject = new Subject(); public readonly disablePlayerControlStream = this._disablePlayerControlStream.asObservable(); @@ -219,7 +207,7 @@ class IframeListener { } else if (payload.type === "setProperty" && isSetPropertyEvent(payload.data)) { this._setPropertyStream.next(payload.data); } else if (payload.type === "chat" && isChatEvent(payload.data)) { - this._chatStream.next(payload.data); + scriptUtils.sendAnonymousChat(payload.data); } else if (payload.type === "openPopup" && isOpenPopupEvent(payload.data)) { this._openPopupStream.next(payload.data); } else if (payload.type === "closePopup" && isClosePopupEvent(payload.data)) { diff --git a/front/src/Api/ScriptUtils.ts b/front/src/Api/ScriptUtils.ts index 0dbe40fe..ad6dcc0f 100644 --- a/front/src/Api/ScriptUtils.ts +++ b/front/src/Api/ScriptUtils.ts @@ -1,4 +1,7 @@ import { coWebsiteManager } from "../WebRtc/CoWebsiteManager"; +import { playersStore } from "../Stores/PlayersStore"; +import { chatMessagesStore } from "../Stores/ChatStore"; +import type { ChatEvent } from "./Events/ChatEvent"; class ScriptUtils { public openTab(url: string) { @@ -16,6 +19,11 @@ class ScriptUtils { public closeCoWebSite() { coWebsiteManager.closeCoWebsite(); } + + public sendAnonymousChat(chatEvent: ChatEvent) { + const userId = playersStore.addFacticePlayer(chatEvent.author); + chatMessagesStore.addExternalMessage(userId, chatEvent.message); + } } export const scriptUtils = new ScriptUtils(); diff --git a/front/src/WebRtc/DiscussionManager.ts b/front/src/WebRtc/DiscussionManager.ts deleted file mode 100644 index fcf04ef1..00000000 --- a/front/src/WebRtc/DiscussionManager.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { iframeListener } from "../Api/IframeListener"; -import { chatMessagesStore } from "../Stores/ChatStore"; -import { playersStore } from "../Stores/PlayersStore"; - -export class DiscussionManager { - constructor() { - iframeListener.chatStream.subscribe((chatEvent) => { - const userId = playersStore.addFacticePlayer(chatEvent.author); - chatMessagesStore.addExternalMessage(userId, chatEvent.message); - }); - } -} - -export const discussionManager = new DiscussionManager(); diff --git a/front/src/WebRtc/VideoPeer.ts b/front/src/WebRtc/VideoPeer.ts index 990adb4e..c3a2af23 100644 --- a/front/src/WebRtc/VideoPeer.ts +++ b/front/src/WebRtc/VideoPeer.ts @@ -5,11 +5,7 @@ import { blackListManager } from "./BlackListManager"; import type { Subscription } from "rxjs"; import type { UserSimplePeerInterface } from "./SimplePeer"; import { readable, Readable, Unsubscriber } from "svelte/store"; -import { - localStreamStore, - obtainedMediaConstraintStore, - ObtainedMediaStreamConstraints, -} from "../Stores/MediaStore"; +import { localStreamStore, obtainedMediaConstraintStore, ObtainedMediaStreamConstraints } from "../Stores/MediaStore"; import { playersStore } from "../Stores/PlayersStore"; import { chatMessagesStore, newChatMessageStore } from "../Stores/ChatStore"; import { getIceServersConfig } from "../Components/Video/utils"; From 01bd36ca3f67faddd46849190ee38825d6de9261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 13 Sep 2021 18:58:00 +0200 Subject: [PATCH 2/2] Removing test in double --- maps/tests/index.html | 8 -------- 1 file changed, 8 deletions(-) diff --git a/maps/tests/index.html b/maps/tests/index.html index 6f298386..29d4f0bb 100644 --- a/maps/tests/index.html +++ b/maps/tests/index.html @@ -224,14 +224,6 @@

WebRTC

- - - -
- Success Failure Pending - - Test energy consumption -
Success Failure Pending