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