From 8de05c39c126bcbe3bc0b01db33aa5e094b82946 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 25 Jan 2021 14:10:16 +0100 Subject: [PATCH] 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(); + } }