Compare commits

..

No commits in common. '2ab77268535e3051bc26fa01ef78a41ae4cbaa80' and '087e7863c15974b3007815e6422b215d4f87d79a' have entirely different histories.

@ -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;
@ -111,14 +111,15 @@ 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, room.Port);
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