Refactor message
This commit is contained in:
parent
ba9f9dcbe1
commit
7059c6e6e3
3 changed files with 15 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue