This commit is contained in:
Killian Marty 2023-12-06 09:35:51 +01:00
parent ffde38b144
commit 24b6ba9298

View file

@ -72,7 +72,6 @@ function createNewPlayer(socket, name){
players.push(obj);
playerCount++;
console.log(players);
socket.send(JSON.stringify({
type: "connect",
data: {
@ -103,6 +102,11 @@ wss.on('connection', (socket, req) => {
if (message.type == "ping") {
socket.send("pong");
} else if(message.type=="update") {
players.forEach((player)=>{
if(player.id==message.data.id){
player = message.data;
}
})
broadcast(JSON.stringify(message), socket.id);
}
});