Refactor message

This commit is contained in:
Gregoire Parant 2020-10-20 08:20:21 +02:00
parent ba9f9dcbe1
commit 7059c6e6e3
3 changed files with 15 additions and 2 deletions

View File

@ -81,6 +81,13 @@ export class IoSocketController {
const messageToEmit = (message.message as {message: string, type: string, userUuid: string});
socketManager.emitSendUserMessage(messageToEmit);
}
if (message.message.type === 'banned') {
const messageToEmit = (message.message as {message: string, type: string, userUuid: string});
const socketUser = socketManager.emitSendUserMessage(messageToEmit);
setTimeout(() => {
socketUser.close();
}, 10000);
}
}
}catch (err) {
console.error(err);

View File

@ -673,7 +673,7 @@ class SocketManager {
client.send(serverToClientMessage.serializeBinary().buffer, true);
}
public emitSendUserMessage(messageToSend: {userUuid: string, message: string, type: string}): void {
public emitSendUserMessage(messageToSend: {userUuid: string, message: string, type: string}): ExSocketInterface {
const socket = this.searchClientByUuid(messageToSend.userUuid);
if(!socket){
throw 'socket was not found';
@ -689,6 +689,7 @@ class SocketManager {
if (!socket.disconnecting) {
socket.send(serverToClientMessage.serializeBinary().buffer, true);
}
return socket;
}
}

View File

@ -1,7 +1,7 @@
import {TypeMessageInterface} from "./UserMessageManager";
import {HtmlUtils} from "../WebRtc/HtmlUtils";
export class Ban implements TypeMessageInterface {
export class TypeMessageExt implements TypeMessageInterface{
private nbSecond = 0;
private maxNbSecond = 10;
private titleMessage = 'IMPORTANT !';
@ -60,3 +60,8 @@ export class Ban implements TypeMessageInterface {
}
}
}
export class Ban extends TypeMessageExt {
}
export class Banned extends TypeMessageExt {
}