merging latest dev + resolving 1 conflict

Signed-off-by: Gene Walters <genewalt@amazon.com>
This commit is contained in:
Gene Walters
2021-10-06 16:55:58 -07:00
1635 changed files with 159616 additions and 23634 deletions
@@ -9,6 +9,8 @@
#include <AzCore/EBus/EBus.h>
#include <memory>
namespace Aws
{
namespace CognitoIdentityProvider
@@ -33,7 +33,7 @@ namespace AWSClientAuth
AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
if (serialize)
{
serialize->Class<AWSClientAuthSystemComponent, AZ::Component>()->Version(0);
serialize->Class<AWSClientAuthSystemComponent, AZ::Component>()->Version(1);
if (AZ::EditContext* ec = serialize->GetEditContext())
{
@@ -55,26 +55,44 @@ namespace AWSClientAuth
->Enum<(int)ProviderNameEnum::AWSCognitoIDP>("ProviderNameEnum_AWSCognitoIDP")
->Enum<(int)ProviderNameEnum::LoginWithAmazon>("ProviderNameEnum_LoginWithAmazon")
->Enum<(int)ProviderNameEnum::Google>("ProviderNameEnum_Google");
behaviorContext->EBus<AuthenticationProviderScriptCanvasRequestBus>("AuthenticationProviderRequestBus")
->Attribute(AZ::Script::Attributes::Category, SerializeComponentName)
->Event("Initialize", &AuthenticationProviderScriptCanvasRequestBus::Events::Initialize)
->Event("IsSignedIn", &AuthenticationProviderScriptCanvasRequestBus::Events::IsSignedIn)
->Event("GetAuthenticationTokens", &AuthenticationProviderScriptCanvasRequestBus::Events::GetAuthenticationTokens)
->Event("IsSignedIn", &AuthenticationProviderScriptCanvasRequestBus::Events::IsSignedIn,
{ { { "Provider name", "The identity provider name" } } })
->Event("GetAuthenticationTokens", &AuthenticationProviderScriptCanvasRequestBus::Events::GetAuthenticationTokens,
{ { { "Provider name", "The identity provider name" } } })
->Event(
"PasswordGrantSingleFactorSignInAsync",
&AuthenticationProviderScriptCanvasRequestBus::Events::PasswordGrantSingleFactorSignInAsync)
&AuthenticationProviderScriptCanvasRequestBus::Events::PasswordGrantSingleFactorSignInAsync,
{ { { "Provider name", "The identity provider" }, { "Username", "The client's username" }, { "Password", "The client's password" } } })
->Event(
"PasswordGrantMultiFactorSignInAsync",
&AuthenticationProviderScriptCanvasRequestBus::Events::PasswordGrantMultiFactorSignInAsync)
&AuthenticationProviderScriptCanvasRequestBus::Events::PasswordGrantMultiFactorSignInAsync,
{ { { "Provider name", "The identity provider name" },
{ "Username", "The client's username" },
{ "Password", "The client's password" } } })
->Event(
"PasswordGrantMultiFactorConfirmSignInAsync",
&AuthenticationProviderScriptCanvasRequestBus::Events::PasswordGrantMultiFactorConfirmSignInAsync)
->Event("DeviceCodeGrantSignInAsync", &AuthenticationProviderScriptCanvasRequestBus::Events::DeviceCodeGrantSignInAsync)
->Event("DeviceCodeGrantConfirmSignInAsync", &AuthenticationProviderScriptCanvasRequestBus::Events::DeviceCodeGrantConfirmSignInAsync)
->Event("RefreshTokensAsync", &AuthenticationProviderScriptCanvasRequestBus::Events::RefreshTokensAsync)
->Event("GetTokensWithRefreshAsync", &AuthenticationProviderScriptCanvasRequestBus::Events::GetTokensWithRefreshAsync)
->Event("SignOut", &AuthenticationProviderScriptCanvasRequestBus::Events::SignOut);
&AuthenticationProviderScriptCanvasRequestBus::Events::PasswordGrantMultiFactorConfirmSignInAsync,
{ { { "Provider name", "The identity provider name" },
{ "Username", "The client's username" },
{ "Confirmation code", "The client's confirmation code" } } })
->Event(
"DeviceCodeGrantSignInAsync", &AuthenticationProviderScriptCanvasRequestBus::Events::DeviceCodeGrantSignInAsync,
{ { { "Provider name", "The identity provider name" } } })
->Event(
"DeviceCodeGrantConfirmSignInAsync",
&AuthenticationProviderScriptCanvasRequestBus::Events::DeviceCodeGrantConfirmSignInAsync,
{ { { "Provider name", "The identity provider name" } } })
->Event(
"RefreshTokensAsync", &AuthenticationProviderScriptCanvasRequestBus::Events::RefreshTokensAsync,
{ { { "Provider name", "The identity provider name" } } })
->Event("GetTokensWithRefreshAsync", &AuthenticationProviderScriptCanvasRequestBus::Events::GetTokensWithRefreshAsync,
{ { { "Provider name", "The identity provider name" } } })
->Event(
"SignOut", &AuthenticationProviderScriptCanvasRequestBus::Events::SignOut,
{ { { "Provider name", "The identity provider name" } } });
behaviorContext->EBus<AWSCognitoAuthorizationRequestBus>("AWSCognitoAuthorizationRequestBus")
->Attribute(AZ::Script::Attributes::Category, SerializeComponentName)
+8 -8
View File
@@ -6,18 +6,18 @@
#
#
ly_get_list_relative_pal_filename(pal_editor_include_dir ${CMAKE_CURRENT_LIST_DIR}/Include/Private/Editor/Platform/${PAL_PLATFORM_NAME})
ly_get_list_relative_pal_filename(pal_cafile_include_dir ${CMAKE_CURRENT_LIST_DIR}/Source/Framework/Platform/${PAL_PLATFORM_NAME})
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME})
ly_add_target(
NAME AWSCore.Static STATIC
NAMESPACE Gem
FILES_CMAKE
awscore_files.cmake
${pal_cafile_include_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Include/Public
${pal_dir}
PRIVATE
Include/Private
BUILD_DEPENDENCIES
@@ -65,11 +65,11 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS)
NAMESPACE Gem
FILES_CMAKE
awscore_editor_files.cmake
${pal_editor_include_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_editor_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Include/Private
${pal_editor_include_dir}
${pal_dir}
PUBLIC
Include/Public
BUILD_DEPENDENCIES
@@ -164,12 +164,12 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
NAMESPACE Gem
FILES_CMAKE
awscore_editor_tests_files.cmake
${pal_editor_include_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
Tests/Editor/Platform/${PAL_PLATFORM_NAME}/awscore_editor_tests_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_editor_files.cmake
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_editor_tests_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Include/Private
${pal_editor_include_dir}
${pal_dir}
Include/Public
Tests
COMPILE_DEFINITIONS
@@ -21,7 +21,7 @@ namespace AWSCore
{
public:
AWSCVarCredentialHandler() = default;
~AWSCVarCredentialHandler() = default;
~AWSCVarCredentialHandler() override = default;
//! Activate handler and its credentials provider, make sure activation
//! invoked after AWSNativeSDK init to avoid memory leak
@@ -9,6 +9,7 @@
#include <AzCore/EBus/EBus.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <AWSCoreBus.h>
@@ -13,12 +13,15 @@
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AWSCore_Traits_Platform.h>
// The AWS Native SDK AWSAllocator triggers a warning due to accessing members of std::allocator directly.
// AWSAllocator.h(70): warning C4996: 'std::allocator<T>::pointer': warning STL4010: Various members of std::allocator are deprecated in C++17.
// Use std::allocator_traits instead of accessing these members directly.
// You can define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
AZ_PUSH_DISABLE_WARNING(4251 4996, "-Wunknown-warning-option")
#include <aws/core/client/ClientConfiguration.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/http/Scheme.h>
#include <aws/core/Region.h>
@@ -136,7 +139,11 @@ namespace AWSCore
Override<std::shared_ptr<Aws::Utils::RateLimits::RateLimiterInterface>> writeRateLimiter;
Override<std::shared_ptr<Aws::Utils::RateLimits::RateLimiterInterface>> readRateLimiter;
Override<Aws::Http::TransferLibType> httpLibOverride;
#if AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE
Override<Aws::Client::FollowRedirectsPolicy> followRedirects;
#else
Override<bool> followRedirects;
#endif
Override<Aws::String> caFile;
/// Applys settings changes made after first use.
@@ -0,0 +1,10 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 1
@@ -0,0 +1,10 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AWSCore_Traits_Android.h>
@@ -1,33 +1,33 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/PlatformDef.h>
// The AWS Native SDK AWSAllocator triggers a warning due to accessing members of std::allocator directly.
// AWSAllocator.h(70): warning C4996: 'std::allocator<T>::pointer': warning STL4010: Various members of std::allocator are deprecated in
// C++17. Use std::allocator_traits instead of accessing these members directly. You can define
// _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received
// this warning.
AZ_PUSH_DISABLE_WARNING(4251 4996, "-Wunknown-warning-option")
#include <aws/core/utils/memory/stl/AWSString.h>
AZ_POP_DISABLE_WARNING
#include <AzCore/Android/Utils.h>
#include <AzCore/std/string/string.h>
namespace AWSCore
{
namespace Platform
{
Aws::String GetCaCertBundlePath()
{
AZStd::string publicStoragePath = AZ::Android::Utils::GetAppPublicStoragePath();
publicStoragePath.append("/certificates/aws/cacert.pem");
return publicStoragePath.c_str();
}
} // namespace Platform
}
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/PlatformDef.h>
// The AWS Native SDK AWSAllocator triggers a warning due to accessing members of std::allocator directly.
// AWSAllocator.h(70): warning C4996: 'std::allocator<T>::pointer': warning STL4010: Various members of std::allocator are deprecated in
// C++17. Use std::allocator_traits instead of accessing these members directly. You can define
// _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received
// this warning.
AZ_PUSH_DISABLE_WARNING(4251 4996, "-Wunknown-warning-option")
#include <aws/core/utils/memory/stl/AWSString.h>
AZ_POP_DISABLE_WARNING
#include <AzCore/Android/Utils.h>
#include <AzCore/std/string/string.h>
namespace AWSCore
{
namespace Platform
{
Aws::String GetCaCertBundlePath()
{
AZStd::string publicStoragePath = AZ::Android::Utils::GetAppPublicStoragePath();
publicStoragePath.append("/certificates/aws/cacert.pem");
return publicStoragePath.c_str();
}
} // namespace Platform
}
@@ -7,5 +7,7 @@
#
set(FILES
AWSCore_Traits_Platform.h
AWSCore_Traits_Android.h
GetCertsPath_Android.cpp
)
@@ -1,28 +1,28 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/PlatformDef.h>
// The AWS Native SDK AWSAllocator triggers a warning due to accessing members of std::allocator directly.
// AWSAllocator.h(70): warning C4996: 'std::allocator<T>::pointer': warning STL4010: Various members of std::allocator are deprecated in
// C++17. Use std::allocator_traits instead of accessing these members directly. You can define
// _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received
// this warning.
AZ_PUSH_DISABLE_WARNING(4251 4996, "-Wunknown-warning-option")
#include <aws/core/utils/memory/stl/AWSString.h>
AZ_POP_DISABLE_WARNING
namespace AWSCore
{
namespace Platform
{
Aws::String GetCaCertBundlePath()
{
return ""; // no-op
}
} // namespace Platform
} // namespace GridMate
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/PlatformDef.h>
// The AWS Native SDK AWSAllocator triggers a warning due to accessing members of std::allocator directly.
// AWSAllocator.h(70): warning C4996: 'std::allocator<T>::pointer': warning STL4010: Various members of std::allocator are deprecated in
// C++17. Use std::allocator_traits instead of accessing these members directly. You can define
// _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received
// this warning.
AZ_PUSH_DISABLE_WARNING(4251 4996, "-Wunknown-warning-option")
#include <aws/core/utils/memory/stl/AWSString.h>
AZ_POP_DISABLE_WARNING
namespace AWSCore
{
namespace Platform
{
Aws::String GetCaCertBundlePath()
{
return ""; // no-op
}
} // namespace Platform
} // namespace GridMate
@@ -0,0 +1,10 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 0
@@ -0,0 +1,10 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AWSCore_Traits_Linux.h>
@@ -7,5 +7,7 @@
#
set(FILES
AWSCore_Traits_Platform.h
AWSCore_Traits_Linux.h
../Common/GetCertsPath_Null.cpp
)
@@ -0,0 +1,10 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 0
@@ -0,0 +1,10 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AWSCore_Traits_Mac.h>
@@ -0,0 +1,10 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set(FILES
)
@@ -7,5 +7,7 @@
#
set(FILES
AWSCore_Traits_Platform.h
AWSCore_Traits_Mac.h
../Common/GetCertsPath_Null.cpp
)
@@ -0,0 +1,10 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AWSCore_Traits_Windows.h>
@@ -0,0 +1,10 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 0
@@ -0,0 +1,19 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set(FILES
../../Tests/Editor/AWSCoreEditorSystemComponentTest.cpp
../../Tests/Editor/Attribution/AWSCoreAttributionManagerTest.cpp
../../Tests/Editor/Attribution/AWSCoreAttributionMetricTest.cpp
../../Tests/Editor/Attribution/AWSCoreAttributionSystemComponentTest.cpp
../../Tests/Editor/Attribution/AWSAttributionServiceApiTest.cpp
../../Tests/Editor/UI/AWSCoreEditorMenuTest.cpp
../../Tests/Editor/UI/AWSCoreEditorUIFixture.h
../../Tests/Editor/UI/AWSCoreResourceMappingToolActionTest.cpp
../../Tests/Editor/AWSCoreEditorManagerTest.cpp
)
@@ -7,5 +7,7 @@
#
set(FILES
AWSCore_Traits_Platform.h
AWSCore_Traits_Windows.h
../Common/GetCertsPath_Null.cpp
)
@@ -0,0 +1,10 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AWSCore_Traits_iOS.h>
@@ -0,0 +1,10 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 0
@@ -0,0 +1,10 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set(FILES
)
@@ -7,5 +7,7 @@
#
set(FILES
AWSCore_Traits_Platform.h
AWSCore_Traits_iOS.h
../Common/GetCertsPath_Null.cpp
)
@@ -11,6 +11,7 @@
#include <AzCore/Jobs/JobManagerBus.h>
#include <AzCore/Jobs/JobCancelGroup.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
@@ -64,7 +64,7 @@ namespace AWSCore
void AWSCoreConfiguration::InitSourceProjectFolderPath()
{
auto sourceProjectFolder = AZ::IO::FileIOBase::GetInstance()->GetAlias("@devassets@");
auto sourceProjectFolder = AZ::IO::FileIOBase::GetInstance()->GetAlias("@projectroot@");
if (!sourceProjectFolder)
{
AZ_Error(AWSCoreConfigurationName, false, ProjectSourceFolderNotFoundErrorMessage);
@@ -5,15 +5,14 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/Console/IConsole.h>
#include <Credential/AWSCVarCredentialHandler.h>
namespace AWSCore
{
AZ_CVAR(AZ::CVarFixedString, cl_awsAccessKey, "", nullptr, AZ::ConsoleFunctorFlags::Null, "Override AWS access key");
AZ_CVAR(AZ::CVarFixedString, cl_awsSecretKey, "", nullptr, AZ::ConsoleFunctorFlags::Null, "Override AWS secret key");
AZ_CVAR(AZ::CVarFixedString, cl_awsAccessKey, "", nullptr, AZ::ConsoleFunctorFlags::IsInvisible, "Override AWS access key");
AZ_CVAR(AZ::CVarFixedString, cl_awsSecretKey, "", nullptr, AZ::ConsoleFunctorFlags::IsInvisible, "Override AWS secret key");
static constexpr char AWSCVARCREDENTIALHANDLER_ALLOC_TAG[] = "AWSCVarCredentialHandler";
@@ -36,12 +35,12 @@ namespace AWSCore
std::shared_ptr<Aws::Auth::AWSCredentialsProvider> AWSCVarCredentialHandler::GetCredentialsProvider()
{
auto accessKey = static_cast<AZ::CVarFixedString>(cl_awsAccessKey);
auto secretKey = static_cast<AZ::CVarFixedString>(cl_awsSecretKey);
const auto accessKey = static_cast<AZ::CVarFixedString>(cl_awsAccessKey);
const auto secretKey = static_cast<AZ::CVarFixedString>(cl_awsSecretKey);
if (!accessKey.empty() && !secretKey.empty())
{
AZStd::lock_guard<AZStd::mutex> credentialsLock{m_credentialMutex};
AZStd::lock_guard<AZStd::mutex> credentialsLock{ m_credentialMutex };
m_cvarCredentialsProvider = Aws::MakeShared<Aws::Auth::SimpleAWSCredentialsProvider>(
AWSCVARCREDENTIALHANDLER_ALLOC_TAG, accessKey.c_str(), secretKey.c_str());
return m_cvarCredentialsProvider;
@@ -52,7 +51,7 @@ namespace AWSCore
void AWSCVarCredentialHandler::ResetCredentialsProvider()
{
// Must reset credential provider after AWSNativeSDKs init or before AWSNativeSDKs shutdown
AZStd::lock_guard<AZStd::mutex> credentialsLock{m_credentialMutex};
AZStd::lock_guard<AZStd::mutex> credentialsLock{ m_credentialMutex };
m_cvarCredentialsProvider.reset();
}
} // namespace AWSCore
@@ -78,7 +78,7 @@ namespace AWSCore
void AWSCoreEditorMenu::InitializeResourceMappingToolAction()
{
#ifdef AWSCORE_EDITOR_RESOURCE_MAPPING_TOOL_ENABLED
#if AWSCORE_EDITOR_RESOURCE_MAPPING_TOOL_ENABLED
AWSCoreResourceMappingToolAction* resourceMappingTool =
new AWSCoreResourceMappingToolAction(QObject::tr(AWSResourceMappingToolActionText), this);
QObject::connect(resourceMappingTool, &QAction::triggered, this,
@@ -197,7 +197,7 @@ namespace AWSCore
subMenu->addAction(AddExternalLinkAction(
AWSMetricsAdvancedTopicsActionText, AWSMetricsAdvancedTopicsUrl, ":/Notifications/link.svg"));
AZStd::string priorAlias = AZ::IO::FileIOBase::GetInstance()->GetAlias("@devroot@");
AZStd::string priorAlias = AZ::IO::FileIOBase::GetInstance()->GetAlias("@engroot@");
AZStd::string configFilePath = priorAlias + "\\Gems\\AWSMetrics\\Code\\" + AZ::SettingsRegistryInterface::RegistryFolder;
AzFramework::StringFunc::Path::Normalize(configFilePath);
@@ -12,16 +12,6 @@
#include <AWSCoreBus.h>
#include <Credential/AWSCredentialBus.h>
// The AWS Native SDK AWSAllocator triggers a warning due to accessing members of std::allocator directly.
// AWSAllocator.h(70): warning C4996: 'std::allocator<T>::pointer': warning STL4010: Various members of std::allocator are deprecated in C++17.
// Use std::allocator_traits instead of accessing these members directly.
// You can define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
AZ_PUSH_DISABLE_WARNING(4251 4996, "-Wunknown-warning-option")
#include <aws/core/client/ClientConfiguration.h>
AZ_POP_DISABLE_WARNING
namespace AWSCore
{
void AwsApiJobConfig::ApplySettings()
@@ -11,6 +11,7 @@
#include <AzCore/Jobs/JobManagerBus.h>
#include <AzCore/Jobs/JobCancelGroup.h>
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
@@ -60,7 +60,7 @@ public:
m_normalizedSourceProjectFolder.c_str(), AZ::SettingsRegistryInterface::RegistryFolder);
AzFramework::StringFunc::Path::Normalize(m_normalizedSetRegFolderPath);
m_localFileIO->SetAlias("@devassets@", m_normalizedSourceProjectFolder.c_str());
m_localFileIO->SetAlias("@projectroot@", m_normalizedSourceProjectFolder.c_str());
CreateTestSetRegFile(TEST_VALID_RESOURCE_MAPPING_SETREG);
}
@@ -122,7 +122,7 @@ private:
TEST_F(AWSCoreConfigurationTest, InitConfig_NoSourceProjectFolderFound_ReturnEmptyConfigFilePath)
{
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
m_localFileIO->ClearAlias("@devassets@");
m_localFileIO->ClearAlias("@projectroot@");
AZ_TEST_START_TRACE_SUPPRESSION;
m_awsCoreConfiguration->InitConfig();
@@ -154,7 +154,7 @@ TEST_F(AWSCoreConfigurationTest, InitConfig_LoadValidSettingsRegistry_ReturnNonE
TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_NoSourceProjectFolderFound_ReturnEmptyConfigFilePath)
{
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
m_localFileIO->ClearAlias("@devassets@");
m_localFileIO->ClearAlias("@projectroot@");
m_awsCoreConfiguration->ReloadConfiguration();
auto actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
@@ -6,6 +6,7 @@
*
*/
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
@@ -1,19 +0,0 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set(FILES
../../AWSCoreEditorSystemComponentTest.cpp
../../Attribution/AWSCoreAttributionManagerTest.cpp
../../Attribution/AWSCoreAttributionMetricTest.cpp
../../Attribution/AWSCoreAttributionSystemComponentTest.cpp
../../Attribution/AWSAttributionServiceApiTest.cpp
../../UI/AWSCoreEditorMenuTest.cpp
../../UI/AWSCoreEditorUIFixture.h
../../UI/AWSCoreResourceMappingToolActionTest.cpp
../../AWSCoreEditorManagerTest.cpp
)
@@ -32,7 +32,7 @@ class AWSCoreEditorMenuTest
{
AWSCoreEditorUIFixture::SetUp();
AWSCoreFixture::SetUp();
m_localFileIO->SetAlias("@devroot@", "dummy engine root");
m_localFileIO->SetAlias("@engroot@", "dummy engine root");
}
void TearDown() override
@@ -0,0 +1,29 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzFramework/Matchmaking/MatchmakingRequests.h>
namespace AWSGameLift
{
//! AWSGameLiftAcceptMatchRequest
//! GameLift accept match request which corresponds to Amazon GameLift
//! Registers a player's acceptance or rejection of a proposed FlexMatch match.
//! AcceptMatchRequest
struct AWSGameLiftAcceptMatchRequest
: public AzFramework::AcceptMatchRequest
{
public:
AZ_RTTI(AWSGameLiftAcceptMatchRequest, "{8372B297-88E8-4C13-B31D-BE87236CA416}", AzFramework::AcceptMatchRequest);
static void Reflect(AZ::ReflectContext* context);
AWSGameLiftAcceptMatchRequest() = default;
virtual ~AWSGameLiftAcceptMatchRequest() = default;
};
} // namespace AWSGameLift
@@ -8,7 +8,7 @@
#pragma once
#include <AzFramework/Session/ISessionRequests.h>
#include <AzFramework/Session/SessionRequests.h>
namespace AWSGameLift
{
@@ -8,7 +8,7 @@
#pragma once
#include <AzFramework/Session/ISessionRequests.h>
#include <AzFramework/Session/SessionRequests.h>
namespace AWSGameLift
{
@@ -8,7 +8,7 @@
#pragma once
#include <AzFramework/Session/ISessionRequests.h>
#include <AzFramework/Session/SessionRequests.h>
namespace AWSGameLift
{
@@ -8,7 +8,7 @@
#pragma once
#include <AzFramework/Session/ISessionRequests.h>
#include <AzFramework/Session/SessionRequests.h>
namespace AWSGameLift
{
@@ -0,0 +1,59 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzFramework/Matchmaking/MatchmakingRequests.h>
namespace AWSGameLift
{
//! AWSGameLiftPlayerInformation
//! Information on each player to be matched
//! This information must include a player ID, and may contain player attributes and latency data to be used in the matchmaking process
//! After a successful match, Player objects contain the name of the team the player is assigned to
struct AWSGameLiftPlayerInformation
{
AZ_RTTI(AWSGameLiftPlayerInformation, "{B62C118E-C55D-4903-8ECB-E58E8CA613C4}");
static void Reflect(AZ::ReflectContext* context);
AWSGameLiftPlayerInformation() = default;
virtual ~AWSGameLiftPlayerInformation() = default;
// A map of region names to latencies in millseconds, that indicates
// the amount of latency that a player experiences when connected to AWS Regions
AZStd::unordered_map<AZStd::string, int> m_latencyInMs;
// A collection of key:value pairs containing player information for use in matchmaking
// Player attribute keys must match the playerAttributes used in a matchmaking rule set
// Example: {"skill": "{\"N\": \"23\"}", "gameMode": "{\"S\": \"deathmatch\"}"}
AZStd::unordered_map<AZStd::string, AZStd::string> m_playerAttributes;
// A unique identifier for a player
AZStd::string m_playerId;
// Name of the team that the player is assigned to in a match
AZStd::string m_team;
};
//! AWSGameLiftStartMatchmakingRequest
//! GameLift start matchmaking request which corresponds to Amazon GameLift
//! Uses FlexMatch to create a game match for a group of players based on custom matchmaking rules
//! StartMatchmakingRequest
struct AWSGameLiftStartMatchmakingRequest
: public AzFramework::StartMatchmakingRequest
{
public:
AZ_RTTI(AWSGameLiftStartMatchmakingRequest, "{D273DF71-9C55-48C1-95F9-8D7B66B9CF3E}", AzFramework::StartMatchmakingRequest);
static void Reflect(AZ::ReflectContext* context);
AWSGameLiftStartMatchmakingRequest() = default;
virtual ~AWSGameLiftStartMatchmakingRequest() = default;
// Name of the matchmaking configuration to use for this request
AZStd::string m_configurationName;
// Information on each player to be matched
AZStd::vector<AWSGameLiftPlayerInformation> m_players;
};
} // namespace AWSGameLift
@@ -0,0 +1,29 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzFramework/Matchmaking/MatchmakingRequests.h>
namespace AWSGameLift
{
//! AWSGameLiftStopMatchmakingRequest
//! GameLift stop matchmaking request which corresponds to Amazon GameLift
//! Cancels a matchmaking ticket or match backfill ticket that is currently being processed.
//! StopMatchmakingRequest
struct AWSGameLiftStopMatchmakingRequest
: public AzFramework::StopMatchmakingRequest
{
public:
AZ_RTTI(AWSGameLiftStopMatchmakingRequest, "{2766BC03-9F84-4346-A52B-49129BBAF38B}", AzFramework::StopMatchmakingRequest);
static void Reflect(AZ::ReflectContext* context);
AWSGameLiftStopMatchmakingRequest() = default;
virtual ~AWSGameLiftStopMatchmakingRequest() = default;
};
} // namespace AWSGameLift
@@ -11,6 +11,7 @@
#include <AzCore/EBus/EBus.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/std/string/string.h>
#include <AzFramework/Matchmaking/IMatchmakingRequests.h>
#include <AzFramework/Session/ISessionRequests.h>
namespace AWSGameLift
@@ -71,4 +72,26 @@ namespace AWSGameLift
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
};
using AWSGameLiftSessionRequestBus = AZ::EBus<AzFramework::ISessionRequests, AWSGameLiftSessionRequests>;
// IMatchmakingAsyncRequests EBus wrapper for scripting
class AWSGameLiftMatchmakingAsyncRequests
: public AZ::EBusTraits
{
public:
using MutexType = AZStd::recursive_mutex;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
};
using AWSGameLiftMatchmakingAsyncRequestBus = AZ::EBus<AzFramework::IMatchmakingAsyncRequests, AWSGameLiftMatchmakingAsyncRequests>;
// IMatchmakingRequests EBus wrapper for scripting
class AWSGameLiftMatchmakingRequests
: public AZ::EBusTraits
{
public:
using MutexType = AZStd::recursive_mutex;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
};
using AWSGameLiftMatchmakingRequestBus = AZ::EBus<AzFramework::IMatchmakingRequests, AWSGameLiftMatchmakingRequests>;
} // namespace AWSGameLift
@@ -0,0 +1,169 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/Interface/Interface.h>
#include <AzCore/std/bind/bind.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <AzFramework/Session/ISessionHandlingRequests.h>
#include <AWSGameLiftClientLocalTicketTracker.h>
#include <AWSGameLiftSessionConstants.h>
#include <Request/IAWSGameLiftInternalRequests.h>
#include <aws/core/utils/Outcome.h>
#include <aws/gamelift/GameLiftClient.h>
#include <aws/gamelift/model/DescribeMatchmakingRequest.h>
namespace AWSGameLift
{
AWSGameLiftClientLocalTicketTracker::AWSGameLiftClientLocalTicketTracker()
: m_status(TicketTrackerStatus::Idle)
, m_pollingPeriodInMS(AWSGameLiftClientDefaultPollingPeriodInMS)
{
}
void AWSGameLiftClientLocalTicketTracker::ActivateTracker()
{
AZ::Interface<IAWSGameLiftMatchmakingInternalRequests>::Register(this);
}
void AWSGameLiftClientLocalTicketTracker::DeactivateTracker()
{
AZ::Interface<IAWSGameLiftMatchmakingInternalRequests>::Unregister(this);
StopPolling();
}
void AWSGameLiftClientLocalTicketTracker::StartPolling(
const AZStd::string& ticketId, const AZStd::string& playerId)
{
AZStd::lock_guard<AZStd::mutex> lock(m_trackerMutex);
if (m_status == TicketTrackerStatus::Running)
{
AZ_TracePrintf(AWSGameLiftClientLocalTicketTrackerName, "Matchmaking ticket tracker is running.");
return;
}
m_status = TicketTrackerStatus::Running;
m_trackerThread = AZStd::thread(AZStd::bind(
&AWSGameLiftClientLocalTicketTracker::ProcessPolling, this, ticketId, playerId));
}
void AWSGameLiftClientLocalTicketTracker::StopPolling()
{
AZStd::lock_guard<AZStd::mutex> lock(m_trackerMutex);
m_status = TicketTrackerStatus::Idle;
if (m_trackerThread.joinable())
{
m_trackerThread.join();
}
}
void AWSGameLiftClientLocalTicketTracker::ProcessPolling(
const AZStd::string& ticketId, const AZStd::string& playerId)
{
while (m_status == TicketTrackerStatus::Running)
{
auto gameliftClient = AZ::Interface<IAWSGameLiftInternalRequests>::Get()->GetGameLiftClient();
if (gameliftClient)
{
Aws::GameLift::Model::DescribeMatchmakingRequest request;
request.AddTicketIds(ticketId.c_str());
auto describeMatchmakingOutcome = gameliftClient->DescribeMatchmaking(request);
if (describeMatchmakingOutcome.IsSuccess())
{
if (describeMatchmakingOutcome.GetResult().GetTicketList().size() == 1)
{
auto ticket = describeMatchmakingOutcome.GetResult().GetTicketList().front();
if (ticket.GetStatus() == Aws::GameLift::Model::MatchmakingConfigurationStatus::COMPLETED)
{
m_status = TicketTrackerStatus::Idle;
AZ_TracePrintf(AWSGameLiftClientLocalTicketTrackerName,
"Matchmaking ticket %s is complete.", ticket.GetTicketId().c_str());
RequestPlayerJoinMatch(ticket, playerId);
return;
}
else if (ticket.GetStatus() == Aws::GameLift::Model::MatchmakingConfigurationStatus::TIMED_OUT ||
ticket.GetStatus() == Aws::GameLift::Model::MatchmakingConfigurationStatus::FAILED ||
ticket.GetStatus() == Aws::GameLift::Model::MatchmakingConfigurationStatus::CANCELLED)
{
m_status = TicketTrackerStatus::Idle;
AZ_Error(AWSGameLiftClientLocalTicketTrackerName, false, "Matchmaking ticket %s is not complete, %s",
ticket.GetTicketId().c_str(), ticket.GetStatusReason().c_str());
return;
}
else if (ticket.GetStatus() == Aws::GameLift::Model::MatchmakingConfigurationStatus::REQUIRES_ACCEPTANCE)
{
// broadcast acceptance requires to player
}
else
{
AZ_TracePrintf(AWSGameLiftClientLocalTicketTrackerName, "Matchmaking ticket %s is processing, %s.",
ticket.GetTicketId().c_str(), ticket.GetStatusReason().c_str());
}
}
else
{
AZ_Error(AWSGameLiftClientLocalTicketTrackerName, false, "Unable to find expected ticket with id %s", ticketId.c_str());
}
}
else
{
AZ_Error(AWSGameLiftClientLocalTicketTrackerName, false, AWSGameLiftErrorMessageTemplate,
describeMatchmakingOutcome.GetError().GetExceptionName().c_str(),
describeMatchmakingOutcome.GetError().GetMessage().c_str());
}
}
else
{
AZ_Error(AWSGameLiftClientLocalTicketTrackerName, false, AWSGameLiftClientMissingErrorMessage);
}
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(m_pollingPeriodInMS));
}
}
void AWSGameLiftClientLocalTicketTracker::RequestPlayerJoinMatch(
const Aws::GameLift::Model::MatchmakingTicket& ticket, const AZStd::string& playerId)
{
auto connectionInfo = ticket.GetGameSessionConnectionInfo();
AzFramework::SessionConnectionConfig sessionConnectionConfig;
sessionConnectionConfig.m_ipAddress = connectionInfo.GetIpAddress().c_str();
for (auto matchedPlayer : connectionInfo.GetMatchedPlayerSessions())
{
if (playerId.compare(matchedPlayer.GetPlayerId().c_str()) == 0)
{
sessionConnectionConfig.m_playerSessionId = matchedPlayer.GetPlayerSessionId().c_str();
break;
}
}
sessionConnectionConfig.m_port = static_cast<uint16_t>(connectionInfo.GetPort());
if (!sessionConnectionConfig.m_playerSessionId.empty())
{
AZ_TracePrintf(AWSGameLiftClientLocalTicketTrackerName,
"Requesting and validating player session %s to connect to the match ...",
sessionConnectionConfig.m_playerSessionId.c_str());
bool result =
AZ::Interface<AzFramework::ISessionHandlingClientRequests>::Get()->RequestPlayerJoinSession(sessionConnectionConfig);
if (result)
{
AZ_TracePrintf(AWSGameLiftClientLocalTicketTrackerName,
"Started connection process, and connection validation is in process.");
}
else
{
AZ_Error(AWSGameLiftClientLocalTicketTrackerName, false,
"Failed to start connection process.");
}
}
else
{
AZ_Error(AWSGameLiftClientLocalTicketTrackerName, false,
"Player session id is missing for player % to join the match.", playerId.c_str());
}
}
}
@@ -0,0 +1,62 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/std/parallel/mutex.h>
#include <AzCore/std/parallel/thread.h>
#include <Request/IAWSGameLiftMatchmakingInternalRequests.h>
#include <aws/gamelift/model/MatchmakingTicket.h>
namespace AWSGameLift
{
enum TicketTrackerStatus
{
Idle,
Running
};
//! AWSGameLiftClientLocalTicketTracker
//! GameLift client ticket tracker to describe submitted matchmaking ticket periodically,
//! and join player to the match once matchmaking ticket is complete.
//! For use in production, please see GameLifts guidance about matchmaking at volume.
//! The continuous polling approach here is only suitable for low volume matchmaking and is meant to aid with development only
class AWSGameLiftClientLocalTicketTracker
: public IAWSGameLiftMatchmakingInternalRequests
{
public:
static constexpr const char AWSGameLiftClientLocalTicketTrackerName[] = "AWSGameLiftClientLocalTicketTracker";
// Set ticket polling period to 10 seconds
// https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-client.html#match-client-track
static constexpr const uint64_t AWSGameLiftClientDefaultPollingPeriodInMS = 10000;
AWSGameLiftClientLocalTicketTracker();
virtual ~AWSGameLiftClientLocalTicketTracker() = default;
virtual void ActivateTracker();
virtual void DeactivateTracker();
// IAWSGameLiftMatchmakingInternalRequests interface implementation
void StartPolling(const AZStd::string& ticketId, const AZStd::string& playerId) override;
void StopPolling() override;
protected:
// For testing friendly access
uint64_t m_pollingPeriodInMS;
TicketTrackerStatus m_status;
private:
void ProcessPolling(const AZStd::string& ticketId, const AZStd::string& playerId);
void RequestPlayerJoinMatch(const Aws::GameLift::Model::MatchmakingTicket& ticket, const AZStd::string& playerId);
AZStd::mutex m_trackerMutex;
AZStd::thread m_trackerThread;
};
} // namespace AWSGameLift
@@ -17,11 +17,13 @@
#include <ResourceMapping/AWSResourceMappingBus.h>
#include <AWSGameLiftClientManager.h>
#include <AWSGameLiftSessionConstants.h>
#include <Activity/AWSGameLiftCreateSessionActivity.h>
#include <Activity/AWSGameLiftCreateSessionOnQueueActivity.h>
#include <Activity/AWSGameLiftJoinSessionActivity.h>
#include <Activity/AWSGameLiftLeaveSessionActivity.h>
#include <Activity/AWSGameLiftSearchSessionsActivity.h>
#include <Request/IAWSGameLiftInternalRequests.h>
#include <aws/core/auth/AWSCredentialsProvider.h>
@@ -31,11 +33,6 @@ namespace AWSGameLift
AZ_CVAR(AZ::CVarFixedString, cl_gameliftLocalEndpoint, "", nullptr, AZ::ConsoleFunctorFlags::Null, "The local endpoint to test with GameLiftLocal SDK.");
#endif
AWSGameLiftClientManager::AWSGameLiftClientManager()
{
m_gameliftClient.reset();
}
void AWSGameLiftClientManager::ActivateManager()
{
AZ::Interface<IAWSGameLiftRequests>::Register(this);
@@ -62,8 +59,7 @@ namespace AWSGameLift
bool AWSGameLiftClientManager::ConfigureGameLiftClient(const AZStd::string& region)
{
m_gameliftClient.reset();
AZ::Interface<IAWSGameLiftInternalRequests>::Get()->SetGameLiftClient(nullptr);
Aws::Client::ClientConfiguration clientConfig;
// Set up client endpoint or region
AZStd::string localEndpoint = "";
@@ -103,7 +99,8 @@ namespace AWSGameLift
AZ_Error(AWSGameLiftClientManagerName, false, AWSGameLiftClientCredentialMissingErrorMessage);
return false;
}
m_gameliftClient = AZStd::make_shared<Aws::GameLift::GameLiftClient>(credentialResult.result, clientConfig);
AZ::Interface<IAWSGameLiftInternalRequests>::Get()->SetGameLiftClient(
AZStd::make_shared<Aws::GameLift::GameLiftClient>(credentialResult.result, clientConfig));
return true;
}
@@ -112,6 +109,16 @@ namespace AWSGameLift
return AZ::Uuid::CreateRandom().ToString<AZStd::string>(includeBrackets, includeDashes);
}
void AWSGameLiftClientManager::AcceptMatch(const AzFramework::AcceptMatchRequest& acceptMatchRequest)
{
AZ_UNUSED(acceptMatchRequest);
}
void AWSGameLiftClientManager::AcceptMatchAsync(const AzFramework::AcceptMatchRequest& acceptMatchRequest)
{
AZ_UNUSED(acceptMatchRequest);
}
AZStd::string AWSGameLiftClientManager::CreateSession(const AzFramework::CreateSessionRequest& createSessionRequest)
{
AZStd::string result = "";
@@ -184,15 +191,15 @@ namespace AWSGameLift
AZStd::string AWSGameLiftClientManager::CreateSessionHelper(
const AWSGameLiftCreateSessionRequest& createSessionRequest)
{
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameLiftClient = m_gameliftClient;
auto gameliftClient = AZ::Interface<IAWSGameLiftInternalRequests>::Get()->GetGameLiftClient();
AZStd::string result = "";
if (!gameLiftClient)
if (!gameliftClient)
{
AZ_Error(AWSGameLiftClientManagerName, false, AWSGameLiftClientMissingErrorMessage);
}
else
{
result = CreateSessionActivity::CreateSession(*gameLiftClient, createSessionRequest);
result = CreateSessionActivity::CreateSession(*gameliftClient, createSessionRequest);
}
return result;
}
@@ -200,7 +207,7 @@ namespace AWSGameLift
AZStd::string AWSGameLiftClientManager::CreateSessionOnQueueHelper(
const AWSGameLiftCreateSessionOnQueueRequest& createSessionOnQueueRequest)
{
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient = m_gameliftClient;
auto gameliftClient = AZ::Interface<IAWSGameLiftInternalRequests>::Get()->GetGameLiftClient();
AZStd::string result;
if (!gameliftClient)
{
@@ -255,7 +262,7 @@ namespace AWSGameLift
bool AWSGameLiftClientManager::JoinSessionHelper(const AWSGameLiftJoinSessionRequest& joinSessionRequest)
{
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient = m_gameliftClient;
auto gameliftClient = AZ::Interface<IAWSGameLiftInternalRequests>::Get()->GetGameLiftClient();
bool result = false;
if (!gameliftClient)
{
@@ -335,8 +342,7 @@ namespace AWSGameLift
AzFramework::SearchSessionsResponse AWSGameLiftClientManager::SearchSessionsHelper(
const AWSGameLiftSearchSessionsRequest& searchSessionsRequest) const
{
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient = m_gameliftClient;
auto gameliftClient = AZ::Interface<IAWSGameLiftInternalRequests>::Get()->GetGameLiftClient();
AzFramework::SearchSessionsResponse response;
if (!gameliftClient)
{
@@ -349,8 +355,25 @@ namespace AWSGameLift
return response;
}
void AWSGameLiftClientManager::SetGameLiftClient(AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient)
AZStd::string AWSGameLiftClientManager::StartMatchmaking(const AzFramework::StartMatchmakingRequest& startMatchmakingRequest)
{
m_gameliftClient.swap(gameliftClient);
AZ_UNUSED(startMatchmakingRequest);
return AZStd::string{};
}
void AWSGameLiftClientManager::StartMatchmakingAsync(const AzFramework::StartMatchmakingRequest& startMatchmakingRequest)
{
AZ_UNUSED(startMatchmakingRequest);
}
void AWSGameLiftClientManager::StopMatchmaking(const AzFramework::StopMatchmakingRequest& stopMatchmakingRequest)
{
AZ_UNUSED(stopMatchmakingRequest);
}
void AWSGameLiftClientManager::StopMatchmakingAsync(const AzFramework::StopMatchmakingRequest& stopMatchmakingRequest)
{
AZ_UNUSED(stopMatchmakingRequest);
}
} // namespace AWSGameLift
@@ -9,15 +9,9 @@
#pragma once
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <Request/IAWSGameLiftRequests.h>
#include <AzFramework/Matchmaking/MatchmakingNotifications.h>
namespace Aws
{
namespace GameLift
{
class GameLiftClient;
}
}
#include <Request/IAWSGameLiftRequests.h>
namespace AWSGameLift
{
@@ -26,6 +20,54 @@ namespace AWSGameLift
struct AWSGameLiftJoinSessionRequest;
struct AWSGameLiftSearchSessionsRequest;
// MatchAcceptanceNotificationBus EBus handler for scripting
class AWSGameLiftMatchAcceptanceNotificationBusHandler
: public AzFramework::MatchAcceptanceNotificationBus::Handler
, public AZ::BehaviorEBusHandler
{
public:
AZ_EBUS_BEHAVIOR_BINDER(
AWSGameLiftMatchAcceptanceNotificationBusHandler,
"{CBE057D3-F5CE-46D3-B02D-8A6A1446B169}",
AZ::SystemAllocator,
OnMatchAcceptance);
void OnMatchAcceptance() override
{
Call(FN_OnMatchAcceptance);
}
};
// MatchmakingAsyncRequestNotificationBus EBus handler for scripting
class AWSGameLiftMatchmakingAsyncRequestNotificationBusHandler
: public AzFramework::MatchmakingAsyncRequestNotificationBus::Handler
, public AZ::BehaviorEBusHandler
{
public:
AZ_EBUS_BEHAVIOR_BINDER(
AWSGameLiftMatchmakingAsyncRequestNotificationBusHandler,
"{2045EE8F-2AB7-4ED0-9614-3496A1A43677}",
AZ::SystemAllocator,
OnAcceptMatchAsyncComplete,
OnStartMatchmakingAsyncComplete,
OnStopMatchmakingAsyncComplete);
void OnAcceptMatchAsyncComplete() override
{
Call(FN_OnAcceptMatchAsyncComplete);
}
void OnStartMatchmakingAsyncComplete(const AZStd::string& matchmakingTicketId) override
{
Call(FN_OnStartMatchmakingAsyncComplete, matchmakingTicketId);
}
void OnStopMatchmakingAsyncComplete() override
{
Call(FN_OnStopMatchmakingAsyncComplete);
}
};
// SessionAsyncRequestNotificationBus EBus handler for scripting
class AWSGameLiftSessionAsyncRequestNotificationBusHandler
: public AzFramework::SessionAsyncRequestNotificationBus::Handler
@@ -66,6 +108,8 @@ namespace AWSGameLift
//! GameLift client manager to support game and player session related client requests
class AWSGameLiftClientManager
: public AWSGameLiftRequestBus::Handler
, public AWSGameLiftMatchmakingAsyncRequestBus::Handler
, public AWSGameLiftMatchmakingRequestBus::Handler
, public AWSGameLiftSessionAsyncRequestBus::Handler
, public AWSGameLiftSessionRequestBus::Handler
{
@@ -75,13 +119,11 @@ namespace AWSGameLift
"Missing AWS region for GameLift client.";
static constexpr const char AWSGameLiftClientCredentialMissingErrorMessage[] =
"Missing AWS credential for GameLift client.";
static constexpr const char AWSGameLiftClientMissingErrorMessage[] =
"GameLift client is not configured yet.";
static constexpr const char AWSGameLiftCreateSessionRequestInvalidErrorMessage[] =
"Invalid GameLift CreateSession or CreateSessionOnQueue request.";
AWSGameLiftClientManager();
AWSGameLiftClientManager() = default;
virtual ~AWSGameLiftClientManager() = default;
virtual void ActivateManager();
@@ -91,28 +133,32 @@ namespace AWSGameLift
bool ConfigureGameLiftClient(const AZStd::string& region) override;
AZStd::string CreatePlayerId(bool includeBrackets, bool includeDashes) override;
// AWSGameLiftMatchmakingAsyncRequestBus interface implementation
void AcceptMatchAsync(const AzFramework::AcceptMatchRequest& acceptMatchRequest) override;
void StartMatchmakingAsync(const AzFramework::StartMatchmakingRequest& startMatchmakingRequest) override;
void StopMatchmakingAsync(const AzFramework::StopMatchmakingRequest& stopMatchmakingRequest) override;
// AWSGameLiftSessionAsyncRequestBus interface implementation
void CreateSessionAsync(const AzFramework::CreateSessionRequest& createSessionRequest) override;
void JoinSessionAsync(const AzFramework::JoinSessionRequest& joinSessionRequest) override;
void SearchSessionsAsync(const AzFramework::SearchSessionsRequest& searchSessionsRequest) const override;
void LeaveSessionAsync() override;
// AWSGameLiftMatchmakingRequestBus interface implementation
void AcceptMatch(const AzFramework::AcceptMatchRequest& acceptMatchRequest) override;
AZStd::string StartMatchmaking(const AzFramework::StartMatchmakingRequest& startMatchmakingRequest) override;
void StopMatchmaking(const AzFramework::StopMatchmakingRequest& stopMatchmakingRequest) override;
// AWSGameLiftSessionRequestBus interface implementation
AZStd::string CreateSession(const AzFramework::CreateSessionRequest& createSessionRequest) override;
bool JoinSession(const AzFramework::JoinSessionRequest& joinSessionRequest) override;
AzFramework::SearchSessionsResponse SearchSessions(const AzFramework::SearchSessionsRequest& searchSessionsRequest) const override;
void LeaveSession() override;
protected:
// Use for automation tests only to inject mock objects.
void SetGameLiftClient(AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient);
private:
AZStd::string CreateSessionHelper(const AWSGameLiftCreateSessionRequest& createSessionRequest);
AZStd::string CreateSessionOnQueueHelper(const AWSGameLiftCreateSessionOnQueueRequest& createSessionOnQueueRequest);
bool JoinSessionHelper(const AWSGameLiftJoinSessionRequest& joinSessionRequest);
AzFramework::SearchSessionsResponse SearchSessionsHelper(const AWSGameLiftSearchSessionsRequest& searchSessionsRequest) const;
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> m_gameliftClient;
};
} // namespace AWSGameLift
@@ -6,6 +6,7 @@
*
*/
#include <AzCore/Interface/Interface.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/EditContextConstants.inl>
@@ -13,10 +14,13 @@
#include <AWSGameLiftClientManager.h>
#include <AWSGameLiftClientSystemComponent.h>
#include <Request/AWSGameLiftAcceptMatchRequest.h>
#include <Request/AWSGameLiftCreateSessionOnQueueRequest.h>
#include <Request/AWSGameLiftCreateSessionRequest.h>
#include <Request/AWSGameLiftJoinSessionRequest.h>
#include <Request/AWSGameLiftSearchSessionsRequest.h>
#include <Request/AWSGameLiftStartMatchmakingRequest.h>
#include <Request/AWSGameLiftStopMatchmakingRequest.h>
#include <aws/gamelift/GameLiftClient.h>
@@ -24,23 +28,19 @@ namespace AWSGameLift
{
AWSGameLiftClientSystemComponent::AWSGameLiftClientSystemComponent()
{
m_gameliftClientManager = AZStd::make_unique<AWSGameLiftClientManager>();
m_gameliftManager = AZStd::make_unique<AWSGameLiftClientManager>();
m_gameliftTicketTracker = AZStd::make_unique<AWSGameLiftClientLocalTicketTracker>();
}
void AWSGameLiftClientSystemComponent::Reflect(AZ::ReflectContext* context)
{
ReflectCreateSessionRequest(context);
AWSGameLiftCreateSessionOnQueueRequest::Reflect(context);
AWSGameLiftCreateSessionRequest::Reflect(context);
AWSGameLiftJoinSessionRequest::Reflect(context);
AWSGameLiftSearchSessionsRequest::Reflect(context);
ReflectSearchSessionsResponse(context);
ReflectGameLiftMatchmaking(context);
ReflectGameLiftSession(context);
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<AWSGameLiftClientSystemComponent, AZ::Component>()
->Version(0)
;
->Version(1);
if (AZ::EditContext* editContext = serialize->GetEditContext())
{
@@ -50,8 +50,7 @@ namespace AWSGameLift
"Create the GameLift client manager that handles communication between game clients and the GameLift service.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
->Attribute(AZ::Edit::Attributes::AutoExpand, true);
}
}
@@ -63,33 +62,7 @@ namespace AWSGameLift
{{{"Region", ""}}})
->Event("CreatePlayerId", &AWSGameLiftRequestBus::Events::CreatePlayerId,
{{{"IncludeBrackets", ""},
{"IncludeDashes", ""}}})
;
behaviorContext->EBus<AWSGameLiftSessionAsyncRequestBus>("AWSGameLiftSessionAsyncRequestBus")
->Attribute(AZ::Script::Attributes::Category, "AWSGameLift")
->Event("CreateSessionAsync", &AWSGameLiftSessionAsyncRequestBus::Events::CreateSessionAsync,
{{{"CreateSessionRequest", ""}}})
->Event("JoinSessionAsync", &AWSGameLiftSessionAsyncRequestBus::Events::JoinSessionAsync,
{{{"JoinSessionRequest", ""}}})
->Event("SearchSessionsAsync", &AWSGameLiftSessionAsyncRequestBus::Events::SearchSessionsAsync,
{{{"SearchSessionsRequest", ""}}})
->Event("LeaveSessionAsync", &AWSGameLiftSessionAsyncRequestBus::Events::LeaveSessionAsync)
;
behaviorContext
->EBus<AzFramework::SessionAsyncRequestNotificationBus>("AWSGameLiftSessionAsyncRequestNotificationBus")
->Attribute(AZ::Script::Attributes::Category, "AWSGameLift")
->Handler<AWSGameLiftSessionAsyncRequestNotificationBusHandler>()
;
behaviorContext->EBus<AWSGameLiftSessionRequestBus>("AWSGameLiftSessionRequestBus")
->Attribute(AZ::Script::Attributes::Category, "AWSGameLift")
->Event("CreateSession", &AWSGameLiftSessionRequestBus::Events::CreateSession,
{{{"CreateSessionRequest", ""}}})
->Event("JoinSession", &AWSGameLiftSessionRequestBus::Events::JoinSession,
{{{"JoinSessionRequest", ""}}})
->Event("SearchSessions", &AWSGameLiftSessionRequestBus::Events::SearchSessions,
{{{"SearchSessionsRequest", ""}}})
->Event("LeaveSession", &AWSGameLiftSessionRequestBus::Events::LeaveSession)
;
{"IncludeDashes", ""}}});
}
}
@@ -119,12 +92,88 @@ namespace AWSGameLift
void AWSGameLiftClientSystemComponent::Activate()
{
m_gameliftClientManager->ActivateManager();
AZ::Interface<IAWSGameLiftInternalRequests>::Register(this);
m_gameliftClient.reset();
m_gameliftManager->ActivateManager();
m_gameliftTicketTracker->ActivateTracker();
}
void AWSGameLiftClientSystemComponent::Deactivate()
{
m_gameliftClientManager->DeactivateManager();
m_gameliftTicketTracker->DeactivateTracker();
m_gameliftManager->DeactivateManager();
m_gameliftClient.reset();
AZ::Interface<IAWSGameLiftInternalRequests>::Unregister(this);
}
void AWSGameLiftClientSystemComponent::ReflectGameLiftMatchmaking(AZ::ReflectContext* context)
{
AWSGameLiftAcceptMatchRequest::Reflect(context);
AWSGameLiftStartMatchmakingRequest::Reflect(context);
AWSGameLiftStopMatchmakingRequest::Reflect(context);
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<AWSGameLiftMatchmakingAsyncRequestBus>("AWSGameLiftMatchmakingAsyncRequestBus")
->Attribute(AZ::Script::Attributes::Category, "AWSGameLift")
->Event("AcceptMatchAsync", &AWSGameLiftMatchmakingAsyncRequestBus::Events::AcceptMatchAsync,
{ { { "AcceptMatchRequest", "" } } })
->Event("StartMatchmakingAsync", &AWSGameLiftMatchmakingAsyncRequestBus::Events::StartMatchmakingAsync,
{ { { "StartMatchmakingRequest", "" } } })
->Event("StopMatchmakingAsync", &AWSGameLiftMatchmakingAsyncRequestBus::Events::StopMatchmakingAsync,
{ { { "StopMatchmakingRequest", "" } } });
behaviorContext->EBus<AzFramework::MatchmakingAsyncRequestNotificationBus>("AWSGameLiftMatchmakingAsyncRequestNotificationBus")
->Attribute(AZ::Script::Attributes::Category, "AWSGameLift")
->Handler<AWSGameLiftMatchmakingAsyncRequestNotificationBusHandler>();
behaviorContext->EBus<AWSGameLiftMatchmakingRequestBus>("AWSGameLiftMatchmakingRequestBus")
->Attribute(AZ::Script::Attributes::Category, "AWSGameLift")
->Event("AcceptMatch", &AWSGameLiftMatchmakingRequestBus::Events::AcceptMatch, { { { "AcceptMatchRequest", "" } } })
->Event("StartMatchmaking", &AWSGameLiftMatchmakingRequestBus::Events::StartMatchmaking,
{ { { "StartMatchmakingRequest", "" } } })
->Event("StopMatchmaking", &AWSGameLiftMatchmakingRequestBus::Events::StopMatchmaking,
{ { { "StopMatchmakingRequest", "" } } });
behaviorContext->EBus<AzFramework::MatchAcceptanceNotificationBus>("AWSGameLiftMatchAcceptanceNotificationBus")
->Attribute(AZ::Script::Attributes::Category, "AWSGameLift")
->Handler<AWSGameLiftMatchAcceptanceNotificationBusHandler>();
}
}
void AWSGameLiftClientSystemComponent::ReflectGameLiftSession(AZ::ReflectContext* context)
{
ReflectCreateSessionRequest(context);
AWSGameLiftCreateSessionOnQueueRequest::Reflect(context);
AWSGameLiftCreateSessionRequest::Reflect(context);
AWSGameLiftJoinSessionRequest::Reflect(context);
AWSGameLiftSearchSessionsRequest::Reflect(context);
ReflectSearchSessionsResponse(context);
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<AWSGameLiftSessionAsyncRequestBus>("AWSGameLiftSessionAsyncRequestBus")
->Attribute(AZ::Script::Attributes::Category, "AWSGameLift")
->Event("CreateSessionAsync", &AWSGameLiftSessionAsyncRequestBus::Events::CreateSessionAsync,
{ { { "CreateSessionRequest", "" } } })
->Event("JoinSessionAsync", &AWSGameLiftSessionAsyncRequestBus::Events::JoinSessionAsync, { { { "JoinSessionRequest", "" } } })
->Event("SearchSessionsAsync", &AWSGameLiftSessionAsyncRequestBus::Events::SearchSessionsAsync,
{ { { "SearchSessionsRequest", "" } } })
->Event("LeaveSessionAsync", &AWSGameLiftSessionAsyncRequestBus::Events::LeaveSessionAsync);
behaviorContext->EBus<AzFramework::SessionAsyncRequestNotificationBus>("AWSGameLiftSessionAsyncRequestNotificationBus")
->Attribute(AZ::Script::Attributes::Category, "AWSGameLift")
->Handler<AWSGameLiftSessionAsyncRequestNotificationBusHandler>();
behaviorContext->EBus<AWSGameLiftSessionRequestBus>("AWSGameLiftSessionRequestBus")
->Attribute(AZ::Script::Attributes::Category, "AWSGameLift")
->Event("CreateSession", &AWSGameLiftSessionRequestBus::Events::CreateSession, { { { "CreateSessionRequest", "" } } })
->Event("JoinSession", &AWSGameLiftSessionRequestBus::Events::JoinSession, { { { "JoinSessionRequest", "" } } })
->Event("SearchSessions", &AWSGameLiftSessionRequestBus::Events::SearchSessions, { { { "SearchSessionsRequest", "" } } })
->Event("LeaveSession", &AWSGameLiftSessionRequestBus::Events::LeaveSession);
}
}
void AWSGameLiftClientSystemComponent::ReflectCreateSessionRequest(AZ::ReflectContext* context)
@@ -174,9 +223,25 @@ namespace AWSGameLift
}
}
void AWSGameLiftClientSystemComponent::SetGameLiftClientManager(AZStd::unique_ptr<AWSGameLiftClientManager> gameliftClientManager)
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> AWSGameLiftClientSystemComponent::GetGameLiftClient() const
{
m_gameliftClientManager.reset();
m_gameliftClientManager = AZStd::move(gameliftClientManager);
return m_gameliftClient;
}
void AWSGameLiftClientSystemComponent::SetGameLiftClient(AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient)
{
m_gameliftClient.swap(gameliftClient);
}
void AWSGameLiftClientSystemComponent::SetGameLiftClientManager(AZStd::unique_ptr<AWSGameLiftClientManager> gameliftManager)
{
m_gameliftManager.reset();
m_gameliftManager = AZStd::move(gameliftManager);
}
void AWSGameLiftClientSystemComponent::SetGameLiftClientTicketTracker(AZStd::unique_ptr<AWSGameLiftClientLocalTicketTracker> gameliftTicketTracker)
{
m_gameliftTicketTracker.reset();
m_gameliftTicketTracker = AZStd::move(gameliftTicketTracker);
}
} // namespace AWSGameLift
@@ -11,6 +11,9 @@
#include <AzCore/Component/Component.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <AWSGameLiftClientLocalTicketTracker.h>
#include <Request/IAWSGameLiftInternalRequests.h>
namespace AWSGameLift
{
class AWSGameLiftClientManager;
@@ -18,6 +21,7 @@ namespace AWSGameLift
//! Gem client system component. Responsible for creating the gamelift client manager.
class AWSGameLiftClientSystemComponent
: public AZ::Component
, public IAWSGameLiftInternalRequests
{
public:
AZ_COMPONENT(AWSGameLiftClientSystemComponent, "{d481c15c-732a-4eea-9853-4965ed1bc2be}");
@@ -32,6 +36,10 @@ namespace AWSGameLift
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
// IAWSGameLiftInternalRequests interface implementation
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> GetGameLiftClient() const override;
void SetGameLiftClient(AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient) override;
protected:
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
@@ -40,13 +48,19 @@ namespace AWSGameLift
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
void SetGameLiftClientManager(AZStd::unique_ptr<AWSGameLiftClientManager> gameliftClientManager);
void SetGameLiftClientManager(AZStd::unique_ptr<AWSGameLiftClientManager> gameliftManager);
void SetGameLiftClientTicketTracker(AZStd::unique_ptr<AWSGameLiftClientLocalTicketTracker> gameliftTicketTracker);
private:
static void ReflectGameLiftMatchmaking(AZ::ReflectContext* context);
static void ReflectGameLiftSession(AZ::ReflectContext* context);
static void ReflectCreateSessionRequest(AZ::ReflectContext* context);
static void ReflectSearchSessionsResponse(AZ::ReflectContext* context);
AZStd::unique_ptr<AWSGameLiftClientManager> m_gameliftClientManager;
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> m_gameliftClient;
AZStd::unique_ptr<AWSGameLiftClientManager> m_gameliftManager;
AZStd::unique_ptr<AWSGameLiftClientLocalTicketTracker> m_gameliftTicketTracker;
};
} // namespace AWSGameLift
@@ -0,0 +1,43 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <Request/AWSGameLiftAcceptMatchRequest.h>
namespace AWSGameLift
{
void AWSGameLiftAcceptMatchRequest::Reflect(AZ::ReflectContext* context)
{
AzFramework::AcceptMatchRequest::Reflect(context);
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<AWSGameLiftAcceptMatchRequest, AzFramework::AcceptMatchRequest>()
->Version(0);
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<AWSGameLiftAcceptMatchRequest>("AWSGameLiftAcceptMatchRequest", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly);
}
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->Class<AWSGameLiftAcceptMatchRequest>("AWSGameLiftAcceptMatchRequest")
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
->Property("AcceptMatch", BehaviorValueProperty(&AWSGameLiftAcceptMatchRequest::m_acceptMatch))
->Property("PlayerIds", BehaviorValueProperty(&AWSGameLiftAcceptMatchRequest::m_playerIds))
->Property("TicketId", BehaviorValueProperty(&AWSGameLiftAcceptMatchRequest::m_ticketId));
}
}
} // namespace AWSGameLift
@@ -6,11 +6,12 @@
*
*/
#include <Request/AWSGameLiftCreateSessionOnQueueRequest.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <Request/AWSGameLiftCreateSessionOnQueueRequest.h>
namespace AWSGameLift
{
void AWSGameLiftCreateSessionOnQueueRequest::Reflect(AZ::ReflectContext* context)
@@ -6,11 +6,12 @@
*
*/
#include <Request/AWSGameLiftCreateSessionRequest.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <Request/AWSGameLiftCreateSessionRequest.h>
namespace AWSGameLift
{
void AWSGameLiftCreateSessionRequest::Reflect(AZ::ReflectContext* context)
@@ -5,12 +5,12 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Request/AWSGameLiftJoinSessionRequest.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <Request/AWSGameLiftJoinSessionRequest.h>
namespace AWSGameLift
{
void AWSGameLiftJoinSessionRequest::Reflect(AZ::ReflectContext* context)
@@ -6,13 +6,14 @@
*
*/
#include <Request/AWSGameLiftSearchSessionsRequest.h>
#include <AWSGameLiftSessionConstants.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzFramework/Session/SessionConfig.h>
#include <Request/AWSGameLiftSearchSessionsRequest.h>
#include <AWSGameLiftSessionConstants.h>
namespace AWSGameLift
{
void AWSGameLiftSearchSessionsRequest::Reflect(AZ::ReflectContext* context)
@@ -0,0 +1,93 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <Request/AWSGameLiftStartMatchmakingRequest.h>
namespace AWSGameLift
{
void AWSGameLiftPlayerInformation::Reflect(AZ::ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<AWSGameLiftPlayerInformation>()
->Version(0)
->Field("latencyInMs", &AWSGameLiftPlayerInformation::m_latencyInMs)
->Field("playerAttributes", &AWSGameLiftPlayerInformation::m_playerAttributes)
->Field("playerId", &AWSGameLiftPlayerInformation::m_playerId)
->Field("team", &AWSGameLiftPlayerInformation::m_team);
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<AWSGameLiftPlayerInformation>("AWSGameLiftPlayerInformation", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
->DataElement(
AZ::Edit::UIHandlers::Default, &AWSGameLiftPlayerInformation::m_latencyInMs, "LatencyInMs",
"A set of values, expressed in milliseconds, that indicates the amount of latency that"
"a player experiences when connected to AWS Regions")
->DataElement(
AZ::Edit::UIHandlers::Default, &AWSGameLiftPlayerInformation::m_playerAttributes, "PlayerAttributes",
"A collection of key:value pairs containing player information for use in matchmaking")
->DataElement(
AZ::Edit::UIHandlers::Default, &AWSGameLiftPlayerInformation::m_playerId, "PlayerId",
"A unique identifier for a player")
->DataElement(
AZ::Edit::UIHandlers::Default, &AWSGameLiftPlayerInformation::m_team, "Team",
"Name of the team that the player is assigned to in a match");
}
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->Class<AWSGameLiftPlayerInformation>("AWSGameLiftPlayerInformation")
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
->Property("LatencyInMs", BehaviorValueProperty(&AWSGameLiftPlayerInformation::m_latencyInMs))
->Property("PlayerAttributes", BehaviorValueProperty(&AWSGameLiftPlayerInformation::m_playerAttributes))
->Property("PlayerId", BehaviorValueProperty(&AWSGameLiftPlayerInformation::m_playerId))
->Property("Team", BehaviorValueProperty(&AWSGameLiftPlayerInformation::m_team));
}
}
void AWSGameLiftStartMatchmakingRequest::Reflect(AZ::ReflectContext* context)
{
AzFramework::StartMatchmakingRequest::Reflect(context);
AWSGameLiftPlayerInformation::Reflect(context);
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<AWSGameLiftStartMatchmakingRequest, AzFramework::StartMatchmakingRequest>()
->Version(0)
->Field("configurationName", &AWSGameLiftStartMatchmakingRequest::m_configurationName)
->Field("players", &AWSGameLiftStartMatchmakingRequest::m_players);
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<AWSGameLiftStartMatchmakingRequest>("AWSGameLiftStartMatchmakingRequest", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
->DataElement(AZ::Edit::UIHandlers::Default, &AWSGameLiftStartMatchmakingRequest::m_configurationName, "ConfigurationName",
"Name of the matchmaking configuration to use for this request")
->DataElement(AZ::Edit::UIHandlers::Default, &AWSGameLiftStartMatchmakingRequest::m_players, "Players",
"Information on each player to be matched.");
}
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->Class<AWSGameLiftStartMatchmakingRequest>("AWSGameLiftStartMatchmakingRequest")
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
->Property("TicketId", BehaviorValueProperty(&AWSGameLiftStartMatchmakingRequest::m_ticketId))
->Property("ConfigurationName", BehaviorValueProperty(&AWSGameLiftStartMatchmakingRequest::m_configurationName))
->Property("Players", BehaviorValueProperty(&AWSGameLiftStartMatchmakingRequest::m_players));
}
}
} // namespace AWSGameLift
@@ -0,0 +1,41 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <Request/AWSGameLiftStopMatchmakingRequest.h>
namespace AWSGameLift
{
void AWSGameLiftStopMatchmakingRequest::Reflect(AZ::ReflectContext* context)
{
AzFramework::StopMatchmakingRequest::Reflect(context);
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<AWSGameLiftStopMatchmakingRequest, AzFramework::StopMatchmakingRequest>()
->Version(0);
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<AWSGameLiftStopMatchmakingRequest>("AWSGameLiftStopMatchmakingRequest", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly);
}
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->Class<AWSGameLiftStopMatchmakingRequest>("AWSGameLiftStopMatchmakingRequest")
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
->Property("TicketId", BehaviorValueProperty(&AWSGameLiftStopMatchmakingRequest::m_ticketId));
}
}
} // namespace AWSGameLift
@@ -0,0 +1,43 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/RTTI/RTTI.h>
namespace Aws
{
namespace GameLift
{
class GameLiftClient;
}
} // namespace Aws
namespace AWSGameLift
{
//! IAWSGameLiftRequests
//! GameLift Gem internal interface which is used to fetch gem global GameLift client
class IAWSGameLiftInternalRequests
{
public:
AZ_RTTI(IAWSGameLiftInternalRequests, "{DC0CC1C4-21EE-4A41-B428-D12D697F88A2}");
IAWSGameLiftInternalRequests() = default;
virtual ~IAWSGameLiftInternalRequests() = default;
//! GetGameLiftClient
//! Get GameLift client to interact with Amazon GameLift service
//! @return Shared pointer to the GameLift client
virtual AZStd::shared_ptr<Aws::GameLift::GameLiftClient> GetGameLiftClient() const = 0;
//! SetGameLiftClient
//! Set GameLift client to provided GameLift client
//! @param gameliftClient Input new GameLift client
virtual void SetGameLiftClient(AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient) = 0;
};
} // namespace AWSGameLift
@@ -0,0 +1,39 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h>
namespace AWSGameLift
{
//! IAWSGameLiftMatchmakingInternalRequests
//! GameLift Gem matchmaking internal interfaces which is used to communicate
//! with client side ticket tracker to sync matchmaking ticket data and join
//! player to the match
class IAWSGameLiftMatchmakingInternalRequests
{
public:
AZ_RTTI(IAWSGameLiftMatchmakingInternalRequests, "{C2DA440E-74E0-411E-813D-5880B50B0C9E}");
IAWSGameLiftMatchmakingInternalRequests() = default;
virtual ~IAWSGameLiftMatchmakingInternalRequests() = default;
//! StartPolling
//! Request to start process for polling matchmaking ticket based on given ticket id and player id
//! @param ticketId The requested matchmaking ticket id
//! @param playerId The requested matchmaking player id
virtual void StartPolling(const AZStd::string& ticketId, const AZStd::string& playerId) = 0;
//! StopPolling
//! Request to stop process for polling matchmaking ticket
virtual void StopPolling() = 0;
};
} // namespace AWSGameLift
@@ -0,0 +1,353 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AWSGameLiftClientFixture.h>
#include <AWSGameLiftClientLocalTicketTracker.h>
#include <AWSGameLiftClientMocks.h>
#include <Request/IAWSGameLiftInternalRequests.h>
using namespace AWSGameLift;
static constexpr const uint64_t TEST_RACKER_POLLING_PERIOD_MS = 100;
static constexpr const uint64_t TEST_WAIT_BUFFER_TIME_MS = 10;
static constexpr const uint64_t TEST_WAIT_MAXIMUM_TIME_MS = 10000;
class TestAWSGameLiftClientLocalTicketTracker
: public AWSGameLiftClientLocalTicketTracker
{
public:
TestAWSGameLiftClientLocalTicketTracker() = default;
virtual ~TestAWSGameLiftClientLocalTicketTracker() = default;
void SetUp()
{
ActivateTracker();
m_pollingPeriodInMS = TEST_RACKER_POLLING_PERIOD_MS;
}
void TearDown()
{
DeactivateTracker();
}
bool IsTrackerIdle()
{
return m_status == TicketTrackerStatus::Idle;
}
};
class AWSGameLiftClientLocalTicketTrackerTest
: public AWSGameLiftClientFixture
, public IAWSGameLiftInternalRequests
{
protected:
void SetUp() override
{
AWSGameLiftClientFixture::SetUp();
AZ::Interface<IAWSGameLiftInternalRequests>::Register(this);
m_gameliftClientMockPtr = AZStd::make_shared<GameLiftClientMock>();
m_gameliftClientTicketTracker = AZStd::make_unique<TestAWSGameLiftClientLocalTicketTracker>();
m_gameliftClientTicketTracker->SetUp();
}
void TearDown() override
{
m_gameliftClientTicketTracker->TearDown();
m_gameliftClientTicketTracker.reset();
m_gameliftClientMockPtr.reset();
AZ::Interface<IAWSGameLiftInternalRequests>::Unregister(this);
AWSGameLiftClientFixture::TearDown();
}
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> GetGameLiftClient() const
{
return m_gameliftClientMockPtr;
}
void SetGameLiftClient(AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient)
{
AZ_UNUSED(gameliftClient);
m_gameliftClientMockPtr.reset();
}
void WaitForProcessFinish(uint64_t expectedNum)
{
int processingTime = 0;
while (processingTime < TEST_WAIT_MAXIMUM_TIME_MS)
{
if (::UnitTest::TestRunner::Instance().m_numAssertsFailed == expectedNum)
{
AZ_TEST_STOP_TRACE_SUPPRESSION(expectedNum);
return;
}
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(TEST_WAIT_BUFFER_TIME_MS));
processingTime += TEST_WAIT_BUFFER_TIME_MS;
}
}
void WaitForProcessFinish()
{
int processingTime = 0;
while (processingTime < TEST_WAIT_MAXIMUM_TIME_MS)
{
if (m_gameliftClientTicketTracker->IsTrackerIdle())
{
return;
}
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(TEST_WAIT_BUFFER_TIME_MS));
processingTime += TEST_WAIT_BUFFER_TIME_MS;
}
}
public:
AZStd::unique_ptr<TestAWSGameLiftClientLocalTicketTracker> m_gameliftClientTicketTracker;
AZStd::shared_ptr<GameLiftClientMock> m_gameliftClientMockPtr;
};
TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_CallWithoutClientSetup_GetExpectedErrors)
{
AZ::Interface<IAWSGameLiftInternalRequests>::Get()->SetGameLiftClient(nullptr);
AZ_TEST_START_TRACE_SUPPRESSION;
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
WaitForProcessFinish(1);
ASSERT_FALSE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_MultipleCallsWithoutClientSetup_GetExpectedErrors)
{
AZ::Interface<IAWSGameLiftInternalRequests>::Get()->SetGameLiftClient(nullptr);
AZ_TEST_START_TRACE_SUPPRESSION;
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
WaitForProcessFinish(1);
ASSERT_FALSE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_CallButWithFailedOutcome_GetExpectedErrors)
{
Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
Aws::GameLift::Model::DescribeMatchmakingOutcome outcome(error);
EXPECT_CALL(*m_gameliftClientMockPtr, DescribeMatchmaking(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
AZ_TEST_START_TRACE_SUPPRESSION;
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
WaitForProcessFinish(1);
ASSERT_FALSE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_CallWithMoreThanOneTicket_GetExpectedErrors)
{
Aws::GameLift::Model::DescribeMatchmakingResult result;
result.AddTicketList(Aws::GameLift::Model::MatchmakingTicket());
result.AddTicketList(Aws::GameLift::Model::MatchmakingTicket());
Aws::GameLift::Model::DescribeMatchmakingOutcome outcome(result);
EXPECT_CALL(*m_gameliftClientMockPtr, DescribeMatchmaking(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
AZ_TEST_START_TRACE_SUPPRESSION;
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
WaitForProcessFinish(1);
ASSERT_FALSE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_CallWithCompleteStatus_ProcessStopsAndGetExpectedResult)
{
Aws::GameLift::Model::GameSessionConnectionInfo connectionInfo;
connectionInfo.SetIpAddress("DummyIpAddress");
connectionInfo.SetPort(123);
connectionInfo.AddMatchedPlayerSessions(
Aws::GameLift::Model::MatchedPlayerSession()
.WithPlayerId("player1")
.WithPlayerSessionId("playersession1"));
Aws::GameLift::Model::MatchmakingTicket ticket;
ticket.SetStatus(Aws::GameLift::Model::MatchmakingConfigurationStatus::COMPLETED);
ticket.SetGameSessionConnectionInfo(connectionInfo);
Aws::GameLift::Model::DescribeMatchmakingResult result;
result.AddTicketList(ticket);
Aws::GameLift::Model::DescribeMatchmakingOutcome outcome(result);
EXPECT_CALL(*m_gameliftClientMockPtr, DescribeMatchmaking(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
SessionHandlingClientRequestsMock handlerMock;
EXPECT_CALL(handlerMock, RequestPlayerJoinSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(true));
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
WaitForProcessFinish();
ASSERT_TRUE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_CallButNoPlayerSession_ProcessStopsAndGetExpectedError)
{
Aws::GameLift::Model::GameSessionConnectionInfo connectionInfo;
connectionInfo.SetIpAddress("DummyIpAddress");
connectionInfo.SetPort(123);
Aws::GameLift::Model::MatchmakingTicket ticket;
ticket.SetStatus(Aws::GameLift::Model::MatchmakingConfigurationStatus::COMPLETED);
ticket.SetGameSessionConnectionInfo(connectionInfo);
Aws::GameLift::Model::DescribeMatchmakingResult result;
result.AddTicketList(ticket);
Aws::GameLift::Model::DescribeMatchmakingOutcome outcome(result);
EXPECT_CALL(*m_gameliftClientMockPtr, DescribeMatchmaking(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
AZ_TEST_START_TRACE_SUPPRESSION;
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
WaitForProcessFinish(1);
ASSERT_TRUE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_CallButFailedToJoinMatch_ProcessStopsAndGetExpectedError)
{
Aws::GameLift::Model::GameSessionConnectionInfo connectionInfo;
connectionInfo.SetIpAddress("DummyIpAddress");
connectionInfo.SetPort(123);
connectionInfo.AddMatchedPlayerSessions(
Aws::GameLift::Model::MatchedPlayerSession()
.WithPlayerId("player1")
.WithPlayerSessionId("playersession1"));
Aws::GameLift::Model::MatchmakingTicket ticket;
ticket.SetStatus(Aws::GameLift::Model::MatchmakingConfigurationStatus::COMPLETED);
ticket.SetGameSessionConnectionInfo(connectionInfo);
Aws::GameLift::Model::DescribeMatchmakingResult result;
result.AddTicketList(ticket);
Aws::GameLift::Model::DescribeMatchmakingOutcome outcome(result);
EXPECT_CALL(*m_gameliftClientMockPtr, DescribeMatchmaking(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
SessionHandlingClientRequestsMock handlerMock;
EXPECT_CALL(handlerMock, RequestPlayerJoinSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(false));
AZ_TEST_START_TRACE_SUPPRESSION;
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
WaitForProcessFinish(1);
ASSERT_TRUE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_CallButTicketTimeOut_ProcessStopsAndGetExpectedError)
{
Aws::GameLift::Model::MatchmakingTicket ticket;
ticket.SetStatus(Aws::GameLift::Model::MatchmakingConfigurationStatus::TIMED_OUT);
Aws::GameLift::Model::DescribeMatchmakingResult result;
result.AddTicketList(ticket);
Aws::GameLift::Model::DescribeMatchmakingOutcome outcome(result);
EXPECT_CALL(*m_gameliftClientMockPtr, DescribeMatchmaking(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
AZ_TEST_START_TRACE_SUPPRESSION;
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
WaitForProcessFinish(1);
ASSERT_TRUE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_CallButTicketFailed_ProcessStopsAndGetExpectedError)
{
Aws::GameLift::Model::MatchmakingTicket ticket;
ticket.SetStatus(Aws::GameLift::Model::MatchmakingConfigurationStatus::FAILED);
Aws::GameLift::Model::DescribeMatchmakingResult result;
result.AddTicketList(ticket);
Aws::GameLift::Model::DescribeMatchmakingOutcome outcome(result);
EXPECT_CALL(*m_gameliftClientMockPtr, DescribeMatchmaking(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
AZ_TEST_START_TRACE_SUPPRESSION;
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
WaitForProcessFinish(1);
ASSERT_TRUE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_CallButTicketCancelled_ProcessStopsAndGetExpectedError)
{
Aws::GameLift::Model::MatchmakingTicket ticket;
ticket.SetStatus(Aws::GameLift::Model::MatchmakingConfigurationStatus::CANCELLED);
Aws::GameLift::Model::DescribeMatchmakingResult result;
result.AddTicketList(ticket);
Aws::GameLift::Model::DescribeMatchmakingOutcome outcome(result);
EXPECT_CALL(*m_gameliftClientMockPtr, DescribeMatchmaking(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
AZ_TEST_START_TRACE_SUPPRESSION;
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
WaitForProcessFinish(1);
ASSERT_TRUE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
TEST_F(AWSGameLiftClientLocalTicketTrackerTest, StartPolling_CallAndTicketCompleteAtLast_ProcessContinuesAndStop)
{
Aws::GameLift::Model::MatchmakingTicket ticket1;
ticket1.SetStatus(Aws::GameLift::Model::MatchmakingConfigurationStatus::QUEUED);
Aws::GameLift::Model::DescribeMatchmakingResult result1;
result1.AddTicketList(ticket1);
Aws::GameLift::Model::DescribeMatchmakingOutcome outcome1(result1);
Aws::GameLift::Model::GameSessionConnectionInfo connectionInfo;
connectionInfo.SetIpAddress("DummyIpAddress");
connectionInfo.SetPort(123);
connectionInfo.AddMatchedPlayerSessions(
Aws::GameLift::Model::MatchedPlayerSession()
.WithPlayerId("player1")
.WithPlayerSessionId("playersession1"));
Aws::GameLift::Model::MatchmakingTicket ticket2;
ticket2.SetStatus(Aws::GameLift::Model::MatchmakingConfigurationStatus::COMPLETED);
ticket2.SetGameSessionConnectionInfo(connectionInfo);
Aws::GameLift::Model::DescribeMatchmakingResult result2;
result2.AddTicketList(ticket2);
Aws::GameLift::Model::DescribeMatchmakingOutcome outcome2(result2);
EXPECT_CALL(*m_gameliftClientMockPtr, DescribeMatchmaking(::testing::_))
.WillOnce(::testing::Return(outcome1))
.WillOnce(::testing::Return(outcome2));
SessionHandlingClientRequestsMock handlerMock;
EXPECT_CALL(handlerMock, RequestPlayerJoinSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(true));
m_gameliftClientTicketTracker->StartPolling("ticket1", "player1");
WaitForProcessFinish();
ASSERT_TRUE(m_gameliftClientTicketTracker->IsTrackerIdle());
}
@@ -23,8 +23,7 @@
#include <Request/AWSGameLiftCreateSessionRequest.h>
#include <Request/AWSGameLiftJoinSessionRequest.h>
#include <Request/AWSGameLiftSearchSessionsRequest.h>
#include <aws/gamelift/GameLiftClient.h>
#include <Request/IAWSGameLiftInternalRequests.h>
using namespace AWSGameLift;
@@ -117,38 +116,19 @@ public:
MOCK_METHOD0(GetDefaultConfig, AWSCore::AwsApiJobConfig*());
};
class TestAWSGameLiftClientManager
: public AWSGameLiftClientManager
{
public:
TestAWSGameLiftClientManager()
{
m_gameliftClientMockPtr = nullptr;
}
~TestAWSGameLiftClientManager()
{
m_gameliftClientMockPtr = nullptr;
}
void SetUpMockClient()
{
m_gameliftClientMockPtr = AZStd::make_shared<GameLiftClientMock>();
SetGameLiftClient(m_gameliftClientMockPtr);
}
AZStd::shared_ptr<GameLiftClientMock> m_gameliftClientMockPtr;
};
class AWSGameLiftClientManagerTest
: public AWSGameLiftClientFixture
, public IAWSGameLiftInternalRequests
{
protected:
void SetUp() override
{
AWSGameLiftClientFixture::SetUp();
m_gameliftClientManager = AZStd::make_unique<TestAWSGameLiftClientManager>();
m_gameliftClientManager->SetUpMockClient();
AZ::Interface<IAWSGameLiftInternalRequests>::Register(this);
m_gameliftClientMockPtr = AZStd::make_shared<GameLiftClientMock>();
m_gameliftClientManager = AZStd::make_unique<AWSGameLiftClientManager>();
m_gameliftClientManager->ActivateManager();
}
@@ -156,10 +136,24 @@ protected:
{
m_gameliftClientManager->DeactivateManager();
m_gameliftClientManager.reset();
m_gameliftClientMockPtr.reset();
AZ::Interface<IAWSGameLiftInternalRequests>::Unregister(this);
AWSGameLiftClientFixture::TearDown();
}
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> GetGameLiftClient() const
{
return m_gameliftClientMockPtr;
}
void SetGameLiftClient(AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient)
{
AZ_UNUSED(gameliftClient);
m_gameliftClientMockPtr.reset();
}
AWSGameLiftSearchSessionsRequest GetValidSearchSessionsRequest()
{
AWSGameLiftSearchSessionsRequest request;
@@ -230,7 +224,8 @@ protected:
}
public:
AZStd::unique_ptr<TestAWSGameLiftClientManager> m_gameliftClientManager;
AZStd::unique_ptr<AWSGameLiftClientManager> m_gameliftClientManager;
AZStd::shared_ptr<GameLiftClientMock> m_gameliftClientMockPtr;
};
TEST_F(AWSGameLiftClientManagerTest, ConfigureGameLiftClient_CallWithoutRegion_GetFalseAsResult)
@@ -319,7 +314,7 @@ TEST_F(AWSGameLiftClientManagerTest, CreateSession_CallWithValidRequest_GetSucce
Aws::GameLift::Model::CreateGameSessionResult result;
result.SetGameSession(Aws::GameLift::Model::GameSession());
Aws::GameLift::Model::CreateGameSessionOutcome outcome(result);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), CreateGameSession(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, CreateGameSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
m_gameliftClientManager->CreateSession(request);
@@ -331,7 +326,7 @@ TEST_F(AWSGameLiftClientManagerTest, CreateSession_CallWithValidRequest_GetError
request.m_aliasId = "dummyAlias";
Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
Aws::GameLift::Model::CreateGameSessionOutcome outcome(error);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), CreateGameSession(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, CreateGameSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
AZ_TEST_START_TRACE_SUPPRESSION;
@@ -357,7 +352,7 @@ TEST_F(AWSGameLiftClientManagerTest, CreateSessionAsync_CallWithValidRequest_Get
Aws::GameLift::Model::CreateGameSessionResult result;
result.SetGameSession(Aws::GameLift::Model::GameSession());
Aws::GameLift::Model::CreateGameSessionOutcome outcome(result);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), CreateGameSession(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, CreateGameSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
@@ -373,7 +368,7 @@ TEST_F(AWSGameLiftClientManagerTest, CreateSessionAsync_CallWithValidRequest_Get
request.m_aliasId = "dummyAlias";
Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
Aws::GameLift::Model::CreateGameSessionOutcome outcome(error);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), CreateGameSession(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, CreateGameSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
@@ -403,7 +398,7 @@ TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueue_CallWithValidRequest_G
Aws::GameLift::Model::StartGameSessionPlacementResult result;
result.SetGameSessionPlacement(Aws::GameLift::Model::GameSessionPlacement());
Aws::GameLift::Model::StartGameSessionPlacementOutcome outcome(result);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), StartGameSessionPlacement(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, StartGameSessionPlacement(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
m_gameliftClientManager->CreateSession(request);
@@ -416,7 +411,7 @@ TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueue_CallWithValidRequest_G
request.m_placementId = "dummyPlacementId";
Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
Aws::GameLift::Model::StartGameSessionPlacementOutcome outcome(error);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), StartGameSessionPlacement(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, StartGameSessionPlacement(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
AZ_TEST_START_TRACE_SUPPRESSION;
@@ -434,7 +429,7 @@ TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueueAsync_CallWithValidRequ
Aws::GameLift::Model::StartGameSessionPlacementResult result;
result.SetGameSessionPlacement(Aws::GameLift::Model::GameSessionPlacement());
Aws::GameLift::Model::StartGameSessionPlacementOutcome outcome(result);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), StartGameSessionPlacement(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, StartGameSessionPlacement(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
@@ -451,7 +446,7 @@ TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueueAsync_CallWithValidRequ
request.m_placementId = "dummyPlacementId";
Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
Aws::GameLift::Model::StartGameSessionPlacementOutcome outcome(error);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), StartGameSessionPlacement(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, StartGameSessionPlacement(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
@@ -489,7 +484,7 @@ TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithValidRequestButNoReques
Aws::GameLift::Model::CreatePlayerSessionResult result;
result.SetPlayerSession(Aws::GameLift::Model::PlayerSession());
Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(result);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), CreatePlayerSession(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
AZ_TEST_START_TRACE_SUPPRESSION;
@@ -505,7 +500,7 @@ TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithValidRequest_GetErrorOu
request.m_playerId = "dummyPlayerId";
Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(error);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), CreatePlayerSession(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
AZ_TEST_START_TRACE_SUPPRESSION;
@@ -524,7 +519,7 @@ TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithValidRequestAndRequestH
Aws::GameLift::Model::CreatePlayerSessionResult result;
result.SetPlayerSession(Aws::GameLift::Model::PlayerSession());
Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(result);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), CreatePlayerSession(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
auto response = m_gameliftClientManager->JoinSession(request);
@@ -541,7 +536,7 @@ TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithValidRequestAndRequestH
Aws::GameLift::Model::CreatePlayerSessionResult result;
result.SetPlayerSession(Aws::GameLift::Model::PlayerSession());
Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(result);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), CreatePlayerSession(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
auto response = m_gameliftClientManager->JoinSession(request);
@@ -567,7 +562,7 @@ TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithValidRequestButNoR
Aws::GameLift::Model::CreatePlayerSessionResult result;
result.SetPlayerSession(Aws::GameLift::Model::PlayerSession());
Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(result);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), CreatePlayerSession(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
@@ -586,7 +581,7 @@ TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithValidRequest_GetEr
request.m_playerId = "dummyPlayerId";
Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(error);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), CreatePlayerSession(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
@@ -608,7 +603,7 @@ TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithValidRequestAndReq
Aws::GameLift::Model::CreatePlayerSessionResult result;
result.SetPlayerSession(Aws::GameLift::Model::PlayerSession());
Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(result);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), CreatePlayerSession(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
@@ -628,7 +623,7 @@ TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithValidRequestAndReq
Aws::GameLift::Model::CreatePlayerSessionResult result;
result.SetPlayerSession(Aws::GameLift::Model::PlayerSession());
Aws::GameLift::Model::CreatePlayerSessionOutcome outcome(result);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), CreatePlayerSession(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, CreatePlayerSession(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
@@ -642,7 +637,7 @@ TEST_F(AWSGameLiftClientManagerTest, SearchSessions_CallWithValidRequestAndError
Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
Aws::GameLift::Model::SearchGameSessionsOutcome outcome(error);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), SearchGameSessions(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, SearchGameSessions(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
@@ -657,7 +652,7 @@ TEST_F(AWSGameLiftClientManagerTest, SearchSessions_CallWithValidRequestAndSucce
AWSGameLiftSearchSessionsRequest request = GetValidSearchSessionsRequest();
Aws::GameLift::Model::SearchGameSessionsOutcome outcome = GetValidSearchGameSessionsOutcome();
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), SearchGameSessions(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, SearchGameSessions(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
@@ -703,7 +698,7 @@ TEST_F(AWSGameLiftClientManagerTest, SearchSessionsAsync_CallWithValidRequestAnd
Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
Aws::GameLift::Model::SearchGameSessionsOutcome outcome(error);
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), SearchGameSessions(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, SearchGameSessions(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
@@ -724,7 +719,7 @@ TEST_F(AWSGameLiftClientManagerTest, SearchSessionsAsync_CallWithValidRequestAnd
EXPECT_CALL(coreHandlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
Aws::GameLift::Model::SearchGameSessionsOutcome outcome = GetValidSearchGameSessionsOutcome();
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), SearchGameSessions(::testing::_))
EXPECT_CALL(*m_gameliftClientMockPtr, SearchGameSessions(::testing::_))
.Times(1)
.WillOnce(::testing::Return(outcome));
@@ -21,6 +21,8 @@
#include <aws/gamelift/model/CreateGameSessionResult.h>
#include <aws/gamelift/model/CreatePlayerSessionRequest.h>
#include <aws/gamelift/model/CreatePlayerSessionResult.h>
#include <aws/gamelift/model/DescribeMatchmakingRequest.h>
#include <aws/gamelift/model/DescribeMatchmakingResult.h>
#include <aws/gamelift/model/SearchGameSessionsRequest.h>
#include <aws/gamelift/model/SearchGameSessionsResult.h>
#include <aws/gamelift/model/StartGameSessionPlacementRequest.h>
@@ -39,6 +41,7 @@ public:
MOCK_CONST_METHOD1(CreateGameSession, Model::CreateGameSessionOutcome(const Model::CreateGameSessionRequest&));
MOCK_CONST_METHOD1(CreatePlayerSession, Model::CreatePlayerSessionOutcome(const Model::CreatePlayerSessionRequest&));
MOCK_CONST_METHOD1(DescribeMatchmaking, Model::DescribeMatchmakingOutcome(const Model::DescribeMatchmakingRequest&));
MOCK_CONST_METHOD1(SearchGameSessions, Model::SearchGameSessionsOutcome(const Model::SearchGameSessionsRequest&));
MOCK_CONST_METHOD1(StartGameSessionPlacement, Model::StartGameSessionPlacementOutcome(const Model::StartGameSessionPlacementRequest&));
};
@@ -13,10 +13,9 @@
#include <AWSGameLiftClientFixture.h>
#include <AWSGameLiftClientManager.h>
#include <AWSGameLiftClientLocalTicketTracker.h>
#include <AWSGameLiftClientSystemComponent.h>
#include <aws/gamelift/GameLiftClient.h>
using namespace AWSGameLift;
class AWSGameLiftClientManagerMock
@@ -30,6 +29,17 @@ public:
MOCK_METHOD0(DeactivateManager, void());
};
class AWSGameLiftClientLocalTicketTrackerMock
: public AWSGameLiftClientLocalTicketTracker
{
public:
AWSGameLiftClientLocalTicketTrackerMock() = default;
~AWSGameLiftClientLocalTicketTrackerMock() = default;
MOCK_METHOD0(ActivateTracker, void());
MOCK_METHOD0(DeactivateTracker, void());
};
class TestAWSGameLiftClientSystemComponent
: public AWSGameLiftClientSystemComponent
{
@@ -37,20 +47,29 @@ public:
TestAWSGameLiftClientSystemComponent()
{
m_gameliftClientManagerMockPtr = nullptr;
m_gameliftClientTicketTrackerMockPtr = nullptr;
}
~TestAWSGameLiftClientSystemComponent()
{
m_gameliftClientManagerMockPtr = nullptr;
m_gameliftClientTicketTrackerMockPtr = nullptr;
}
void SetUpMockManager()
{
AZStd::unique_ptr<AWSGameLiftClientManagerMock> gameliftClientManagerMock = AZStd::make_unique<AWSGameLiftClientManagerMock>();
AZStd::unique_ptr<AWSGameLiftClientManagerMock> gameliftClientManagerMock =
AZStd::make_unique<AWSGameLiftClientManagerMock>();
m_gameliftClientManagerMockPtr = gameliftClientManagerMock.get();
SetGameLiftClientManager(AZStd::move(gameliftClientManagerMock));
AZStd::unique_ptr<AWSGameLiftClientLocalTicketTrackerMock> gameliftClientTicketTrackerMock =
AZStd::make_unique<AWSGameLiftClientLocalTicketTrackerMock>();
m_gameliftClientTicketTrackerMockPtr = gameliftClientTicketTrackerMock.get();
SetGameLiftClientTicketTracker(AZStd::move(gameliftClientTicketTrackerMock));
}
AWSGameLiftClientManagerMock* m_gameliftClientManagerMockPtr;
AWSGameLiftClientLocalTicketTrackerMock* m_gameliftClientTicketTrackerMockPtr;
};
class AWSCoreSystemComponentMock
@@ -145,8 +164,10 @@ TEST_F(AWSGameLiftClientSystemComponentTest, ActivateDeactivate_Call_GameLiftCli
{
m_entity->Init();
EXPECT_CALL(*(m_gameliftClientSystemComponent->m_gameliftClientManagerMockPtr), ActivateManager()).Times(1);
EXPECT_CALL(*(m_gameliftClientSystemComponent->m_gameliftClientTicketTrackerMockPtr), ActivateTracker()).Times(1);
m_entity->Activate();
EXPECT_CALL(*(m_gameliftClientSystemComponent->m_gameliftClientManagerMockPtr), DeactivateManager()).Times(1);
EXPECT_CALL(*(m_gameliftClientSystemComponent->m_gameliftClientTicketTrackerMockPtr), DeactivateTracker()).Times(1);
m_entity->Deactivate();
}
@@ -7,10 +7,14 @@
#
set(FILES
../AWSGameLiftCommon/Source/AWSGameLiftSessionConstants.h
Include/Request/AWSGameLiftAcceptMatchRequest.h
Include/Request/AWSGameLiftCreateSessionOnQueueRequest.h
Include/Request/AWSGameLiftCreateSessionRequest.h
Include/Request/AWSGameLiftJoinSessionRequest.h
Include/Request/AWSGameLiftSearchSessionsRequest.h
Include/Request/AWSGameLiftStartMatchmakingRequest.h
Include/Request/AWSGameLiftStopMatchmakingRequest.h
Include/Request/IAWSGameLiftRequests.h
Source/Activity/AWSGameLiftActivityUtils.cpp
Source/Activity/AWSGameLiftActivityUtils.h
@@ -24,12 +28,19 @@ set(FILES
Source/Activity/AWSGameLiftLeaveSessionActivity.h
Source/Activity/AWSGameLiftSearchSessionsActivity.cpp
Source/Activity/AWSGameLiftSearchSessionsActivity.h
Source/AWSGameLiftClientLocalTicketTracker.cpp
Source/AWSGameLiftClientLocalTicketTracker.h
Source/AWSGameLiftClientManager.cpp
Source/AWSGameLiftClientManager.h
Source/AWSGameLiftClientSystemComponent.cpp
Source/AWSGameLiftClientSystemComponent.h
Source/Request/AWSGameLiftAcceptMatchRequest.cpp
Source/Request/AWSGameLiftCreateSessionOnQueueRequest.cpp
Source/Request/AWSGameLiftCreateSessionRequest.cpp
Source/Request/AWSGameLiftJoinSessionRequest.cpp
Source/Request/AWSGameLiftSearchSessionsRequest.cpp
Source/Request/AWSGameLiftStartMatchmakingRequest.cpp
Source/Request/AWSGameLiftStopMatchmakingRequest.cpp
Source/Request/IAWSGameLiftInternalRequests.h
Source/Request/IAWSGameLiftMatchmakingInternalRequests.h
)
@@ -12,6 +12,7 @@ set(FILES
Tests/Activity/AWSGameLiftJoinSessionActivityTest.cpp
Tests/Activity/AWSGameLiftSearchSessionsActivityTest.cpp
Tests/AWSGameLiftClientFixture.h
Tests/AWSGameLiftClientLocalTicketTrackerTest.cpp
Tests/AWSGameLiftClientManagerTest.cpp
Tests/AWSGameLiftClientMocks.h
Tests/AWSGameLiftClientSystemComponentTest.cpp
@@ -17,4 +17,5 @@ namespace AWSGameLift
static const char* AWSGameLiftSessionStatusReasons[2] = { "NotSet", "Interrupted" };
static constexpr const char AWSGameLiftErrorMessageTemplate[] = "Exception: %s, Message: %s";
static constexpr const char AWSGameLiftClientMissingErrorMessage[] = "GameLift client is not configured yet.";
} // namespace AWSGameLift
@@ -52,6 +52,7 @@ class AWSGameLift(core.Construct):
stack_name=stack_name,
fleet_configurations=fleet_configurations,
create_game_session_queue=self.node.try_get_context('create_game_session_queue') == 'true',
flex_match=self.node.try_get_context('flex_match') == 'true',
description=f'Contains resources for the AWS GameLift Gem stack as part of the {project_name} project',
tags=tags,
env=env
@@ -0,0 +1,6 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
@@ -0,0 +1,30 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
# Matchmaking rule formatted as a JSON string.
# Comments are not allowed in JSON, but most elements support a description field.
# For instructions on designing Matchmaking rule sets, please check:
# https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-design-ruleset.html
RULE_SET_BODY = '{"ruleLanguageVersion":"1.0","teams":[{"name":"Players","maxPlayers":4,"minPlayers":2}]}'
# A flag that determines whether a match that was created with this configuration
# must be accepted by the matched players.
ACCEPTANCE_REQUIRED = False
# The maximum duration, in seconds, that a matchmaking ticket can remain in process before timing out.
# Requests that fail due to timing out can be resubmitted as needed.
REQUEST_TIMEOUT_SECONDS = 300
# The number of player slots in a match to keep open for future players.
# This parameter is not used if FlexMatchMode is set to STANDALONE.
ADDITIONAL_PLAYER_COUNT = 2
# The method used to backfill game sessions that are created with this matchmaking configuration.
# Specify MANUAL when your game manages backfill requests manually or does not use the match backfill feature.
# Specify AUTOMATIC to have GameLift create a StartMatchBackfill request whenever a game session has one or more
# open slots.
BACKFILL_MODE = 'AUTOMATIC'
@@ -0,0 +1,60 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
import typing
from aws_cdk import (
core,
aws_gamelift as gamelift
)
from . import flexmatch_configurations
FLEX_MATCH_MODE = 'WITH_QUEUE'
class MatchmakingResoures:
"""
Create a matchmaking rule set and matchmaking configuration for Gamelift FlexMatch.
For more information about Gamelift FlexMatch, please check
https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-intro.html
"""
def __init__(self, stack: core.Stack, game_session_queue_arns: typing.List[str]):
rule_set = gamelift.CfnMatchmakingRuleSet(
scope=stack,
id='MatchmakingRuleSet',
name=f'{stack.stack_name}-MatchmakingRuleSet',
rule_set_body=flexmatch_configurations.RULE_SET_BODY
)
matchmaking_configuration = gamelift.CfnMatchmakingConfiguration(
scope=stack,
id='MatchmakingConfiguration',
acceptance_required=flexmatch_configurations.ACCEPTANCE_REQUIRED,
name=f'{stack.stack_name}-MatchmakingConfiguration',
request_timeout_seconds=flexmatch_configurations.REQUEST_TIMEOUT_SECONDS,
rule_set_name=rule_set.name,
additional_player_count=flexmatch_configurations.ADDITIONAL_PLAYER_COUNT,
backfill_mode=flexmatch_configurations.BACKFILL_MODE,
flex_match_mode=FLEX_MATCH_MODE,
game_session_queue_arns=game_session_queue_arns if len(game_session_queue_arns) else None
)
matchmaking_configuration.node.add_dependency(rule_set)
# Export the matchmaking rule set and configuration names as stack outputs
core.CfnOutput(
stack,
id='MatchmakingRuleSetName',
description='Name of the matchmaking rule set',
export_name=f'{stack.stack_name}:MatchmakingRuleSet',
value=rule_set.name)
core.CfnOutput(
stack,
id='MatchmakingConfigurationName',
description='Name of the matchmaking configuration',
export_name=f'{stack.stack_name}:MatchmakingConfiguration',
value=matchmaking_configuration.name)
@@ -0,0 +1,6 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
@@ -0,0 +1,43 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
import typing
from aws_cdk import (
core,
aws_gamelift as gamelift
)
class GameSessionQueueResources:
"""
Create a game session queue which fulfills game session placement requests using the fleets.
For more information about Gamelift game session queues, please check
https://docs.aws.amazon.com/gamelift/latest/developerguide/queues-intro.html
"""
def __init__(self, stack: core.Stack, destinations: typing.List):
self._game_session_queue = gamelift.CfnGameSessionQueue(
scope=stack,
id=f'{stack.stack_name}-GameLiftQueue',
name=f'{stack.stack_name}-GameLiftQueue',
destinations=[
gamelift.CfnGameSessionQueue.DestinationProperty(
destination_arn=resource_arn
) for resource_arn in destinations
]
)
# Export the game session queue name as a stack output
core.CfnOutput(
scope=stack,
id='GameSessionQueue',
description='Name of the game session queue',
export_name=f'{stack.stack_name}:GameSessionQueue',
value=self._game_session_queue.name)
@property
def game_session_queue_arn(self) -> str:
return self._game_session_queue.attr_arn
@@ -5,10 +5,13 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
import typing
from aws_cdk import (
core,
aws_gamelift as gamelift
)
from aws_cdk import core
from aws_cdk import aws_gamelift as gamelift
from .flexmatch import matchmaking
from .game_session_queue import game_session_queue
class GameLiftStack(core.Stack):
@@ -19,7 +22,9 @@ class GameLiftStack(core.Stack):
"""
def __init__(self, scope: core.Construct, id_: str,
stack_name: str, fleet_configurations: dict,
create_game_session_queue: bool, **kwargs) -> None:
create_game_session_queue: bool,
flex_match: bool,
**kwargs) -> None:
super().__init__(scope, id_, **kwargs)
self._stack_name = stack_name
@@ -50,7 +55,7 @@ class GameLiftStack(core.Stack):
queue_destinations.append(destination_arn)
# Export the GameLift fleet ids as a stack output
fleets_output = core.CfnOutput(
core.CfnOutput(
self,
id='GameLiftFleets',
description='List of GameLift fleet ids',
@@ -58,17 +63,13 @@ class GameLiftStack(core.Stack):
value=','.join(fleet_ids)
)
if create_game_session_queue:
# Create a game session queue which fulfills game session placement requests using the fleets
game_session_queue = self._create_game_session_queue(queue_destinations)
game_session_queue_arns = []
if flex_match or create_game_session_queue:
queue = game_session_queue.GameSessionQueueResources(self, queue_destinations)
game_session_queue_arns.append(queue.game_session_queue_arn)
# Export the game session queue name as a stack output
game_session_queue_output = core.CfnOutput(
self,
id='GameSessionQueue',
description='Name of the game session queue',
export_name=f'{self._stack_name}:GameSessionQueue',
value=game_session_queue.name)
if flex_match:
matchmaking.MatchmakingResoures(self, game_session_queue_arns)
def _create_fleet(self, fleet_configuration: dict, identifier: int) -> gamelift.CfnFleet:
"""
@@ -155,25 +156,3 @@ class GameLiftStack(core.Stack):
)
return alias
def _create_game_session_queue(self, destinations: typing.List) -> gamelift.CfnGameSessionQueue:
"""
Create a placement queue that processes requests for new game sessions.
:param destinations: Destinations of the queue.
:return: Generated GameLift game session queue.
"""
game_session_queue = gamelift.CfnGameSessionQueue(
self,
id=f'{self._stack_name}-GameLiftQueue',
name=f'{self._stack_name}-game-session-queue',
destinations=[
gamelift.CfnGameSessionQueue.DestinationProperty(
destination_arn=resource_arn
) for resource_arn in destinations
]
)
return game_session_queue
@@ -22,7 +22,7 @@ namespace AWSMetrics
AZStd::string IdentityProvider::GetEngineVersion()
{
static constexpr const char* EngineConfigFilePath = "@root@/engine.json";
static constexpr const char* EngineConfigFilePath = "@products@/engine.json";
static constexpr const char* EngineVersionJsonKey = "O3DEVersion";
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetDirectInstance();
+28 -12
View File
@@ -16,8 +16,8 @@
#include <AzCore/Serialization/Json/RegistrationContext.h>
#include <AzCore/Settings/SettingsRegistryImpl.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/Utils/Utils.h>
#include <AzFramework/IO/LocalFileIO.h>
#include <AzFramework/StringFunc/StringFunc.h>
namespace AWSMetrics
{
@@ -34,15 +34,22 @@ namespace AWSMetrics
// Set up the file IO and alias
m_localFileIO = aznew AZ::IO::LocalFileIO();
m_priorFileIO = AZ::IO::FileIOBase::GetInstance();
// we need to set it to nullptr first because otherwise the
// we need to set it to nullptr first because otherwise the
// underneath code assumes that we might be leaking the previous instance
AZ::IO::FileIOBase::SetInstance(nullptr);
AZ::IO::FileIOBase::SetInstance(m_localFileIO);
const AZStd::string engineRoot = AZ::Test::GetEngineRootPath();
m_localFileIO->SetAlias("@devroot@", engineRoot.c_str());
m_localFileIO->SetAlias("@root@", engineRoot.c_str());
m_localFileIO->SetAlias("@user@", GetTestFolderPath().c_str());
const AZ::IO::Path engineRoot = AZ::Test::GetEngineRootPath();
const auto productAssetPath = GetTestFolderPath() / "Cache";
const auto userPath = GetTestFolderPath() / "user";
m_localFileIO->CreatePath(productAssetPath.c_str());
m_localFileIO->CreatePath(userPath.c_str());
m_localFileIO->SetAlias("@engroot@", engineRoot.c_str());
m_localFileIO->SetAlias("@products@", productAssetPath.c_str());
m_localFileIO->SetAlias("@user@", userPath.c_str());
// Copy engine.json to the cache
EXPECT_TRUE(m_localFileIO->Copy((engineRoot / "engine.json").c_str(), "engine.json"));
m_serializeContext = AZStd::make_unique<AZ::SerializeContext>();
m_registrationContext = AZStd::make_unique<AZ::JsonRegistrationContext>();
@@ -69,6 +76,13 @@ namespace AWSMetrics
m_serializeContext.reset();
m_registrationContext.reset();
const auto productAssetPath = GetTestFolderPath() / "Cache";
const auto userPath = GetTestFolderPath() / "user";
// Clear the product asset cache alias to prevent cache write errors
m_localFileIO->ClearAlias("@products@");
m_localFileIO->DestroyPath(userPath.c_str());
m_localFileIO->DestroyPath(productAssetPath.c_str());
AZ::IO::FileIOBase::SetInstance(nullptr);
delete m_localFileIO;
AZ::IO::FileIOBase::SetInstance(m_priorFileIO);
@@ -97,22 +111,22 @@ namespace AWSMetrics
bool CreateFile(const AZStd::string& filePath, const AZStd::string& content)
{
AZ::IO::HandleType fileHandle;
// Suppress errors about writing to product asset cache
AZ_TEST_START_TRACE_SUPPRESSION;
if (!m_localFileIO->Open(filePath.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeText, fileHandle))
{
return false;
}
m_localFileIO->Write(fileHandle, content.c_str(), content.size());
AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT;
m_localFileIO->Close(fileHandle);
return true;
}
AZStd::string GetDefaultTestFilePath()
{
AZStd::string testFilePath = GetTestFolderPath();
AzFramework::StringFunc::Path::Join(testFilePath.c_str(), "Test.json", testFilePath);
return testFilePath;
return (GetTestFolderPath() / "Test.json").Native();
}
bool RemoveFile(const AZStd::string& filePath)
@@ -133,14 +147,16 @@ namespace AWSMetrics
AZ::IO::FileIOBase* m_priorFileIO = nullptr;
AZ::IO::FileIOBase* m_localFileIO = nullptr;
AZ::Test::ScopedAutoTempDirectory m_testDirectory;
AZStd::unique_ptr<AZ::SerializeContext> m_serializeContext;
AZStd::unique_ptr<AZ::JsonRegistrationContext> m_registrationContext;
AZStd::unique_ptr<AZ::SettingsRegistryImpl> m_settingsRegistry;
private:
AZStd::string GetTestFolderPath()
AZ::IO::Path GetTestFolderPath()
{
return AZ_TRAIT_TEST_ROOT_FOLDER;
AZ::IO::Path testPathString{ m_testDirectory.GetDirectory() };
return testPathString;
}
};
}
@@ -11,6 +11,7 @@
#include <AzCore/Memory/MemoryDrillerBus.h>
#include <AzCore/Debug/AssetTrackingTypesImpl.h>
#include <AzCore/Debug/AssetTracking.h>
#include <AzCore/std/containers/unordered_set.h>
#include <AzCore/std/smart_ptr/make_shared.h>
///////////////////////////////////////////////////////////////////////////////
@@ -142,14 +142,14 @@ namespace AssetValidation
system.GetIConsole()->AddCommand("addseedlist", ConsoleCommandAddSeedList);
system.GetIConsole()->AddCommand("removeseedlist", ConsoleCommandRemoveSeedList);
system.GetIConsole()->AddCommand("printexcluded", ConsoleCommandTogglePrintExcluded);
}
}
bool AssetValidationSystemComponent::IsKnownAsset(const char* assetPath)
{
AZStd::string lowerAsset{ assetPath };
AZStd::replace(lowerAsset.begin(), lowerAsset.end(), AZ_WRONG_DATABASE_SEPARATOR, AZ_CORRECT_DATABASE_SEPARATOR);
const AZStd::vector<AZStd::string> prefixes = { "./", "@assets@/" };
const AZStd::vector<AZStd::string> prefixes = { "./", "@products@/" };
for (const AZStd::string& prefix : prefixes)
{
if (lowerAsset.starts_with(prefix))
@@ -392,7 +392,7 @@ namespace AssetValidation
AssetValidationRequestBus::Broadcast(&AssetValidationRequestBus::Events::AddSeedList, seedfilepath);
}
bool AssetValidationSystemComponent::AddSeedsFor(const AzFramework::AssetSeedList& seedList, AZ::u32 seedId)
bool AssetValidationSystemComponent::AddSeedsFor(const AzFramework::AssetSeedList& seedList, AZ::u32 seedId)
{
for (const AzFramework::SeedInfo& thisSeed : seedList)
{
@@ -401,7 +401,7 @@ namespace AssetValidation
return true;
}
bool AssetValidationSystemComponent::RemoveSeedsFor(const AzFramework::AssetSeedList& seedList, AZ::u32 seedId)
bool AssetValidationSystemComponent::RemoveSeedsFor(const AzFramework::AssetSeedList& seedList, AZ::u32 seedId)
{
AssetValidationRequests::AssetSourceList removeList;
for (const AzFramework::SeedInfo& thisSeed : seedList)
@@ -244,7 +244,7 @@ namespace ImageProcessingAtom
}
AZ::IO::FixedMaxPath projectConfigFolder;
if (auto sourceGameRoot = fileIoBase->ResolvePath("@devassets@"); sourceGameRoot.has_value())
if (auto sourceGameRoot = fileIoBase->ResolvePath("@projectroot@"); sourceGameRoot.has_value())
{
projectConfigFolder = *sourceGameRoot;
projectConfigFolder /= s_projectConfigRelativeFolder;
@@ -860,8 +860,9 @@ namespace UnitTest
{
continue;
}
#if defined(AZ_ENABLE_TRACING)
auto formatInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(pixelFormat);
#endif
ColorSpace sourceColorSpace = srcImage->HasImageFlags(EIF_SRGBRead) ? ColorSpace::sRGB : ColorSpace::linear;
ICompressorPtr compressor = ICompressor::FindCompressor(pixelFormat, sourceColorSpace, true);
@@ -40,6 +40,7 @@
"_diffuse"
],
"PixelFormat": "ASTC_6x6",
"MaxTextureSize": 2048,
"DiscardAlpha": true,
"IsPowerOf2": true,
"MipMapSetting": {
@@ -61,6 +62,7 @@
"_diffuse"
],
"PixelFormat": "ASTC_6x6",
"MaxTextureSize": 2048,
"DiscardAlpha": true,
"IsPowerOf2": true,
"MipMapSetting": {
@@ -37,6 +37,7 @@
"_diffuse"
],
"PixelFormat": "ASTC_6x6",
"MaxTextureSize": 2048,
"IsPowerOf2": true,
"MipMapSetting": {
"MipGenType": "Box"
@@ -56,6 +57,7 @@
"_diffuse"
],
"PixelFormat": "ASTC_6x6",
"MaxTextureSize": 2048,
"IsPowerOf2": true,
"MipMapSetting": {
"MipGenType": "Box"
@@ -28,6 +28,7 @@
"_amb",
"_ambientocclusion"
],
"MaxTextureSize": 2048,
"PixelFormat": "ASTC_4x4"
},
"ios": {
@@ -41,6 +42,7 @@
"_amb",
"_ambientocclusion"
],
"MaxTextureSize": 2048,
"PixelFormat": "ASTC_4x4"
},
"mac": {
@@ -25,6 +25,7 @@
"_decal"
],
"PixelFormat": "ASTC_4x4",
"MaxTextureSize": 2048,
"IsPowerOf2": true,
"MipMapSetting": {
"MipGenType": "Box"
@@ -39,6 +40,7 @@
"_decal"
],
"PixelFormat": "ASTC_4x4",
"MaxTextureSize": 2048,
"IsPowerOf2": true,
"MipMapSetting": {
"MipGenType": "Box"

Some files were not shown because too many files have changed in this diff Show More