srv
This commit is contained in:
parent
ffde38b144
commit
24b6ba9298
1 changed files with 5 additions and 1 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue