From 8de05c39c126bcbe3bc0b01db33aa5e094b82946 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 25 Jan 2021 14:10:16 +0100 Subject: [PATCH 1/3] Lock user when he was banned --- front/src/Administration/UserMessageManager.ts | 18 +++++++++++++++++- front/src/Phaser/Game/GameScene.ts | 6 ++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/front/src/Administration/UserMessageManager.ts b/front/src/Administration/UserMessageManager.ts index 12022b03..a20b4729 100644 --- a/front/src/Administration/UserMessageManager.ts +++ b/front/src/Administration/UserMessageManager.ts @@ -1,5 +1,8 @@ import {RoomConnection} from "../Connexion/RoomConnection"; import * as TypeMessages from "./TypeMessage"; +import List = Phaser.Structs.List; +import {UpdatedLocalStreamCallback} from "../WebRtc/MediaManager"; +import {Banned} from "./TypeMessage"; export interface TypeMessageInterface { showMessage(message: string): void; @@ -8,6 +11,7 @@ export interface TypeMessageInterface { export class UserMessageManager { typeMessages: Map = new Map(); + receiveBannedMessageListener: Set = new Set(); constructor(private Connection: RoomConnection) { const valueTypeMessageTab = Object.values(TypeMessages); @@ -21,7 +25,14 @@ export class UserMessageManager { initialise() { //receive signal to show message this.Connection.receiveUserMessage((type: string, message: string) => { - this.showMessage(type, message); + const typeMessage = this.showMessage(type, message); + + //listener on banned receive message + if(typeMessage instanceof Banned) { + for (const callback of this.receiveBannedMessageListener) { + callback(); + } + } }); } @@ -32,5 +43,10 @@ export class UserMessageManager { return; } classTypeMessage.showMessage(message); + return classTypeMessage; + } + + setReceiveBanListener(callback: Function){ + this.receiveBannedMessageListener.add(callback); } } \ No newline at end of file diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index d5460420..bfe5cd55 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -524,6 +524,7 @@ export class GameScene extends ResizableScene implements CenterListener { this.simplePeer = new SimplePeer(this.connection, !this.room.isPublic, this.playerName); this.GlobalMessageManager = new GlobalMessageManager(this.connection); this.UserMessageManager = new UserMessageManager(this.connection); + this.UserMessageManager.setReceiveBanListener(this.lockUser.bind(this)); const self = this; this.simplePeer.registerPeerConnectionListener({ @@ -1235,5 +1236,10 @@ export class GameScene extends ResizableScene implements CenterListener { mediaManager.removeTriggerCloseJitsiFrameButton('close-jisi'); } + private lockUser(){ + this.stopJitsi(); + coWebsiteManager.closeCoWebsite(); + this.userInputManager.clearAllInputKeyboard(); + } } From c6903cc4c5f5622504c55bf6e5a5044829d2aa7b Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Tue, 26 Jan 2021 08:57:10 +0100 Subject: [PATCH 2/3] Use Error scene and add banned message --- front/src/Phaser/Game/GameScene.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index bfe5cd55..d1aa3fbb 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -524,7 +524,7 @@ export class GameScene extends ResizableScene implements CenterListener { this.simplePeer = new SimplePeer(this.connection, !this.room.isPublic, this.playerName); this.GlobalMessageManager = new GlobalMessageManager(this.connection); this.UserMessageManager = new UserMessageManager(this.connection); - this.UserMessageManager.setReceiveBanListener(this.lockUser.bind(this)); + this.UserMessageManager.setReceiveBanListener(this.bannedUser.bind(this)); const self = this; this.simplePeer.registerPeerConnectionListener({ @@ -1236,7 +1236,12 @@ export class GameScene extends ResizableScene implements CenterListener { mediaManager.removeTriggerCloseJitsiFrameButton('close-jisi'); } - private lockUser(){ + private bannedUser(){ + this.scene.start(ErrorSceneName, { + title: 'Banned', + subTitle: 'You was banned of WorkAdventure', + message: 'If you want more information, you can contact us: workadventure@thecodingmachine.com' + }); this.stopJitsi(); coWebsiteManager.closeCoWebsite(); this.userInputManager.clearAllInputKeyboard(); From 1dd28584240ba847a7348bb4f18493b6db401afe Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Tue, 26 Jan 2021 14:04:42 +0100 Subject: [PATCH 3/3] Fix feadback @Kharhamel --- front/src/Phaser/Game/GameScene.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index d1aa3fbb..8e089de7 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -1237,14 +1237,13 @@ export class GameScene extends ResizableScene implements CenterListener { } private bannedUser(){ + this.cleanupClosingScene(); + this.userInputManager.clearAllInputKeyboard(); this.scene.start(ErrorSceneName, { title: 'Banned', subTitle: 'You was banned of WorkAdventure', message: 'If you want more information, you can contact us: workadventure@thecodingmachine.com' }); - this.stopJitsi(); - coWebsiteManager.closeCoWebsite(); - this.userInputManager.clearAllInputKeyboard(); } }