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
byte[] connectionData = Encoding.ASCII.GetBytes(room.Port.ToString());
byte[] connectionData = Encoding.ASCII.GetBytes(nextPort.ToString());
serverSocket.Send(connectionData, connectionData.Length, remoteEndPoint);
rooms[data.Data.playerId] = room;
@ -111,14 +111,15 @@ public class PongServer
// Assign a unique port to the client
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());
// 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);
room.PropertyChanged += room.OnReadyChanged;

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

Loading…
Cancel
Save