Revert "Envoi et recvoir ok"
continuous-integration/drone/push Build is passing Details

This reverts commit 44ad57f422.
ServerDeployement
Hugo LIVET 2 years ago
parent 2ab7726853
commit fc7c1c217b

@ -97,7 +97,7 @@ public class PongServer
// Send port message to client // Send port message to client
byte[] connectionData = Encoding.ASCII.GetBytes(room.Port.ToString()); byte[] connectionData = Encoding.ASCII.GetBytes(nextPort.ToString());
serverSocket.Send(connectionData, connectionData.Length, remoteEndPoint); serverSocket.Send(connectionData, connectionData.Length, remoteEndPoint);
rooms[data.Data.playerId] = room; rooms[data.Data.playerId] = room;
@ -110,15 +110,16 @@ public class PongServer
// Assign a unique port to the client // Assign a unique port to the client
IPEndPoint clientEndPoint = new IPEndPoint(IPAddress.Any, room.Port); IPEndPoint clientEndPoint = new IPEndPoint(IPAddress.Any, nextPort);
UdpClient clientSocket = new UdpClient(clientEndPoint);
room.playerJoin = new KeyValuePair<Player, UdpClient>(data.Data, room.playerHost.Value); room.playerJoin = new KeyValuePair<Player, UdpClient>(data.Data, clientSocket);
Console.WriteLine("New connection Client from " + remoteEndPoint.ToString()); Console.WriteLine("New connection Client from " + remoteEndPoint.ToString());
// Send port message to client // Send port message to client
byte[] connectionData = Encoding.ASCII.GetBytes(room.Port.ToString()); byte[] connectionData = Encoding.ASCII.GetBytes(nextPort.ToString());
serverSocket.Send(connectionData, connectionData.Length, remoteEndPoint); serverSocket.Send(connectionData, connectionData.Length, remoteEndPoint);
room.PropertyChanged += room.OnReadyChanged; room.PropertyChanged += room.OnReadyChanged;

@ -82,18 +82,13 @@ namespace Server
if (maxPlayer == 2) if (maxPlayer == 2)
{ {
//IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0); IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 3133);
//byte[] receivedData = serverSocket.Receive(ref remoteEndPoint);
IPEndPoint remoteEndPointHost = new IPEndPoint(IPAddress.Any, 0); byte[] receivedDataHost = playerHost.Value.Receive(ref remoteEndPoint);
IPEndPoint remoteEndPointJoin = new IPEndPoint(IPAddress.Any, 0); byte[] receivedDataJoin = playerJoin.Value.Receive(ref remoteEndPoint);
playerJoin.Value.Send(receivedDataHost, receivedDataHost.Length, remoteEndPoint);
byte[] receivedDataHost = playerHost.Value.Receive(ref remoteEndPointHost); playerHost.Value.Send(receivedDataJoin, receivedDataJoin.Length, remoteEndPoint);
byte[] receivedDataJoin = playerJoin.Value.Receive(ref remoteEndPointJoin);
Console.WriteLine("blabla");
playerJoin.Value.Send(receivedDataHost, receivedDataHost.Length, remoteEndPointJoin);
playerHost.Value.Send(receivedDataJoin, receivedDataJoin.Length, remoteEndPointHost);
Thread receiveThread1 = new Thread(() => ReceiveMessages(playerHost.Value, playerJoin.Value)); Thread receiveThread1 = new Thread(() => ReceiveMessages(playerHost.Value, playerJoin.Value));

Loading…
Cancel
Save