VShow is a function that just sets up ClientMessage in a particular way, nothing particularly unusual there.
Having set up the code using an FMemoryReader archive, the code doesn’t crash, but I think that’s more because the deserialize function now returns false. Would you have any idea why that might be? I unfortunately don’t know whether thats due to my code, or due to something on the other end, but I have been assured that all works fine on the server program.
The New code:
void ANetworkPlayerController::ReceiveData()
{
TArray<uint8> ReceivedData;
uint32 Size;
//uint8 receivedData[1000];
int32 Read = 0;
while (Socket->HasPendingData(Size))
{
ReceivedData.SetNumUninitialized(FMath::Min(Size, 65507u));
Read = 0;
Socket->Recv(ReceivedData.GetData(), ReceivedData.Num(), Read);
}
if (ReceivedData.Num() <= 0)
{
VShow("Error, the Server isn't streaming data");
//return;
}
FMemoryReader MemoryReader(ReceivedData);
TSharedRef< TJsonReader<> > Reader = TJsonReader<>::Create(&MemoryReader);
bool result = FJsonSerializer::Deserialize(Reader, JsonObject);
if (!result)
Print("Error, Json Deserialization Failed");
}