🐛 modifications
continuous-integration/drone/push Build is passing Details

ServerDeployement
Bruno DA COSTA CUNHA 2 years ago
parent f87243c262
commit 2f4a18c494

@ -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 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); var choisenRoom = rooms.FirstOrDefault(room => room.Value.Availaible);
Console.WriteLine("Connection " + choisenRoom.Key);
if (choisenRoom.Value != default ) if (choisenRoom.Value != default )
{ {
Join(data, remoteEndPoint, serverSocket, choisenRoom.Value); Join(data, remoteEndPoint, serverSocket, choisenRoom.Value);
@ -85,20 +86,23 @@ public class PongServer
room.playerHost = new KeyValuePair<Player,UdpClient>(data.Data,clientSocket); room.playerHost = new KeyValuePair<Player,UdpClient>(data.Data,clientSocket);
room.nbPlayer++; room.nbPlayer++;
room.PropertyChanged += room.OnReadyChanged;
Console.WriteLine("New connection Host From " + remoteEndPoint.ToString()); Console.WriteLine("New connection Host From " + remoteEndPoint.ToString());
room.Port = nextPort; room.Port = nextPort;
nextPort++; nextPort++;
clients[remoteEndPoint] = clientSocket;
// Send connection message to client // Send connection message to client
byte[] connectionData = Encoding.ASCII.GetBytes(room.Id); byte[] connectionData = Encoding.ASCII.GetBytes(nextPort.ToString());
serverSocket.Send(connectionData, connectionData.Length, remoteEndPoint); serverSocket.Send(connectionData, connectionData.Length, remoteEndPoint);
rooms[data.Data.playerId] = room;
room.PropertyChanged += room.OnReadyChanged;
} }
private void Join(ObjectTransfert<Player> data, IPEndPoint remoteEndPoint, UdpClient serverSocket, Room room) private void Join(ObjectTransfert<Player> data, IPEndPoint remoteEndPoint, UdpClient serverSocket, Room room)

Loading…
Cancel
Save