Merge branch 'master' of https://codefirst.iut.uca.fr/git/leap-hit-team/leap-hit-server
continuous-integration/drone/push Build is passing Details

ServerDeployement
Noan07 2 years ago
commit 293c057c19

@ -14,7 +14,7 @@ class Program
static void StartClient()
{
//IPEndPoint serverEndPoint = new IPEndPoint(Dns.GetHostAddresses("hulivet.fr").FirstOrDefault(), 3131);
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 3131);
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse("192.168.205.58"), 3131);
UdpClient client = new UdpClient();
// Send connection message to server

@ -38,7 +38,7 @@ public class PongServer
byte[] receivedData = serverSocket.Receive(ref remoteEndPoint);
string fileJson = Encoding.UTF8.GetString(receivedData);
ObjectTransfert<Player> data = JsonSerializer.Deserialize<ObjectTransfert<Player>>(fileJson);
if (data.Informations.Action == Shared.DTO.Action.Host)
{
Host(data, remoteEndPoint, serverSocket, false);
@ -58,6 +58,7 @@ public class PongServer
if (data.Informations.Action == Shared.DTO.Action.Connect) // Join = rejoindre un room , et Host ça va juste créer un room
{
var choisenRoom = rooms.FirstOrDefault(room => room.Value.Availaible);
Console.WriteLine("Connection " + choisenRoom.Key);
if (choisenRoom.Value != default )
{
Join(data, remoteEndPoint, serverSocket, choisenRoom.Value);
@ -85,20 +86,23 @@ public class PongServer
room.playerHost = new KeyValuePair<Player,UdpClient>(data.Data,clientSocket);
room.nbPlayer++;
room.PropertyChanged += room.OnReadyChanged;
Console.WriteLine("New connection Host From " + remoteEndPoint.ToString());
room.Port = nextPort;
nextPort++;
clients[remoteEndPoint] = clientSocket;
// Send connection message to client
byte[] connectionData = Encoding.ASCII.GetBytes(room.Id);
// Send connection message to client
byte[] connectionData = Encoding.ASCII.GetBytes(nextPort.ToString());
serverSocket.Send(connectionData, connectionData.Length, remoteEndPoint);
rooms[data.Data.playerId] = room;
room.PropertyChanged += room.OnReadyChanged;
}
private void Join(ObjectTransfert<Player> data, IPEndPoint remoteEndPoint, UdpClient serverSocket, Room room)

@ -8,9 +8,13 @@ namespace Shared.DTO
{
public enum Action
{
Join,
Host,
Connect,
Join,
End
End,
SendPlayer,
RecivePlayer,
SendEntities
}
}

Loading…
Cancel
Save