Skip to content
Open
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
10 changes: 10 additions & 0 deletions Source/AccelByteUe4Sdk/Private/Core/AccelByteMultiRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
namespace AccelByte
{

FCriticalSection MultiRegistryMutex;

FApiClientPtr AccelByte::FMultiRegistry::GetApiClient(const FString &Key, bool bCreateIfNotFound)
{
FScopeLock Lock(&MultiRegistryMutex);

if (!ApiClientInstances.Contains(Key))
{
if (!bCreateIfNotFound)
Expand All @@ -35,6 +39,7 @@ FApiClientPtr AccelByte::FMultiRegistry::GetApiClient(const FString &Key, bool b

FServerApiClientPtr AccelByte::FMultiRegistry::GetServerApiClient(const FString &Key)
{
FScopeLock Lock(&MultiRegistryMutex);
if (!ServerApiClientInstances.Contains(Key))
{
FServerApiClientPtr NewClient = nullptr;
Expand All @@ -56,6 +61,7 @@ FServerApiClientPtr AccelByte::FMultiRegistry::GetServerApiClient(const FString

bool FMultiRegistry::RegisterApiClient(FString const &Key, FApiClientPtr ApiClient)
{
FScopeLock Lock(&MultiRegistryMutex);
bool bResult = false;

if (!Key.IsEmpty())
Expand All @@ -69,6 +75,7 @@ bool FMultiRegistry::RegisterApiClient(FString const &Key, FApiClientPtr ApiClie

bool FMultiRegistry::RemoveApiClient(const FString &Key)
{
FScopeLock Lock(&MultiRegistryMutex);
bool bResult = false;

if (!Key.IsEmpty())
Expand All @@ -82,6 +89,7 @@ bool FMultiRegistry::RemoveApiClient(const FString &Key)

bool FMultiRegistry::RemoveServerApiClient(const FString &Key)
{
FScopeLock Lock(&MultiRegistryMutex);
bool bResult = false;

if (!Key.IsEmpty())
Expand All @@ -95,6 +103,8 @@ bool FMultiRegistry::RemoveServerApiClient(const FString &Key)

void FMultiRegistry::Shutdown()
{
FScopeLock Lock(&MultiRegistryMutex);

TArray<FString> ApiClientKeys{};
ApiClientInstances.GenerateKeyArray(ApiClientKeys);
ApiClientKeys.Remove(TEXT("default"));
Expand Down