server cleaning
This commit is contained in:
parent
4ab6f5da50
commit
1c9a2b9702
1 changed files with 21 additions and 16 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue