fix: json receive null data

master
tiendat3699 2024-04-11 17:05:59 +07:00
parent 476851bf4f
commit 5f9e8f0b66
1 changed files with 9 additions and 6 deletions

View File

@ -43,7 +43,6 @@ namespace GadGame.Network
}
}
private void GetReceiveData()
{
while (_receiving)
@ -55,7 +54,11 @@ namespace GadGame.Network
var buffer = new byte[1024];
var bytesRead = stream.Read(buffer, 0, buffer.Length);
var jsonData = Encoding.ASCII.GetString(buffer, 0, bytesRead);
_dataReceived = JsonConvert.DeserializeObject<ReceiverData>(jsonData);
_dataReceived = JsonConvert.DeserializeObject<ReceiverData>(jsonData, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
MissingMemberHandling = MissingMemberHandling.Ignore
});
}
catch (Exception e)
{