server cleaning

This commit is contained in:
Killian Marty 2023-12-08 19:16:43 +01:00
parent 4ab6f5da50
commit 1c9a2b9702

View file

@ -136,27 +136,32 @@ wss.on('connection', (socket, req) => {
//handle client's messages
socket.on('message', (message) => {
message = JSON.parse(message);
switch (message.type) {
case 'ping':
socket.send("pong");
break;
try{
message = JSON.parse(message);
switch (message.type) {
case 'ping':
socket.send("pong");
break;
case "update":
update(message, socket);
break;
case "update":
update(message, socket);
break;
case "newBullet":
newBullet(message, socket);
break;
case "newBullet":
newBullet(message, socket);
break;
case "died":
died(message, socket);
break;
case "died":
died(message, socket);
break;
default:
break;
default:
break;
}catch(e){
console.log('error');
}
}
});
//handle disconnecting