Add banned message and close ws

This commit is contained in:
Gregoire Parant 2020-10-20 08:30:11 +02:00
parent 7059c6e6e3
commit eb1f62bb1c

View File

@ -77,16 +77,17 @@ export class IoSocketController {
JSON.parse(new TextDecoder("utf-8").decode(new Uint8Array(arrayBuffer))); JSON.parse(new TextDecoder("utf-8").decode(new Uint8Array(arrayBuffer)));
if(message.event === 'user-message') { if(message.event === 'user-message') {
if (message.message.type === 'ban') { const messageToEmit = (message.message as { message: string, type: string, userUuid: string });
const messageToEmit = (message.message as {message: string, type: string, userUuid: string}); switch (message.message.type) {
socketManager.emitSendUserMessage(messageToEmit); case 'ban':
} socketManager.emitSendUserMessage(messageToEmit);
if (message.message.type === 'banned') { break;
const messageToEmit = (message.message as {message: string, type: string, userUuid: string}); case 'banned':
const socketUser = socketManager.emitSendUserMessage(messageToEmit); const socketUser = socketManager.emitSendUserMessage(messageToEmit);
setTimeout(() => { setTimeout(() => {
socketUser.close(); socketUser.close();
}, 10000); }, 10000);
break;
} }
} }
}catch (err) { }catch (err) {