Skip to content

Commit

Permalink
5.1 update
Browse files Browse the repository at this point in the history
- Loading phase  for SocketIOClient changed to predefault
- Soundwave RawData access changed to GetResourceData()
- Updated api to use ImportText_Direct in SIOJConvert
- Removed C++ EnumToString utility, use `UEnum::GetValueAsString<Type>(Value)` api instead.
  • Loading branch information
getnamo committed Nov 16, 2022
1 parent 802fb9a commit 992cd74
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 19 deletions.
6 changes: 3 additions & 3 deletions SocketIOClient.uplugin
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "2.4.4",
"EngineVersion": "5.0.0",
"VersionName": "2.5.0",
"EngineVersion": "5.1.0",
"FriendlyName": "Socket.IO Client",
"Description": "Real-time WebSocket networking via Socket.IO protocol usable from blueprints and c++.",
"Category": "Networking",
Expand All @@ -19,7 +19,7 @@
{
"Name": "SocketIOClient",
"Type": "Runtime",
"LoadingPhase": "Default",
"LoadingPhase": "PreDefault",
"WhitelistPlatforms": [
"Win64",
"Linux",
Expand Down
5 changes: 2 additions & 3 deletions Source/CoreUtility/Private/CUBlueprintLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,9 @@ TArray<uint8> UCUBlueprintLibrary::Conv_SoundWaveToWavBytes(USoundWave* SoundWav
TArray<uint8> WavBytes;

//memcpy raw data from soundwave, hmm this won't work for procedurals...
const void* LockedData = SoundWave->RawData.LockReadOnly();
PCMBytes.SetNumUninitialized(SoundWave->RawData.GetBulkDataSize());
const void* LockedData = SoundWave->GetResourceData();
PCMBytes.SetNumUninitialized(SoundWave->GetResourceSize());
FMemory::Memcpy(PCMBytes.GetData(), LockedData, PCMBytes.Num());
SoundWave->RawData.Unlock();

//add wav header
SerializeWaveFile(WavBytes, PCMBytes.GetData(), PCMBytes.Num(), SoundWave->NumChannels, SoundWave->GetSampleRateForCurrentPlatform());
Expand Down
14 changes: 4 additions & 10 deletions Source/SIOJson/Private/SIOJConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,14 @@ namespace
if (!TheCppStructOps->ImportTextItem(ImportTextPtr, OutValue, PPF_None, nullptr, (FOutputDevice*)GWarn))
{
// Fall back to trying the tagged property approach if custom ImportTextItem couldn't get it done
Property->ImportText(ImportTextPtr, OutValue, PPF_None, nullptr);
Property->ImportText_Direct(ImportTextPtr, OutValue, nullptr, PPF_None);
}
}
else if (JsonValue->Type == EJson::String)
{
FString ImportTextString = JsonValue->AsString();
const TCHAR* ImportTextPtr = *ImportTextString;
Property->ImportText(ImportTextPtr, OutValue, PPF_None, nullptr);
Property->ImportText_Direct(ImportTextPtr, OutValue, nullptr, PPF_None);
}
else
{
Expand Down Expand Up @@ -370,7 +370,7 @@ namespace
else if (JsonValue->Type == EJson::String)
{
// Default to expect a string for everything else
if (Property->ImportText(*JsonValue->AsString(), OutValue, 0, NULL) == NULL)
if (Property->ImportText_Direct(*JsonValue->AsString(), OutValue, nullptr, PPF_None) == nullptr)
{
UE_LOG(LogJson, Error, TEXT("BPEnumWA-JsonValueToUProperty - Unable import property type %s from string value for property %s"), *Property->GetClass()->GetName(), *Property->GetNameCPP());
return false;
Expand All @@ -380,7 +380,7 @@ namespace
else
{
// Default to expect a string for everything else
if (Property->ImportText(*JsonValue->AsString(), OutValue, 0, NULL) == NULL)
if (Property->ImportText_Direct(*JsonValue->AsString(), OutValue, nullptr, PPF_None) == nullptr)
{
UE_LOG(LogJson, Error, TEXT("BPEnumWA-JsonValueToUProperty - Unable import property type %s from string value for property %s"), *Property->GetClass()->GetName(), *Property->GetNameCPP());
return false;
Expand Down Expand Up @@ -1081,9 +1081,3 @@ void USIOJConvert::ReplaceJsonValueNamesWithMap(TSharedPtr<FJsonValue>& JsonValu
}
}
}

FString USIOJConvert::EnumToString(const FString& enumName, const int32 value)
{
UEnum* pEnum = FindObject<UEnum>(ANY_PACKAGE, *enumName);
return *(pEnum ? pEnum->GetNameStringByIndex(static_cast<uint8>(value)) : "null");
}
2 changes: 0 additions & 2 deletions Source/SIOJson/Public/SIOJConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ class SIOJSON_API USIOJConvert : public UObject
static void SetTrimmedKeyMapForStruct(TSharedPtr<FTrimmedKeyMap>& InMap, UStruct* Struct);
static void SetTrimmedKeyMapForProp(TSharedPtr<FTrimmedKeyMap>& InMap, FProperty* ArrayInnerProp);
static void ReplaceJsonValueNamesWithMap(TSharedPtr<FJsonValue>& InValue, TSharedPtr<FTrimmedKeyMap> KeyMap);

static FString EnumToString(const FString& enumName, const int32 value);
};


2 changes: 1 addition & 1 deletion Source/SocketIOClient/Private/SocketIONative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ void FSocketIONative::SetupInternalCallbacks()
bIsConnected = false;

ESIOConnectionCloseReason DisconnectReason = (ESIOConnectionCloseReason)reason;
FString DisconnectReasonString = USIOJConvert::EnumToString(TEXT("ESIOConnectionCloseReason"), DisconnectReason);
FString DisconnectReasonString = UEnum::GetValueAsString<ESIOConnectionCloseReason>(DisconnectReason);
if (VerboseLog)
{
UE_LOG(SocketIO, Log, TEXT("SocketIO Disconnected %s reason: %s"), *SessionId, *DisconnectReasonString);
Expand Down

0 comments on commit 992cd74

Please sign in to comment.