Skip to content

Commit

Permalink
Actually fix binary messages
Browse files Browse the repository at this point in the history
- Binary partials have no frame messages anymore
- Tested on a png echo emit loop at 120fps
- Catch attempt to decode a binary field with a null json value (e.g. property mismatch)
  • Loading branch information
getnamo committed May 5, 2023
1 parent d433f93 commit fadf99a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion SocketIOClient.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "2.5.7",
"VersionName": "2.5.8",
"EngineVersion": "5.1",
"FriendlyName": "Socket.IO Client",
"Description": "Real-time WebSocket networking via Socket.IO protocol usable from blueprints and c++.",
Expand Down
7 changes: 7 additions & 0 deletions Source/SIOJson/Private/SIOJsonObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,19 @@ void USIOJsonObject::SetObjectField(const FString& FieldName, USIOJsonObject* Js

void USIOJsonObject::GetBinaryField(const FString& FieldName, TArray<uint8>& OutBinary) const
{

if (!JsonObj->HasTypedField<EJson::String>(FieldName))
{
UE_LOG(LogSIOJ, Warning, TEXT("No field with name %s of type String"), *FieldName);
}
TSharedPtr<FJsonValue> JsonValue = JsonObj->TryGetField(FieldName);

if (!JsonValue)
{
UE_LOG(LogSIOJ, Warning, TEXT("JsonValue is null for %s, aborting parse."), *FieldName);
return;
}

if (FJsonValueBinary::IsBinary(JsonValue))
{
OutBinary = FJsonValueBinary::AsBinary(JsonValue);
Expand Down
13 changes: 6 additions & 7 deletions Source/SocketIOLib/Private/internal/sio_packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,15 +504,14 @@ namespace sio
break;
}
}
else if (packet::is_binary_message(payload) || (m_partial_packet && !isdigit(payload[0])))

//In current socket.io version, it doesn't appear binary payloads come with a frame message.
else if (m_partial_packet && payload.size() > 0)
{
if (m_partial_packet)
if (!m_partial_packet->parse_buffer(payload))
{
if (!m_partial_packet->parse_buffer(payload))
{
p = std::move(m_partial_packet);
break;
}
p = std::move(m_partial_packet);
break;
}
}
else
Expand Down

0 comments on commit fadf99a

Please sign in to comment.