Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SocketIOClient.uplugin
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "2.11.2",
"EngineVersion": "5.7",
"VersionName": "2.12.0",
"EngineVersion": "5.8",
"FriendlyName": "Socket.IO Client",
"Description": "Real-time WebSocket networking via Socket.IO protocol usable from blueprints and c++.",
"Category": "Networking",
Expand Down
4 changes: 2 additions & 2 deletions Source/CoreUtility/Private/CUBlueprintLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ UTexture2D* UCUBlueprintLibrary::Conv_BytesToTexture(const TArray<uint8>& InByte
ENQUEUE_RENDER_COMMAND(BytesToTextureCommand)(
[UpdateData](FRHICommandList& CommandList)
{
RHIUpdateTexture2D(
CommandList.UpdateTexture2D(
((FTextureResource*)UpdateData->Texture2D->GetResource())->GetTextureRHI()->GetTexture2D(),
0,
UpdateData->Region,
Expand Down Expand Up @@ -472,7 +472,7 @@ TFuture<UTexture2D*> UCUBlueprintLibrary::Conv_BytesToTexture_Async(const TArray
ENQUEUE_RENDER_COMMAND(BytesToTextureAsyncCommand)(
[UpdateData](FRHICommandList& CommandList)
{
RHIUpdateTexture2D(
CommandList.UpdateTexture2D(
((FTextureResource*)UpdateData->Texture2D->GetResource())->GetTextureRHI()->GetTexture2D(),
0,
UpdateData->Region,
Expand Down
42 changes: 31 additions & 11 deletions Source/SIOJson/Private/SIOJConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ namespace
{
FJsonObjectConverter::CustomExportCallback EnumOverrideExportCallback;

//UE 5.8: FJsonObject stores keys as UE::FSharedString (FJsonObject::FStringType)
//instead of FString. Convert to an FString-keyed map so the partial converter copy
//below can keep its FString interface unchanged.
TMap<FString, TSharedPtr<FJsonValue>> ToFStringKeyedMap(const TMap<FJsonObject::FStringType, TSharedPtr<FJsonValue>>& In)
{
TMap<FString, TSharedPtr<FJsonValue>> Out;
Out.Reserve(In.Num());
for (const auto& Pair : In)
{
Out.Add(FString(*Pair.Key), Pair.Value);
}
return Out;
}

//Begin partial copy of FJsonObjectConverter for BP enum workaround
bool JsonValueToFPropertyWithContainer(const TSharedPtr<FJsonValue>& JsonValue, FProperty* Property, void* OutValue, const UStruct* ContainerStruct, void* Container, int64 CheckFlags, int64 SkipFlags);
bool JsonAttributesToUStructWithContainer(const TMap< FString, TSharedPtr<FJsonValue> >& JsonAttributes, const UStruct* StructDefinition, void* OutStruct, const UStruct* ContainerStruct, void* Container, int64 CheckFlags, int64 SkipFlags);
Expand Down Expand Up @@ -175,7 +189,7 @@ namespace
{
int32 NewIndex = Helper.AddDefaultValue_Invalid_NeedsRehash();

TSharedPtr<FJsonValueString> TempKeyValue = MakeShared<FJsonValueString>(Entry.Key);
TSharedPtr<FJsonValueString> TempKeyValue = MakeShared<FJsonValueString>(FString(*Entry.Key));

const bool bKeySuccess = JsonValueToFPropertyWithContainer(TempKeyValue, MapProperty->KeyProp, Helper.GetKeyPtr(NewIndex), ContainerStruct, Container, CheckFlags & (~CPF_ParmFlags), SkipFlags);
const bool bValueSuccess = JsonValueToFPropertyWithContainer(Entry.Value, MapProperty->ValueProp, Helper.GetValuePtr(NewIndex), ContainerStruct, Container, CheckFlags & (~CPF_ParmFlags), SkipFlags);
Expand Down Expand Up @@ -264,7 +278,7 @@ namespace
{
TSharedPtr<FJsonObject> Obj = JsonValue->AsObject();
check(Obj.IsValid()); // should not fail if Type == EJson::Object
if (!JsonAttributesToUStructWithContainer(Obj->Values, StructProperty->Struct, OutValue, ContainerStruct, Container, CheckFlags & (~CPF_ParmFlags), SkipFlags))
if (!JsonAttributesToUStructWithContainer(ToFStringKeyedMap(Obj->Values), StructProperty->Struct, OutValue, ContainerStruct, Container, CheckFlags & (~CPF_ParmFlags), SkipFlags))
{
UE_LOG(LogJson, Error, TEXT("BPEnumWA-JsonValueToUProperty - FJsonObjectConverter::JsonObjectToUStruct failed for property %s"), *Property->GetNameCPP());
return false;
Expand Down Expand Up @@ -362,7 +376,7 @@ namespace

TSharedPtr<FJsonObject> Obj = JsonValue->AsObject();
check(Obj.IsValid()); // should not fail if Type == EJson::Object
if (!JsonAttributesToUStructWithContainer(Obj->Values, ObjectProperty->PropertyClass, CreatedObj, ObjectProperty->PropertyClass, CreatedObj, CheckFlags & (~CPF_ParmFlags), SkipFlags))
if (!JsonAttributesToUStructWithContainer(ToFStringKeyedMap(Obj->Values), ObjectProperty->PropertyClass, CreatedObj, ObjectProperty->PropertyClass, CreatedObj, CheckFlags & (~CPF_ParmFlags), SkipFlags))
{
UE_LOG(LogJson, Error, TEXT("BPEnumWA-JsonValueToUProperty - FJsonObjectConverter::JsonObjectToUStruct failed for property %s"), *Property->GetNameCPP());
return false;
Expand Down Expand Up @@ -484,7 +498,12 @@ namespace
// Just copy it into the object
FJsonObjectWrapper* ProxyObject = (FJsonObjectWrapper *)OutStruct;
ProxyObject->JsonObject = MakeShared<FJsonObject>();
ProxyObject->JsonObject->Values = JsonAttributes;
//UE 5.8: assign via SetField so FString keys are interned into the
//object's shared-string set (Values is keyed by UE::FSharedString).
for (const auto& Pair : JsonAttributes)
{
ProxyObject->JsonObject->SetField(Pair.Key, Pair.Value);
}
return true;
}

Expand Down Expand Up @@ -543,7 +562,7 @@ namespace
public:
static bool JsonObjectToUStruct(const TSharedRef<FJsonObject>& JsonObject, const UStruct* StructDefinition, void* OutStruct, int64 CheckFlags, int64 SkipFlags)
{
return JsonAttributesToUStructWithContainer(JsonObject->Values, StructDefinition, OutStruct, StructDefinition, OutStruct, CheckFlags, SkipFlags);
return JsonAttributesToUStructWithContainer(ToFStringKeyedMap(JsonObject->Values), StructDefinition, OutStruct, StructDefinition, OutStruct, CheckFlags, SkipFlags);
}
};
}
Expand Down Expand Up @@ -901,7 +920,7 @@ void USIOJConvert::TrimValueKeyNames(const TSharedPtr<FJsonValue>& JsonValue)
auto JsonObject = JsonValue->AsObject();
for (auto Pair : JsonObject->Values)
{
const FString& Key = Pair.Key;
const FString Key(*Pair.Key);
FString TrimmedKey;

bool DidNeedTrimming = TrimKey(Key, TrimmedKey);
Expand Down Expand Up @@ -1061,25 +1080,26 @@ void USIOJConvert::ReplaceJsonValueNamesWithMap(TSharedPtr<FJsonValue>& JsonValu

for (auto Pair : AllValues)
{
const FString Key(*Pair.Key);
if (SubMap.Contains(TMAP_STRING))
{
FString TMapString = FString(TMAP_STRING);
//If we found a tmap, replace each sub key with list of keys
ReplaceJsonValueNamesWithMap(Pair.Value, SubMap[TMapString]);
}
else if (SubMap.Num() > 0 && SubMap.Contains(Pair.Key))
else if (SubMap.Num() > 0 && SubMap.Contains(Key))
{
//Get the long key for entry
const FString& LongKey = SubMap[Pair.Key]->LongKey;
const FString& LongKey = SubMap[Key]->LongKey;

//loop nested structures
ReplaceJsonValueNamesWithMap(Pair.Value, SubMap[Pair.Key]);
ReplaceJsonValueNamesWithMap(Pair.Value, SubMap[Key]);

if (Pair.Key != LongKey)
if (Key != LongKey)
{
//finally set the field and remove the old field
Object->SetField(LongKey, Pair.Value);
Object->RemoveField(Pair.Key);
Object->RemoveField(Key);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/SIOJson/Private/SIOJRequestJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void USIOJRequestJSON::ProcessRequest()
// Loop through all the values and prepare additional url part
for (auto RequestIt = RequestJsonObj->GetRootObject()->Values.CreateIterator(); RequestIt; ++RequestIt)
{
FString Key = RequestIt.Key();
FString Key(*RequestIt.Key());
FString Value = RequestIt.Value().Get()->AsString();

if (!Key.IsEmpty() && !Value.IsEmpty())
Expand Down Expand Up @@ -299,7 +299,7 @@ void USIOJRequestJSON::ProcessRequest()
// Loop through all the values and prepare additional url part
for (auto RequestIt = RequestJsonObj->GetRootObject()->Values.CreateIterator(); RequestIt; ++RequestIt)
{
FString Key = RequestIt.Key();
FString Key(*RequestIt.Key());
FString Value = RequestIt.Value().Get()->AsString();

if (!Key.IsEmpty() && !Value.IsEmpty())
Expand Down
9 changes: 7 additions & 2 deletions Source/SIOJson/Private/SIOJsonObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,13 @@ TArray<FString> USIOJsonObject::GetFieldNames()
return Result;
}

JsonObj->Values.GetKeys(Result);

//UE 5.8: FJsonObject keys are UE::FSharedString; copy them into FString results.
Result.Reserve(JsonObj->Values.Num());
for (const auto& Pair : JsonObj->Values)
{
Result.Add(FString(*Pair.Key));
}

return Result;
}

Expand Down
6 changes: 3 additions & 3 deletions Source/SocketIOClient/Private/SIOMessageConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ sio::message::ptr USIOMessageConvert::ToSIOMessage(const TSharedPtr<FJsonValue>&
for (auto ItemPair : ValueTmap)
{
//important to use get_map() directly to insert the key in the correct map and not a pointer copy
ObjectMessage->get_map()[StdString(ItemPair.Key)] = ToSIOMessage(ItemPair.Value);
ObjectMessage->get_map()[StdString(FString(*ItemPair.Key))] = ToSIOMessage(ItemPair.Value);
}

return ObjectMessage;
Expand Down Expand Up @@ -176,7 +176,7 @@ std::map<std::string, std::string> USIOMessageConvert::JsonObjectToStdStringMap(
//If it's a string value, add it to the std map
if (Value->Type == EJson::String)
{
ParamMap[USIOMessageConvert::StdString(Pair.Key)] = USIOMessageConvert::StdString(Value->AsString());
ParamMap[USIOMessageConvert::StdString(FString(*Pair.Key))] = USIOMessageConvert::StdString(Value->AsString());
}
}
}
Expand All @@ -197,7 +197,7 @@ TMap<FString, FString> USIOMessageConvert::JsonObjectToFStringMap(TSharedPtr<FJs
//If it's a string value, add it to the std map
if (Value->Type == EJson::String)
{
ParamMap.Add(Pair.Key, Value->AsString());
ParamMap.Add(FString(*Pair.Key), Value->AsString());
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion Source/SocketIOClient/Private/SocketIONative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ void FSocketIONative::SetupInternalCallbacks()
bIsConnected = false;

ESIOConnectionCloseReason DisconnectReason = (ESIOConnectionCloseReason)reason;
FString DisconnectReasonString = UEnum::GetValueAsString<ESIOConnectionCloseReason>(DisconnectReason);
//UE 5.8: StaticEnum<>() is deleted for this namespaced UENUM, so map the close
//reason to a string directly for the diagnostic log below.
FString DisconnectReasonString = (DisconnectReason == CLOSE_REASON_NORMAL) ? TEXT("CLOSE_REASON_NORMAL") : TEXT("CLOSE_REASON_DROP");
if (VerboseLog)
{
UE_LOG(SocketIO, Log, TEXT("SocketIO Disconnected %s reason: %s"), *SessionId, *DisconnectReasonString);
Expand Down