So I am currently creating functions that will allow me to take in an array of bytes through a Network Socket, deserialize it back into Json, and then Parse said Json. However, when I try to use the deserialize Function, the entire Engine Crashes, and I am given a link to send a crash report.Here’s the .rar file to my crash report.
The Code Chunk that is most relevant is below:
TArray<uint8> ReceivedData;
uint32 Size;
uint8 receivedData[100];
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");
}
FString output = StringFromBinaryArray(ReceivedData);
FString debugData = BytesToString(receivedData, Read);
Print("Got Message" + debugData);
TSharedPtr<FJsonObject> JsonObject;
TSharedRef< TJsonReader<> > Reader = TJsonReaderFactory<>::Create(debugData);
//If the line below this is commented out, the program doesn't crash
bool result = FJsonSerializer::Deserialize(Reader, JsonObject);
if (!result)
Print("Error, Json Deserialization Failed");
My Implementation in my Blueprint currently Connects to the other IP Address, delays for a second, then calls the above function. I know that the Socket works fine, as I am getting a connection, along with the data.
The Json being sent is being sent like this, according to the developers of the Software I am trying to access:
{"animationValues":
{
"mouth_rightMouth_stretch":0.0000000000000000,
"mouth_leftMouth_narrow":0.00000000000000000,
"mouth_up":0.0000000000000000,
"mouth_leftMouth_stretch":0.0000000000000000,
"mouth_rightMouth_narrow":0.00000000000000000,
"mouth_down":0.00000000000000000,
"mouth_upperLip_left_up":0.0000000000000000,
"mouth_upperLip_right_up":0.0000000000000000,
"mouth_lowerLip_left_down":0.0000000000000000,
"mouth_lowerLip_right_down":0.0000000000000000,
"mouth_leftMouth_frown":0.0000000000000000,
"mouth_rightMouth_frown":0.0000000000000000,
"mouth_leftMouth_smile":0.00000000000000000,
"mouth_rightMouth_smile":0.00000000000000000,
"eyes_lookRight":0.0000000000000000,
"eyes_lookLeft":0.00000000000000000,
"eyes_lookDown":0.0000000000000000,
"eyes_lookUp":0.00000000000000000,
"eyes_leftEye_blink":0.00000000000000000,
"eyes_rightEye_blink":0.00000000000000000,
"eyes_leftEye_wide":0.0000000000000000,
"eyes_rightEye_wide":0.0000000000000000,
"brows_leftBrow_up":0.0000000000000000,
"brows_leftBrow_down":0.00000000000000000,
"brows_rightBrow_up":0.0000000000000000,
"brows_rightBrow_down":0.00000000000000000,
"brows_midBrows_up":0.0000000000000000,
"brows_midBrows_down":0.00000000000000000,
"jaw_open":0.0000000000000000,
"jaw_left":0.0000000000000000,
"jaw_right":0.00000000000000000,
"mouth_phoneme_oo":0.0000000000000000,
"mouth_right":0.0000000000000000,
"mouth_left":0.00000000000000000,
"mouth_phoneme_mbp":0.0000000000000000,
"mouth_phoneme_ch":0.0000000000000000
},
"headRot":[0.0,0.0,0.0]}
I have no reason to assume there is anything wrong on their side, as they offer a plugin to do the same job. However, it costs $1500, so that’s out of the question. I don’t really see how I can be doing anything wrong in this situation, as the code compiles correctly without any errors.