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); | ||||
|   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); | ||||
|     } | ||||
|   }); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue