From b0d54b2af9958614149ee5b3637f33e3488e54d3 Mon Sep 17 00:00:00 2001 From: Bruno Da Costa Cunha Date: Thu, 23 Mar 2023 10:01:05 +0100 Subject: [PATCH] =?UTF-8?q?:bug:=20mis=20=C3=A0=20jour=20du=20serveur,=20m?= =?UTF-8?q?ais=20j'ai=20quand=20meme=20une=20exception=20lors=20de=20la=20?= =?UTF-8?q?connexion=20client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/server/Server/Room.cs | 8 ++++++++ code/server/Shared/DTO/Informations.cs | 12 +++++++++++- code/server/Shared/DTO/ObjectTransfert.cs | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) 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; + } } }