This commit is contained in:
Killian Marty 2023-12-06 09:40:15 +01:00
parent 24b6ba9298
commit 16e959a05c

View file

@ -93,7 +93,7 @@ wss.on('connection', (socket, req) => {
//create new player, send informations to new player and broadcast new player for all
let username = url.parse(req.url, true).query.name;
if(username===undefined){
username = "joueur"
username = "Soldat Inconnu"
}
createNewPlayer(socket, username);
@ -102,11 +102,12 @@ 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;
for (var i = players.length - 1; i >= 0; i--) {
if(player[i].id == message.data.id){
console.log(id);
players[i]=message.data;
}
})
}
broadcast(JSON.stringify(message), socket.id);
}
});