Serv réparer
continuous-integration/drone/push Build is passing Details

ServerDeployement
Hugo LIVET 2 years ago
parent fc7c1c217b
commit babff8b5b0

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

@ -73,8 +73,8 @@ namespace Server
public void OnReadyChanged(object sender, PropertyChangedEventArgs e)
{
Room nbPlayer = sender as Room;
int maxPlayer = nbPlayer.nbPlayer;
Room room = sender as Room;
int maxPlayer = room.nbPlayer;
//IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Any, Port);
//UdpClient serverSocket = new UdpClient(serverEndPoint);
@ -82,13 +82,15 @@ namespace Server
if (maxPlayer == 2)
{
IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 3133);
IPEndPoint remoteEndPointHost = new IPEndPoint(IPAddress.Any, room.Port);
IPEndPoint remoteEndPointJoin = new IPEndPoint(IPAddress.Any, room.Port);
byte[] receivedDataHost = playerHost.Value.Receive(ref remoteEndPoint);
byte[] receivedDataJoin = playerJoin.Value.Receive(ref remoteEndPoint);
playerJoin.Value.Send(receivedDataHost, receivedDataHost.Length, remoteEndPoint);
playerHost.Value.Send(receivedDataJoin, receivedDataJoin.Length, remoteEndPoint);
byte[] receivedDataHost = playerHost.Value.Receive(ref remoteEndPointHost);
byte[] receivedDataJoin = playerJoin.Value.Receive(ref remoteEndPointJoin);
Console.WriteLine("blabla");
playerJoin.Value.Send(receivedDataHost, receivedDataHost.Length, remoteEndPointHost);
playerHost.Value.Send(receivedDataJoin, receivedDataJoin.Length, remoteEndPointJoin);
Thread receiveThread1 = new Thread(() => ReceiveMessages(playerHost.Value, playerJoin.Value));

Loading…
Cancel
Save