Lock user when he was banned

This commit is contained in:
Gregoire Parant 2021-01-25 14:10:16 +01:00
parent 18fb508828
commit 8de05c39c1
2 changed files with 23 additions and 1 deletions

View File

@ -1,5 +1,8 @@
import {RoomConnection} from "../Connexion/RoomConnection"; import {RoomConnection} from "../Connexion/RoomConnection";
import * as TypeMessages from "./TypeMessage"; import * as TypeMessages from "./TypeMessage";
import List = Phaser.Structs.List;
import {UpdatedLocalStreamCallback} from "../WebRtc/MediaManager";
import {Banned} from "./TypeMessage";
export interface TypeMessageInterface { export interface TypeMessageInterface {
showMessage(message: string): void; showMessage(message: string): void;
@ -8,6 +11,7 @@ export interface TypeMessageInterface {
export class UserMessageManager { export class UserMessageManager {
typeMessages: Map<string, TypeMessageInterface> = new Map<string, TypeMessageInterface>(); typeMessages: Map<string, TypeMessageInterface> = new Map<string, TypeMessageInterface>();
receiveBannedMessageListener: Set<Function> = new Set<UpdatedLocalStreamCallback>();
constructor(private Connection: RoomConnection) { constructor(private Connection: RoomConnection) {
const valueTypeMessageTab = Object.values(TypeMessages); const valueTypeMessageTab = Object.values(TypeMessages);
@ -21,7 +25,14 @@ export class UserMessageManager {
initialise() { initialise() {
//receive signal to show message //receive signal to show message
this.Connection.receiveUserMessage((type: string, message: string) => { 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; return;
} }
classTypeMessage.showMessage(message); classTypeMessage.showMessage(message);
return classTypeMessage;
}
setReceiveBanListener(callback: Function){
this.receiveBannedMessageListener.add(callback);
} }
} }

View File

@ -524,6 +524,7 @@ export class GameScene extends ResizableScene implements CenterListener {
this.simplePeer = new SimplePeer(this.connection, !this.room.isPublic, this.playerName); this.simplePeer = new SimplePeer(this.connection, !this.room.isPublic, this.playerName);
this.GlobalMessageManager = new GlobalMessageManager(this.connection); this.GlobalMessageManager = new GlobalMessageManager(this.connection);
this.UserMessageManager = new UserMessageManager(this.connection); this.UserMessageManager = new UserMessageManager(this.connection);
this.UserMessageManager.setReceiveBanListener(this.lockUser.bind(this));
const self = this; const self = this;
this.simplePeer.registerPeerConnectionListener({ this.simplePeer.registerPeerConnectionListener({
@ -1235,5 +1236,10 @@ export class GameScene extends ResizableScene implements CenterListener {
mediaManager.removeTriggerCloseJitsiFrameButton('close-jisi'); mediaManager.removeTriggerCloseJitsiFrameButton('close-jisi');
} }
private lockUser(){
this.stopJitsi();
coWebsiteManager.closeCoWebsite();
this.userInputManager.clearAllInputKeyboard();
}
} }