diff --git a/code/server/Server/PongServer.cs b/code/server/Server/PongServer.cs index 7b055ad..2b8cbc8 100644 --- a/code/server/Server/PongServer.cs +++ b/code/server/Server/PongServer.cs @@ -58,6 +58,7 @@ public class PongServer if (data.Informations.Action == Shared.DTO.Action.Connect) // Join = rejoindre un room , et Host ça va juste créer un room { var choisenRoom = rooms.FirstOrDefault(room => room.Value.Availaible); + Console.WriteLine("Connection " + choisenRoom.Key); if (choisenRoom.Value != default ) { Join(data, remoteEndPoint, serverSocket, choisenRoom.Value); @@ -85,20 +86,23 @@ public class PongServer room.playerHost = new KeyValuePair(data.Data,clientSocket); room.nbPlayer++; - room.PropertyChanged += room.OnReadyChanged; + Console.WriteLine("New connection Host From " + remoteEndPoint.ToString()); room.Port = nextPort; nextPort++; + - clients[remoteEndPoint] = clientSocket; - // Send connection message to client - byte[] connectionData = Encoding.ASCII.GetBytes(room.Id); + // Send connection message to client + byte[] connectionData = Encoding.ASCII.GetBytes(nextPort.ToString()); serverSocket.Send(connectionData, connectionData.Length, remoteEndPoint); + rooms[data.Data.playerId] = room; + room.PropertyChanged += room.OnReadyChanged; + } private void Join(ObjectTransfert data, IPEndPoint remoteEndPoint, UdpClient serverSocket, Room room)