diff --git a/code/server/Server/Room.cs b/code/server/Server/Room.cs index 0252adf..11b2197 100644 --- a/code/server/Server/Room.cs +++ b/code/server/Server/Room.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using Shared.DTO; using System.ComponentModel; +using System.Text.Json; namespace Server { @@ -81,6 +82,13 @@ namespace Server if (maxPlayer == 2) { + IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0); + + byte[] receivedDataHost = playerHost.Value.Receive(ref remoteEndPoint); + playerJoin.Value.Send(receivedDataHost, receivedDataHost.Length, remoteEndPoint); + + byte[] receivedDataJoin = playerJoin.Value.Receive(ref remoteEndPoint); + playerHost.Value.Send(receivedDataJoin, receivedDataJoin.Length, remoteEndPoint); Thread receiveThread1 = new Thread(() => ReceiveMessages(playerHost.Value, playerJoin.Value)); diff --git a/code/server/Shared/DTO/Informations.cs b/code/server/Shared/DTO/Informations.cs index 4974c43..db0044d 100644 --- a/code/server/Shared/DTO/Informations.cs +++ b/code/server/Shared/DTO/Informations.cs @@ -9,6 +9,16 @@ namespace Shared.DTO public class Informations { public Action Action { get; set; } - public string? IdRoom { get; set; } + public long Frame { get; set; } + public string TypeData { get; set; } + public string? IdRoom { get; set; } + + public Informations(Action action, long frame, string typeData, string? idRoom = null) + { + Action = action; + Frame = frame; + TypeData = typeData; + IdRoom = idRoom; + } } } diff --git a/code/server/Shared/DTO/ObjectTransfert.cs b/code/server/Shared/DTO/ObjectTransfert.cs index 5acfca2..3e2c017 100644 --- a/code/server/Shared/DTO/ObjectTransfert.cs +++ b/code/server/Shared/DTO/ObjectTransfert.cs @@ -10,5 +10,11 @@ namespace Shared.DTO { public Informations Informations { get; set; } public T Data { get; set; } + + public ObjectTransfert(Informations infos, T data) + { + Informations = infos; + Data = data; + } } }