|
|
@ -84,7 +84,7 @@ public class PongServer
|
|
|
|
UdpClient clientSocket = new UdpClient(clientEndPoint);
|
|
|
|
UdpClient clientSocket = new UdpClient(clientEndPoint);
|
|
|
|
|
|
|
|
|
|
|
|
room.playerHost = new KeyValuePair<Player,UdpClient>(data.Data,clientSocket);
|
|
|
|
room.playerHost = new KeyValuePair<Player,UdpClient>(data.Data,clientSocket);
|
|
|
|
room.nbPlayer++;
|
|
|
|
room.NbPlayer++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -94,9 +94,9 @@ public class PongServer
|
|
|
|
room.Port = nextPort;
|
|
|
|
room.Port = nextPort;
|
|
|
|
nextPort++;
|
|
|
|
nextPort++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send connection message to client
|
|
|
|
|
|
|
|
|
|
|
|
// Send port message to client
|
|
|
|
byte[] connectionData = Encoding.ASCII.GetBytes(nextPort.ToString());
|
|
|
|
byte[] connectionData = Encoding.ASCII.GetBytes(nextPort.ToString());
|
|
|
|
serverSocket.Send(connectionData, connectionData.Length, remoteEndPoint);
|
|
|
|
serverSocket.Send(connectionData, connectionData.Length, remoteEndPoint);
|
|
|
|
|
|
|
|
|
|
|
@ -114,14 +114,17 @@ public class PongServer
|
|
|
|
UdpClient clientSocket = new UdpClient(clientEndPoint);
|
|
|
|
UdpClient clientSocket = new UdpClient(clientEndPoint);
|
|
|
|
|
|
|
|
|
|
|
|
room.playerJoin = new KeyValuePair<Player, UdpClient>(data.Data, clientSocket);
|
|
|
|
room.playerJoin = new KeyValuePair<Player, UdpClient>(data.Data, clientSocket);
|
|
|
|
room.nbPlayer++;
|
|
|
|
room.NbPlayer++;
|
|
|
|
|
|
|
|
|
|
|
|
room.PropertyChanged += room.OnReadyChanged;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("New connection Client from " + remoteEndPoint.ToString());
|
|
|
|
Console.WriteLine("New connection Client from " + remoteEndPoint.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
room.Port = nextPort;
|
|
|
|
// Send port message to client
|
|
|
|
nextPort++;
|
|
|
|
byte[] connectionData = Encoding.ASCII.GetBytes(nextPort.ToString());
|
|
|
|
|
|
|
|
serverSocket.Send(connectionData, connectionData.Length, remoteEndPoint);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
room.PropertyChanged += room.OnReadyChanged;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|