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