Merge 'gameliftfeature' branch into 'development' branch (#1534)
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(awsgameliftclient_compile_definition $<IF:$<CONFIG:release>,AWSGAMELIFT_RELEASE,AWSGAMELIFT_DEV>)
|
||||
|
||||
ly_add_target(
|
||||
NAME AWSGameLift.Client.Static STATIC
|
||||
NAMESPACE Gem
|
||||
FILES_CMAKE
|
||||
awsgamelift_client_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PUBLIC
|
||||
Include
|
||||
PRIVATE
|
||||
Source
|
||||
../AWSGameLiftCommon/Source
|
||||
COMPILE_DEFINITIONS
|
||||
PRIVATE
|
||||
${awsgameliftclient_compile_definition}
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzCore
|
||||
AZ::AzFramework
|
||||
Gem::AWSCore
|
||||
3rdParty::AWSNativeSDK::GameLiftClient
|
||||
)
|
||||
|
||||
ly_add_target(
|
||||
NAME AWSGameLift.Clients ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
|
||||
NAMESPACE Gem
|
||||
FILES_CMAKE
|
||||
awsgamelift_client_shared_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Source
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzCore
|
||||
3rdParty::AWSNativeSDK::GameLiftClient
|
||||
PUBLIC
|
||||
Gem::AWSGameLift.Client.Static
|
||||
RUNTIME_DEPENDENCIES
|
||||
Gem::AWSCore
|
||||
)
|
||||
|
||||
# Load the "Gem::AWSGameLift" module in all types of applications.
|
||||
if (PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
ly_create_alias(NAME AWSGameLift.Tools NAMESPACE Gem TARGETS Gem::AWSGameLift.Clients)
|
||||
ly_create_alias(NAME AWSGameLift.Builders NAMESPACE Gem TARGETS Gem::AWSGameLift.Clients)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
# Tests
|
||||
################################################################################
|
||||
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
ly_add_target(
|
||||
NAME AWSGameLift.Client.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
|
||||
NAMESPACE Gem
|
||||
FILES_CMAKE
|
||||
awsgamelift_client_tests_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Include
|
||||
Tests
|
||||
Source
|
||||
../AWSGameLiftCommon/Source
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzCore
|
||||
AZ::AzFramework
|
||||
AZ::AzTest
|
||||
Gem::AWSCore
|
||||
Gem::AWSGameLift.Client.Static
|
||||
3rdParty::AWSNativeSDK::GameLiftClient
|
||||
AZ::AWSNativeSDKInit
|
||||
)
|
||||
# Add AWSGameLift.Client.Tests to googletest
|
||||
ly_add_googletest(
|
||||
NAME Gem::AWSGameLift.Client.Tests
|
||||
)
|
||||
endif()
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzFramework/Session/ISessionRequests.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
//! AWSGameLiftCreateSessionOnQueueRequest
|
||||
//! GameLift create session on queue request which corresponds to Amazon GameLift
|
||||
//! StartGameSessionPlacement
|
||||
struct AWSGameLiftCreateSessionOnQueueRequest
|
||||
: public AzFramework::CreateSessionRequest
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(AWSGameLiftCreateSessionOnQueueRequest, "{2B99E594-CE81-4EB0-8888-74EF4242B59F}", AzFramework::CreateSessionRequest);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
AWSGameLiftCreateSessionOnQueueRequest() = default;
|
||||
virtual ~AWSGameLiftCreateSessionOnQueueRequest() = default;
|
||||
|
||||
// Name of the queue to use to place the new game session. You can use either the queue name or ARN value.
|
||||
AZStd::string m_queueName;
|
||||
|
||||
// A unique identifier to assign to the new game session placement. This value is developer-defined.
|
||||
// The value must be unique across all Regions and cannot be reused unless you are resubmitting a canceled or timed-out placement request.
|
||||
AZStd::string m_placementId;
|
||||
};
|
||||
} // namespace AWSGameLift
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzFramework/Session/ISessionRequests.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
//! AWSGameLiftCreateSessionRequest
|
||||
//! GameLift create session on fleet request which corresponds to Amazon GameLift
|
||||
//! CreateGameSessionRequest
|
||||
struct AWSGameLiftCreateSessionRequest
|
||||
: public AzFramework::CreateSessionRequest
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(AWSGameLiftCreateSessionRequest, "{69612D5D-F899-4DEB-AD63-4C497ABC5C0D}", AzFramework::CreateSessionRequest);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
AWSGameLiftCreateSessionRequest() = default;
|
||||
virtual ~AWSGameLiftCreateSessionRequest() = default;
|
||||
|
||||
// A unique identifier for the alias associated with the fleet to create a game session in.
|
||||
AZStd::string m_aliasId;
|
||||
|
||||
// A unique identifier for the fleet to create a game session in.
|
||||
AZStd::string m_fleetId;
|
||||
|
||||
// Custom string that uniquely identifies the new game session request.
|
||||
// This is useful for ensuring that game session requests with the same idempotency token are processed only once.
|
||||
AZStd::string m_idempotencyToken;
|
||||
};
|
||||
} // namespace AWSGameLift
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzFramework/Session/ISessionRequests.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
//! AWSGameLiftJoinSessionRequest
|
||||
//! GameLift join session request which corresponds to Amazon GameLift CreatePlayerSessionRequest.
|
||||
//! Once player session has been created successfully in game session, gamelift client manager will
|
||||
//! signal Multiplayer Gem to setup networking connection.
|
||||
struct AWSGameLiftJoinSessionRequest
|
||||
: public AzFramework::JoinSessionRequest
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(AWSGameLiftJoinSessionRequest, "{6EED6D15-531A-4956-90D0-2EDA31AC9CBA}", AzFramework::JoinSessionRequest);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
AWSGameLiftJoinSessionRequest() = default;
|
||||
virtual ~AWSGameLiftJoinSessionRequest() = default;
|
||||
};
|
||||
} // namespace AWSGameLift
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzFramework/Session/ISessionRequests.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
//! AWSGameLiftSearchSessionsRequest
|
||||
//! GameLift search sessions request which corresponds to Amazon GameLift
|
||||
//! SearchSessionsRequest
|
||||
struct AWSGameLiftSearchSessionsRequest
|
||||
: public AzFramework::SearchSessionsRequest
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(AWSGameLiftSearchSessionsRequest, "{864C91C0-CA53-4585-BF07-066C0DF3E198}", AzFramework::SearchSessionsRequest);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
AWSGameLiftSearchSessionsRequest() = default;
|
||||
virtual ~AWSGameLiftSearchSessionsRequest() = default;
|
||||
|
||||
// A unique identifier for the alias associated with the fleet to search for active game sessions.
|
||||
AZStd::string m_aliasId;
|
||||
|
||||
// A unique identifier for the fleet to search for active game sessions.
|
||||
AZStd::string m_fleetId;
|
||||
|
||||
// A fleet location to search for game sessions.
|
||||
AZStd::string m_location;
|
||||
};
|
||||
} // namespace AWSGameLift
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzFramework/Session/ISessionRequests.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
//! IAWSGameLiftRequests
|
||||
//! GameLift Gem interfaces to configure client manager
|
||||
class IAWSGameLiftRequests
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(IAWSGameLiftRequests, "{494167AD-1185-4AF3-8BF9-C8C37FC9C199}");
|
||||
|
||||
IAWSGameLiftRequests() = default;
|
||||
virtual ~IAWSGameLiftRequests() = default;
|
||||
|
||||
//! ConfigureGameLiftClient
|
||||
//! Configure GameLift client to interact with Amazon GameLift service
|
||||
//! @param region Specifies the AWS region to use
|
||||
//! @return True if client configuration succeeds, false otherwise
|
||||
virtual bool ConfigureGameLiftClient(const AZStd::string& region) = 0;
|
||||
|
||||
//! CreatePlayerId
|
||||
//! Create a new, random ID number for every player in every new game session.
|
||||
//! @param includeBrackets Whether includes brackets in player id
|
||||
//! @param includeDashes Whether includes dashes in player id
|
||||
//! @return The player id to use in game session
|
||||
virtual AZStd::string CreatePlayerId(bool includeBrackets, bool includeDashes) = 0;
|
||||
};
|
||||
|
||||
// IAWSGameLiftRequests EBus wrapper for scripting
|
||||
class AWSGameLiftRequests
|
||||
: 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 AWSGameLiftRequestBus = AZ::EBus<IAWSGameLiftRequests, AWSGameLiftRequests>;
|
||||
|
||||
// ISessionAsyncRequests EBus wrapper for scripting
|
||||
class AWSGameLiftSessionAsyncRequests
|
||||
: 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 AWSGameLiftSessionAsyncRequestBus = AZ::EBus<AzFramework::ISessionAsyncRequests, AWSGameLiftSessionAsyncRequests>;
|
||||
|
||||
// ISessionRequests EBus wrapper for scripting
|
||||
class AWSGameLiftSessionRequests
|
||||
: 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 AWSGameLiftSessionRequestBus = AZ::EBus<AzFramework::ISessionRequests, AWSGameLiftSessionRequests>;
|
||||
} // namespace AWSGameLift
|
||||
@@ -0,0 +1,360 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Jobs/JobFunction.h>
|
||||
#include <AzCore/std/smart_ptr/make_shared.h>
|
||||
#include <AzFramework/Session/SessionConfig.h>
|
||||
|
||||
#include <AWSCoreBus.h>
|
||||
#include <Credential/AWSCredentialBus.h>
|
||||
#include <ResourceMapping/AWSResourceMappingBus.h>
|
||||
|
||||
#include <AWSGameLiftClientManager.h>
|
||||
#include <Activity/AWSGameLiftCreateSessionActivity.h>
|
||||
#include <Activity/AWSGameLiftCreateSessionOnQueueActivity.h>
|
||||
#include <Activity/AWSGameLiftJoinSessionActivity.h>
|
||||
#include <Activity/AWSGameLiftLeaveSessionActivity.h>
|
||||
#include <Activity/AWSGameLiftSearchSessionsActivity.h>
|
||||
|
||||
#include <aws/core/auth/AWSCredentialsProvider.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
#if defined(AWSGAMELIFT_DEV)
|
||||
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);
|
||||
AWSGameLiftRequestBus::Handler::BusConnect();
|
||||
|
||||
AZ::Interface<AzFramework::ISessionAsyncRequests>::Register(this);
|
||||
AWSGameLiftSessionAsyncRequestBus::Handler::BusConnect();
|
||||
|
||||
AZ::Interface<AzFramework::ISessionRequests>::Register(this);
|
||||
AWSGameLiftSessionRequestBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void AWSGameLiftClientManager::DeactivateManager()
|
||||
{
|
||||
AWSGameLiftSessionRequestBus::Handler::BusDisconnect();
|
||||
AZ::Interface<AzFramework::ISessionRequests>::Unregister(this);
|
||||
|
||||
AWSGameLiftSessionAsyncRequestBus::Handler::BusDisconnect();
|
||||
AZ::Interface<AzFramework::ISessionAsyncRequests>::Unregister(this);
|
||||
|
||||
AWSGameLiftRequestBus::Handler::BusDisconnect();
|
||||
AZ::Interface<IAWSGameLiftRequests>::Unregister(this);
|
||||
}
|
||||
|
||||
bool AWSGameLiftClientManager::ConfigureGameLiftClient(const AZStd::string& region)
|
||||
{
|
||||
m_gameliftClient.reset();
|
||||
|
||||
Aws::Client::ClientConfiguration clientConfig;
|
||||
// Set up client endpoint or region
|
||||
AZStd::string localEndpoint = "";
|
||||
#if defined(AWSGAMELIFT_DEV)
|
||||
localEndpoint = static_cast<AZ::CVarFixedString>(cl_gameliftLocalEndpoint);
|
||||
#endif
|
||||
if (!localEndpoint.empty())
|
||||
{
|
||||
// The attribute needs to override to interact with GameLiftLocal
|
||||
clientConfig.endpointOverride = localEndpoint.c_str();
|
||||
}
|
||||
else if (!region.empty())
|
||||
{
|
||||
clientConfig.region = region.c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
AZStd::string clientRegion;
|
||||
AWSCore::AWSResourceMappingRequestBus::BroadcastResult(clientRegion, &AWSCore::AWSResourceMappingRequests::GetDefaultRegion);
|
||||
if (clientRegion.empty())
|
||||
{
|
||||
AZ_Error(AWSGameLiftClientManagerName, false, AWSGameLiftClientRegionMissingErrorMessage);
|
||||
return false;
|
||||
}
|
||||
clientConfig.region = clientRegion.c_str();
|
||||
}
|
||||
|
||||
// Fetch AWS credential for client
|
||||
AWSCore::AWSCredentialResult credentialResult;
|
||||
AWSCore::AWSCredentialRequestBus::BroadcastResult(credentialResult, &AWSCore::AWSCredentialRequests::GetCredentialsProvider);
|
||||
if (!localEndpoint.empty())
|
||||
{
|
||||
credentialResult.result = std::make_shared<Aws::Auth::AnonymousAWSCredentialsProvider>();
|
||||
}
|
||||
else if (!credentialResult.result)
|
||||
{
|
||||
AZ_Error(AWSGameLiftClientManagerName, false, AWSGameLiftClientCredentialMissingErrorMessage);
|
||||
return false;
|
||||
}
|
||||
m_gameliftClient = AZStd::make_shared<Aws::GameLift::GameLiftClient>(credentialResult.result, clientConfig);
|
||||
return true;
|
||||
}
|
||||
|
||||
AZStd::string AWSGameLiftClientManager::CreatePlayerId(bool includeBrackets, bool includeDashes)
|
||||
{
|
||||
return AZ::Uuid::CreateRandom().ToString<AZStd::string>(includeBrackets, includeDashes);
|
||||
}
|
||||
|
||||
AZStd::string AWSGameLiftClientManager::CreateSession(const AzFramework::CreateSessionRequest& createSessionRequest)
|
||||
{
|
||||
AZStd::string result = "";
|
||||
if (CreateSessionActivity::ValidateCreateSessionRequest(createSessionRequest))
|
||||
{
|
||||
const AWSGameLiftCreateSessionRequest& gameliftCreateSessionRequest =
|
||||
static_cast<const AWSGameLiftCreateSessionRequest&>(createSessionRequest);
|
||||
result = CreateSessionHelper(gameliftCreateSessionRequest);
|
||||
}
|
||||
else if (CreateSessionOnQueueActivity::ValidateCreateSessionOnQueueRequest(createSessionRequest))
|
||||
{
|
||||
const AWSGameLiftCreateSessionOnQueueRequest& gameliftCreateSessionOnQueueRequest =
|
||||
static_cast<const AWSGameLiftCreateSessionOnQueueRequest&>(createSessionRequest);
|
||||
result = CreateSessionOnQueueHelper(gameliftCreateSessionOnQueueRequest);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error(AWSGameLiftClientManagerName, false, AWSGameLiftCreateSessionRequestInvalidErrorMessage);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void AWSGameLiftClientManager::CreateSessionAsync(const AzFramework::CreateSessionRequest& createSessionRequest)
|
||||
{
|
||||
if (CreateSessionActivity::ValidateCreateSessionRequest(createSessionRequest))
|
||||
{
|
||||
const AWSGameLiftCreateSessionRequest& gameliftCreateSessionRequest =
|
||||
static_cast<const AWSGameLiftCreateSessionRequest&>(createSessionRequest);
|
||||
|
||||
AZ::JobContext* jobContext = nullptr;
|
||||
AWSCore::AWSCoreRequestBus::BroadcastResult(jobContext, &AWSCore::AWSCoreRequests::GetDefaultJobContext);
|
||||
AZ::Job* createSessionJob = AZ::CreateJobFunction(
|
||||
[this, gameliftCreateSessionRequest]()
|
||||
{
|
||||
AZStd::string result = CreateSessionHelper(gameliftCreateSessionRequest);
|
||||
|
||||
AzFramework::SessionAsyncRequestNotificationBus::Broadcast(
|
||||
&AzFramework::SessionAsyncRequestNotifications::OnCreateSessionAsyncComplete, result);
|
||||
},
|
||||
true, jobContext);
|
||||
createSessionJob->Start();
|
||||
}
|
||||
else if (CreateSessionOnQueueActivity::ValidateCreateSessionOnQueueRequest(createSessionRequest))
|
||||
{
|
||||
const AWSGameLiftCreateSessionOnQueueRequest& gameliftCreateSessionOnQueueRequest =
|
||||
static_cast<const AWSGameLiftCreateSessionOnQueueRequest&>(createSessionRequest);
|
||||
|
||||
AZ::JobContext* jobContext = nullptr;
|
||||
AWSCore::AWSCoreRequestBus::BroadcastResult(jobContext, &AWSCore::AWSCoreRequests::GetDefaultJobContext);
|
||||
AZ::Job* createSessionOnQueueJob = AZ::CreateJobFunction(
|
||||
[this, gameliftCreateSessionOnQueueRequest]()
|
||||
{
|
||||
AZStd::string result = CreateSessionOnQueueHelper(gameliftCreateSessionOnQueueRequest);
|
||||
|
||||
AzFramework::SessionAsyncRequestNotificationBus::Broadcast(
|
||||
&AzFramework::SessionAsyncRequestNotifications::OnCreateSessionAsyncComplete, result);
|
||||
},
|
||||
true, jobContext);
|
||||
createSessionOnQueueJob->Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error(AWSGameLiftClientManagerName, false, AWSGameLiftCreateSessionRequestInvalidErrorMessage);
|
||||
AzFramework::SessionAsyncRequestNotificationBus::Broadcast(
|
||||
&AzFramework::SessionAsyncRequestNotifications::OnCreateSessionAsyncComplete, "");
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::string AWSGameLiftClientManager::CreateSessionHelper(
|
||||
const AWSGameLiftCreateSessionRequest& createSessionRequest)
|
||||
{
|
||||
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameLiftClient = m_gameliftClient;
|
||||
AZStd::string result = "";
|
||||
if (!gameLiftClient)
|
||||
{
|
||||
AZ_Error(AWSGameLiftClientManagerName, false, AWSGameLiftClientMissingErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = CreateSessionActivity::CreateSession(*gameLiftClient, createSessionRequest);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
AZStd::string AWSGameLiftClientManager::CreateSessionOnQueueHelper(
|
||||
const AWSGameLiftCreateSessionOnQueueRequest& createSessionOnQueueRequest)
|
||||
{
|
||||
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient = m_gameliftClient;
|
||||
AZStd::string result;
|
||||
if (!gameliftClient)
|
||||
{
|
||||
AZ_Error(AWSGameLiftClientManagerName, false, AWSGameLiftClientMissingErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = CreateSessionOnQueueActivity::CreateSessionOnQueue(*gameliftClient, createSessionOnQueueRequest);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AWSGameLiftClientManager::JoinSession(const AzFramework::JoinSessionRequest& joinSessionRequest)
|
||||
{
|
||||
bool result = false;
|
||||
if (JoinSessionActivity::ValidateJoinSessionRequest(joinSessionRequest))
|
||||
{
|
||||
const AWSGameLiftJoinSessionRequest& gameliftJoinSessionRequest =
|
||||
static_cast<const AWSGameLiftJoinSessionRequest&>(joinSessionRequest);
|
||||
result = JoinSessionHelper(gameliftJoinSessionRequest);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void AWSGameLiftClientManager::JoinSessionAsync(const AzFramework::JoinSessionRequest& joinSessionRequest)
|
||||
{
|
||||
if (!JoinSessionActivity::ValidateJoinSessionRequest(joinSessionRequest))
|
||||
{
|
||||
AzFramework::SessionAsyncRequestNotificationBus::Broadcast(
|
||||
&AzFramework::SessionAsyncRequestNotifications::OnJoinSessionAsyncComplete, false);
|
||||
return;
|
||||
}
|
||||
|
||||
const AWSGameLiftJoinSessionRequest& gameliftJoinSessionRequest =
|
||||
static_cast<const AWSGameLiftJoinSessionRequest&>(joinSessionRequest);
|
||||
|
||||
AZ::JobContext* jobContext = nullptr;
|
||||
AWSCore::AWSCoreRequestBus::BroadcastResult(jobContext, &AWSCore::AWSCoreRequests::GetDefaultJobContext);
|
||||
AZ::Job* joinSessionJob = AZ::CreateJobFunction(
|
||||
[this, gameliftJoinSessionRequest]()
|
||||
{
|
||||
bool result = JoinSessionHelper(gameliftJoinSessionRequest);
|
||||
|
||||
AzFramework::SessionAsyncRequestNotificationBus::Broadcast(
|
||||
&AzFramework::SessionAsyncRequestNotifications::OnJoinSessionAsyncComplete, result);
|
||||
},
|
||||
true, jobContext);
|
||||
|
||||
joinSessionJob->Start();
|
||||
}
|
||||
|
||||
bool AWSGameLiftClientManager::JoinSessionHelper(const AWSGameLiftJoinSessionRequest& joinSessionRequest)
|
||||
{
|
||||
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient = m_gameliftClient;
|
||||
bool result = false;
|
||||
if (!gameliftClient)
|
||||
{
|
||||
AZ_Error(AWSGameLiftClientManagerName, false, AWSGameLiftClientMissingErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto createPlayerSessionOutcome = JoinSessionActivity::CreatePlayerSession(*gameliftClient, joinSessionRequest);
|
||||
|
||||
result = JoinSessionActivity::RequestPlayerJoinSession(createPlayerSessionOutcome);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void AWSGameLiftClientManager::LeaveSession()
|
||||
{
|
||||
AWSGameLift::LeaveSessionActivity::LeaveSession();
|
||||
}
|
||||
|
||||
void AWSGameLiftClientManager::LeaveSessionAsync()
|
||||
{
|
||||
AZ::JobContext* jobContext = nullptr;
|
||||
AWSCore::AWSCoreRequestBus::BroadcastResult(jobContext, &AWSCore::AWSCoreRequests::GetDefaultJobContext);
|
||||
AZ::Job* leaveSessionJob = AZ::CreateJobFunction(
|
||||
[this]()
|
||||
{
|
||||
LeaveSession();
|
||||
AzFramework::SessionAsyncRequestNotificationBus::Broadcast(
|
||||
&AzFramework::SessionAsyncRequestNotifications::OnLeaveSessionAsyncComplete);
|
||||
},
|
||||
true, jobContext);
|
||||
|
||||
leaveSessionJob->Start();
|
||||
}
|
||||
|
||||
AzFramework::SearchSessionsResponse AWSGameLiftClientManager::SearchSessions(
|
||||
const AzFramework::SearchSessionsRequest& searchSessionsRequest) const
|
||||
{
|
||||
AzFramework::SearchSessionsResponse response;
|
||||
if (SearchSessionsActivity::ValidateSearchSessionsRequest(searchSessionsRequest))
|
||||
{
|
||||
const AWSGameLiftSearchSessionsRequest& gameliftSearchSessionsRequest =
|
||||
static_cast<const AWSGameLiftSearchSessionsRequest&>(searchSessionsRequest);
|
||||
response = SearchSessionsHelper(gameliftSearchSessionsRequest);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
void AWSGameLiftClientManager::SearchSessionsAsync(const AzFramework::SearchSessionsRequest& searchSessionsRequest) const
|
||||
{
|
||||
if (!SearchSessionsActivity::ValidateSearchSessionsRequest(searchSessionsRequest))
|
||||
{
|
||||
AzFramework::SessionAsyncRequestNotificationBus::Broadcast(
|
||||
&AzFramework::SessionAsyncRequestNotifications::OnSearchSessionsAsyncComplete, AzFramework::SearchSessionsResponse());
|
||||
return;
|
||||
}
|
||||
|
||||
const AWSGameLiftSearchSessionsRequest& gameliftSearchSessionsRequest =
|
||||
static_cast<const AWSGameLiftSearchSessionsRequest&>(searchSessionsRequest);
|
||||
|
||||
AZ::JobContext* jobContext = nullptr;
|
||||
AWSCore::AWSCoreRequestBus::BroadcastResult(jobContext, &AWSCore::AWSCoreRequests::GetDefaultJobContext);
|
||||
AZ::Job* searchSessionsJob = AZ::CreateJobFunction(
|
||||
[this, gameliftSearchSessionsRequest]()
|
||||
{
|
||||
AzFramework::SearchSessionsResponse response = SearchSessionsHelper(gameliftSearchSessionsRequest);
|
||||
|
||||
AzFramework::SessionAsyncRequestNotificationBus::Broadcast(
|
||||
&AzFramework::SessionAsyncRequestNotifications::OnSearchSessionsAsyncComplete, response);
|
||||
},
|
||||
true, jobContext);
|
||||
|
||||
searchSessionsJob->Start();
|
||||
}
|
||||
|
||||
AzFramework::SearchSessionsResponse AWSGameLiftClientManager::SearchSessionsHelper(
|
||||
const AWSGameLiftSearchSessionsRequest& searchSessionsRequest) const
|
||||
{
|
||||
AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient = m_gameliftClient;
|
||||
|
||||
AzFramework::SearchSessionsResponse response;
|
||||
if (!gameliftClient)
|
||||
{
|
||||
AZ_Error(AWSGameLiftClientManagerName, false, AWSGameLiftClientMissingErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
response = SearchSessionsActivity::SearchSessions(*gameliftClient, searchSessionsRequest);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
void AWSGameLiftClientManager::SetGameLiftClient(AZStd::shared_ptr<Aws::GameLift::GameLiftClient> gameliftClient)
|
||||
{
|
||||
m_gameliftClient.swap(gameliftClient);
|
||||
}
|
||||
} // namespace AWSGameLift
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/smart_ptr/shared_ptr.h>
|
||||
#include <Request/IAWSGameLiftRequests.h>
|
||||
|
||||
namespace Aws
|
||||
{
|
||||
namespace GameLift
|
||||
{
|
||||
class GameLiftClient;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
struct AWSGameLiftCreateSessionRequest;
|
||||
struct AWSGameLiftCreateSessionOnQueueRequest;
|
||||
struct AWSGameLiftJoinSessionRequest;
|
||||
struct AWSGameLiftSearchSessionsRequest;
|
||||
|
||||
// SessionAsyncRequestNotificationBus EBus handler for scripting
|
||||
class AWSGameLiftSessionAsyncRequestNotificationBusHandler
|
||||
: public AzFramework::SessionAsyncRequestNotificationBus::Handler
|
||||
, public AZ::BehaviorEBusHandler
|
||||
{
|
||||
public:
|
||||
AZ_EBUS_BEHAVIOR_BINDER(
|
||||
AWSGameLiftSessionAsyncRequestNotificationBusHandler,
|
||||
"{6E13FC73-53DC-4B6B-AEA7-9038DE4C9635}",
|
||||
AZ::SystemAllocator,
|
||||
OnCreateSessionAsyncComplete,
|
||||
OnSearchSessionsAsyncComplete,
|
||||
OnJoinSessionAsyncComplete,
|
||||
OnLeaveSessionAsyncComplete);
|
||||
|
||||
void OnCreateSessionAsyncComplete(const AZStd::string& createSessionReponse) override
|
||||
{
|
||||
Call(FN_OnCreateSessionAsyncComplete, createSessionReponse);
|
||||
}
|
||||
|
||||
void OnSearchSessionsAsyncComplete(const AzFramework::SearchSessionsResponse& searchSessionsResponse) override
|
||||
{
|
||||
Call(FN_OnSearchSessionsAsyncComplete, searchSessionsResponse);
|
||||
}
|
||||
|
||||
void OnJoinSessionAsyncComplete(bool joinSessionsResponse) override
|
||||
{
|
||||
Call(FN_OnJoinSessionAsyncComplete, joinSessionsResponse);
|
||||
}
|
||||
|
||||
void OnLeaveSessionAsyncComplete() override
|
||||
{
|
||||
Call(FN_OnLeaveSessionAsyncComplete);
|
||||
}
|
||||
};
|
||||
|
||||
//! AWSGameLiftClientManager
|
||||
//! GameLift client manager to support game and player session related client requests
|
||||
class AWSGameLiftClientManager
|
||||
: public AWSGameLiftRequestBus::Handler
|
||||
, public AWSGameLiftSessionAsyncRequestBus::Handler
|
||||
, public AWSGameLiftSessionRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
static constexpr const char AWSGameLiftClientManagerName[] = "AWSGameLiftClientManager";
|
||||
static constexpr const char AWSGameLiftClientRegionMissingErrorMessage[] =
|
||||
"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();
|
||||
virtual ~AWSGameLiftClientManager() = default;
|
||||
|
||||
virtual void ActivateManager();
|
||||
virtual void DeactivateManager();
|
||||
|
||||
// AWSGameLiftRequestBus interface implementation
|
||||
bool ConfigureGameLiftClient(const AZStd::string& region) override;
|
||||
AZStd::string CreatePlayerId(bool includeBrackets, bool includeDashes) 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;
|
||||
|
||||
// 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
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Module/Module.h>
|
||||
|
||||
#include <AWSGameLiftClientSystemComponent.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
//! Provide the entry point for the gem and register the system component.
|
||||
class AWSGameLiftClientModule
|
||||
: public AZ::Module
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(AWSGameLiftClientModule, "{7b920f3e-2b23-482e-a1b6-16bd278d126c}", AZ::Module);
|
||||
AZ_CLASS_ALLOCATOR(AWSGameLiftClientModule, AZ::SystemAllocator, 0);
|
||||
|
||||
AWSGameLiftClientModule()
|
||||
: AZ::Module()
|
||||
{
|
||||
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
|
||||
m_descriptors.insert(m_descriptors.end(), {
|
||||
AWSGameLiftClientSystemComponent::CreateDescriptor(),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add required SystemComponents to the SystemEntity.
|
||||
*/
|
||||
AZ::ComponentTypeList GetRequiredSystemComponents() const override
|
||||
{
|
||||
return AZ::ComponentTypeList {
|
||||
azrtti_typeid<AWSGameLiftClientSystemComponent>(),
|
||||
};
|
||||
}
|
||||
};
|
||||
}// namespace AWSGameLift
|
||||
|
||||
AZ_DECLARE_MODULE_CLASS(Gem_AWSGameLift_Client, AWSGameLift::AWSGameLiftClientModule)
|
||||
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/EditContextConstants.inl>
|
||||
#include <AzFramework/Session/SessionConfig.h>
|
||||
|
||||
#include <AWSGameLiftClientManager.h>
|
||||
#include <AWSGameLiftClientSystemComponent.h>
|
||||
#include <Request/AWSGameLiftCreateSessionOnQueueRequest.h>
|
||||
#include <Request/AWSGameLiftCreateSessionRequest.h>
|
||||
#include <Request/AWSGameLiftJoinSessionRequest.h>
|
||||
#include <Request/AWSGameLiftSearchSessionsRequest.h>
|
||||
|
||||
#include <aws/gamelift/GameLiftClient.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
AWSGameLiftClientSystemComponent::AWSGameLiftClientSystemComponent()
|
||||
{
|
||||
m_gameliftClientManager = AZStd::make_unique<AWSGameLiftClientManager>();
|
||||
}
|
||||
|
||||
void AWSGameLiftClientSystemComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
ReflectCreateSessionRequest(context);
|
||||
AWSGameLiftCreateSessionOnQueueRequest::Reflect(context);
|
||||
AWSGameLiftCreateSessionRequest::Reflect(context);
|
||||
AWSGameLiftJoinSessionRequest::Reflect(context);
|
||||
AWSGameLiftSearchSessionsRequest::Reflect(context);
|
||||
ReflectSearchSessionsResponse(context);
|
||||
|
||||
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serialize->Class<AWSGameLiftClientSystemComponent, AZ::Component>()
|
||||
->Version(0)
|
||||
;
|
||||
|
||||
if (AZ::EditContext* editContext = serialize->GetEditContext())
|
||||
{
|
||||
editContext
|
||||
->Class<AWSGameLiftClientSystemComponent>(
|
||||
"AWSGameLiftClient",
|
||||
"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)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<AWSGameLiftRequestBus>("AWSGameLiftRequestBus")
|
||||
->Attribute(AZ::Script::Attributes::Category, "AWSGameLift")
|
||||
->Event("ConfigureGameLiftClient", &AWSGameLiftRequestBus::Events::ConfigureGameLiftClient,
|
||||
{{{"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)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
void AWSGameLiftClientSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
{
|
||||
provided.push_back(AZ_CRC_CE("AWSGameLiftClientService"));
|
||||
}
|
||||
|
||||
void AWSGameLiftClientSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
||||
{
|
||||
incompatible.push_back(AZ_CRC_CE("AWSGameLiftClientService"));
|
||||
}
|
||||
|
||||
void AWSGameLiftClientSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
|
||||
{
|
||||
required.push_back(AZ_CRC_CE("AWSCoreService"));
|
||||
}
|
||||
|
||||
void AWSGameLiftClientSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
|
||||
{
|
||||
AZ_UNUSED(dependent);
|
||||
}
|
||||
|
||||
void AWSGameLiftClientSystemComponent::Init()
|
||||
{
|
||||
}
|
||||
|
||||
void AWSGameLiftClientSystemComponent::Activate()
|
||||
{
|
||||
m_gameliftClientManager->ActivateManager();
|
||||
}
|
||||
|
||||
void AWSGameLiftClientSystemComponent::Deactivate()
|
||||
{
|
||||
m_gameliftClientManager->DeactivateManager();
|
||||
}
|
||||
|
||||
void AWSGameLiftClientSystemComponent::ReflectCreateSessionRequest(AZ::ReflectContext* context)
|
||||
{
|
||||
AzFramework::CreateSessionRequest::Reflect(context);
|
||||
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<AzFramework::CreateSessionRequest>("CreateSessionRequest")
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
|
||||
// Expose base type to BehaviorContext, but hide it to be used directly
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
void AWSGameLiftClientSystemComponent::ReflectSearchSessionsResponse(AZ::ReflectContext* context)
|
||||
{
|
||||
// As it is a common response type, reflection could be moved to AzFramework to avoid duplication
|
||||
AzFramework::SessionConfig::Reflect(context);
|
||||
AzFramework::SearchSessionsResponse::Reflect(context);
|
||||
|
||||
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<AzFramework::SessionConfig>("SessionConfig")
|
||||
->Attribute(AZ::Script::Attributes::Category, "Session")
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
|
||||
->Property("CreationTime", BehaviorValueProperty(&AzFramework::SessionConfig::m_creationTime))
|
||||
->Property("CreatorId", BehaviorValueProperty(&AzFramework::SessionConfig::m_creatorId))
|
||||
->Property("CurrentPlayer", BehaviorValueProperty(&AzFramework::SessionConfig::m_currentPlayer))
|
||||
->Property("DnsName", BehaviorValueProperty(&AzFramework::SessionConfig::m_dnsName))
|
||||
->Property("IpAddress", BehaviorValueProperty(&AzFramework::SessionConfig::m_ipAddress))
|
||||
->Property("MaxPlayer", BehaviorValueProperty(&AzFramework::SessionConfig::m_maxPlayer))
|
||||
->Property("Port", BehaviorValueProperty(&AzFramework::SessionConfig::m_port))
|
||||
->Property("SessionId", BehaviorValueProperty(&AzFramework::SessionConfig::m_sessionId))
|
||||
->Property("SessionName", BehaviorValueProperty(&AzFramework::SessionConfig::m_sessionName))
|
||||
->Property("SessionProperties", BehaviorValueProperty(&AzFramework::SessionConfig::m_sessionProperties))
|
||||
->Property("Status", BehaviorValueProperty(&AzFramework::SessionConfig::m_status))
|
||||
->Property("StatusReason", BehaviorValueProperty(&AzFramework::SessionConfig::m_statusReason))
|
||||
->Property("TerminationTime", BehaviorValueProperty(&AzFramework::SessionConfig::m_terminationTime))
|
||||
;
|
||||
behaviorContext->Class<AzFramework::SearchSessionsResponse>("SearchSessionsResponse")
|
||||
->Attribute(AZ::Script::Attributes::Category, "Session")
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
|
||||
->Property("NextToken", BehaviorValueProperty(&AzFramework::SearchSessionsResponse::m_nextToken))
|
||||
->Property("SessionConfigs", BehaviorValueProperty(&AzFramework::SearchSessionsResponse::m_sessionConfigs))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
void AWSGameLiftClientSystemComponent::SetGameLiftClientManager(AZStd::unique_ptr<AWSGameLiftClientManager> gameliftClientManager)
|
||||
{
|
||||
m_gameliftClientManager.reset();
|
||||
m_gameliftClientManager = AZStd::move(gameliftClientManager);
|
||||
}
|
||||
} // namespace AWSGameLift
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
class AWSGameLiftClientManager;
|
||||
|
||||
//! Gem client system component. Responsible for creating the gamelift client manager.
|
||||
class AWSGameLiftClientSystemComponent
|
||||
: public AZ::Component
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(AWSGameLiftClientSystemComponent, "{d481c15c-732a-4eea-9853-4965ed1bc2be}");
|
||||
|
||||
AWSGameLiftClientSystemComponent();
|
||||
virtual ~AWSGameLiftClientSystemComponent() = default;
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
|
||||
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
|
||||
|
||||
protected:
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// AZ::Component interface implementation
|
||||
void Init() override;
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SetGameLiftClientManager(AZStd::unique_ptr<AWSGameLiftClientManager> gameliftClientManager);
|
||||
|
||||
private:
|
||||
static void ReflectCreateSessionRequest(AZ::ReflectContext* context);
|
||||
static void ReflectSearchSessionsResponse(AZ::ReflectContext* context);
|
||||
|
||||
AZStd::unique_ptr<AWSGameLiftClientManager> m_gameliftClientManager;
|
||||
};
|
||||
|
||||
} // namespace AWSGameLift
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Activity/AWSGameLiftCreateSessionActivity.h>
|
||||
#include <AWSGameLiftSessionConstants.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
namespace CreateSessionActivity
|
||||
{
|
||||
Aws::GameLift::Model::CreateGameSessionRequest BuildAWSGameLiftCreateGameSessionRequest(
|
||||
const AWSGameLiftCreateSessionRequest& createSessionRequest)
|
||||
{
|
||||
Aws::GameLift::Model::CreateGameSessionRequest request;
|
||||
// Optional attributes
|
||||
if (!createSessionRequest.m_creatorId.empty())
|
||||
{
|
||||
request.SetCreatorId(createSessionRequest.m_creatorId.c_str());
|
||||
}
|
||||
if (!createSessionRequest.m_sessionName.empty())
|
||||
{
|
||||
request.SetName(createSessionRequest.m_sessionName.c_str());
|
||||
}
|
||||
if (!createSessionRequest.m_idempotencyToken.empty())
|
||||
{
|
||||
request.SetIdempotencyToken(createSessionRequest.m_idempotencyToken.c_str());
|
||||
}
|
||||
for (auto iter = createSessionRequest.m_sessionProperties.begin();
|
||||
iter != createSessionRequest.m_sessionProperties.end(); iter++)
|
||||
{
|
||||
Aws::GameLift::Model::GameProperty sessionProperty;
|
||||
sessionProperty.SetKey(iter->first.c_str());
|
||||
sessionProperty.SetValue(iter->second.c_str());
|
||||
request.AddGameProperties(sessionProperty);
|
||||
}
|
||||
|
||||
// Required attributes
|
||||
if (!createSessionRequest.m_aliasId.empty())
|
||||
{
|
||||
request.SetAliasId(createSessionRequest.m_aliasId.c_str());
|
||||
}
|
||||
if (!createSessionRequest.m_fleetId.empty())
|
||||
{
|
||||
request.SetFleetId(createSessionRequest.m_fleetId.c_str());
|
||||
}
|
||||
request.SetMaximumPlayerSessionCount(createSessionRequest.m_maxPlayer);
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
AZStd::string CreateSession(
|
||||
const Aws::GameLift::GameLiftClient& gameliftClient,
|
||||
const AWSGameLiftCreateSessionRequest& createSessionRequest)
|
||||
{
|
||||
AZ_TracePrintf(AWSGameLiftCreateSessionActivityName, "Requesting CreateGameSession against Amazon GameLift service ...");
|
||||
|
||||
AZStd::string result = "";
|
||||
Aws::GameLift::Model::CreateGameSessionRequest request = BuildAWSGameLiftCreateGameSessionRequest(createSessionRequest);
|
||||
auto createSessionOutcome = gameliftClient.CreateGameSession(request);
|
||||
|
||||
if (createSessionOutcome.IsSuccess())
|
||||
{
|
||||
result = AZStd::string(createSessionOutcome.GetResult().GetGameSession().GetGameSessionId().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error(AWSGameLiftCreateSessionActivityName, false, AWSGameLiftErrorMessageTemplate,
|
||||
createSessionOutcome.GetError().GetExceptionName().c_str(), createSessionOutcome.GetError().GetMessage().c_str());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ValidateCreateSessionRequest(const AzFramework::CreateSessionRequest& createSessionRequest)
|
||||
{
|
||||
auto gameliftCreateSessionRequest = azrtti_cast<const AWSGameLiftCreateSessionRequest*>(&createSessionRequest);
|
||||
|
||||
return gameliftCreateSessionRequest && gameliftCreateSessionRequest->m_maxPlayer >= 0 &&
|
||||
(!gameliftCreateSessionRequest->m_aliasId.empty() || !gameliftCreateSessionRequest->m_fleetId.empty());
|
||||
}
|
||||
} // namespace CreateSessionActivity
|
||||
} // namespace AWSGameLift
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Request/AWSGameLiftCreateSessionRequest.h>
|
||||
|
||||
#include <aws/core/utils/Outcome.h>
|
||||
#include <aws/gamelift/GameLiftClient.h>
|
||||
#include <aws/gamelift/model/CreateGameSessionRequest.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
namespace CreateSessionActivity
|
||||
{
|
||||
static constexpr const char AWSGameLiftCreateSessionActivityName[] = "AWSGameLiftCreateSessionActivity";
|
||||
|
||||
// Build AWS GameLift CreateGameSessionRequest by using AWSGameLiftCreateSessionRequest
|
||||
Aws::GameLift::Model::CreateGameSessionRequest BuildAWSGameLiftCreateGameSessionRequest(const AWSGameLiftCreateSessionRequest& createSessionRequest);
|
||||
|
||||
// Create CreateGameSessionRequest and make a CreateGameSession call through GameLift client
|
||||
AZStd::string CreateSession(
|
||||
const Aws::GameLift::GameLiftClient& gameliftClient,
|
||||
const AWSGameLiftCreateSessionRequest& createSessionRequest);
|
||||
|
||||
// Validate CreateSessionRequest and check required request parameters
|
||||
bool ValidateCreateSessionRequest(const AzFramework::CreateSessionRequest& createSessionRequest);
|
||||
|
||||
} // namespace CreateSessionActivity
|
||||
} // namespace AWSGameLift
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AWSGameLiftSessionConstants.h>
|
||||
#include <Activity/AWSGameLiftCreateSessionOnQueueActivity.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
namespace CreateSessionOnQueueActivity
|
||||
{
|
||||
Aws::GameLift::Model::StartGameSessionPlacementRequest BuildAWSGameLiftStartGameSessionPlacementRequest(
|
||||
const AWSGameLiftCreateSessionOnQueueRequest& createSessionOnQueueRequest)
|
||||
{
|
||||
Aws::GameLift::Model::StartGameSessionPlacementRequest request;
|
||||
// Optional attributes
|
||||
if (!createSessionOnQueueRequest.m_sessionName.empty())
|
||||
{
|
||||
request.SetGameSessionName(createSessionOnQueueRequest.m_sessionName.c_str());
|
||||
}
|
||||
for (auto iter = createSessionOnQueueRequest.m_sessionProperties.begin();
|
||||
iter != createSessionOnQueueRequest.m_sessionProperties.end(); iter++)
|
||||
{
|
||||
Aws::GameLift::Model::GameProperty sessionProperty;
|
||||
sessionProperty.SetKey(iter->first.c_str());
|
||||
sessionProperty.SetValue(iter->second.c_str());
|
||||
request.AddGameProperties(sessionProperty);
|
||||
}
|
||||
|
||||
// Required attributes
|
||||
request.SetGameSessionQueueName(createSessionOnQueueRequest.m_queueName.c_str());
|
||||
request.SetMaximumPlayerSessionCount(createSessionOnQueueRequest.m_maxPlayer);
|
||||
request.SetPlacementId(createSessionOnQueueRequest.m_placementId.c_str());
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
AZStd::string CreateSessionOnQueue(
|
||||
const Aws::GameLift::GameLiftClient& gameliftClient,
|
||||
const AWSGameLiftCreateSessionOnQueueRequest& createSessionOnQueueRequest)
|
||||
{
|
||||
AZ_TracePrintf(AWSGameLiftCreateSessionOnQueueActivityName,
|
||||
"Requesting StartGameSessionPlacement against Amazon GameLift service ...");
|
||||
|
||||
AZStd::string result = "";
|
||||
Aws::GameLift::Model::StartGameSessionPlacementRequest request =
|
||||
BuildAWSGameLiftStartGameSessionPlacementRequest(createSessionOnQueueRequest);
|
||||
auto createSessionOnQueueOutcome = gameliftClient.StartGameSessionPlacement(request);
|
||||
|
||||
if (createSessionOnQueueOutcome.IsSuccess())
|
||||
{
|
||||
result = AZStd::string(createSessionOnQueueOutcome.GetResult().GetGameSessionPlacement().GetPlacementId().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error(AWSGameLiftCreateSessionOnQueueActivityName, false, AWSGameLiftErrorMessageTemplate,
|
||||
createSessionOnQueueOutcome.GetError().GetExceptionName().c_str(),
|
||||
createSessionOnQueueOutcome.GetError().GetMessage().c_str());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ValidateCreateSessionOnQueueRequest(const AzFramework::CreateSessionRequest& createSessionRequest)
|
||||
{
|
||||
auto gameliftCreateSessionOnQueueRequest =
|
||||
azrtti_cast<const AWSGameLiftCreateSessionOnQueueRequest*>(&createSessionRequest);
|
||||
|
||||
return gameliftCreateSessionOnQueueRequest && gameliftCreateSessionOnQueueRequest->m_maxPlayer >= 0 &&
|
||||
!gameliftCreateSessionOnQueueRequest->m_queueName.empty() && !gameliftCreateSessionOnQueueRequest->m_placementId.empty();
|
||||
}
|
||||
} // namespace CreateSessionOnQueueActivity
|
||||
} // namespace AWSGameLift
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Request/AWSGameLiftCreateSessionOnQueueRequest.h>
|
||||
|
||||
#include <aws/core/utils/Outcome.h>
|
||||
#include <aws/gamelift/GameLiftClient.h>
|
||||
#include <aws/gamelift/model/StartGameSessionPlacementRequest.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
namespace CreateSessionOnQueueActivity
|
||||
{
|
||||
static constexpr const char AWSGameLiftCreateSessionOnQueueActivityName[] = "AWSGameLiftCreateSessionOnQueueActivity";
|
||||
|
||||
// Build AWS GameLift StartGameSessionPlacementRequest by using AWSGameLiftCreateSessionOnQueueRequest
|
||||
Aws::GameLift::Model::StartGameSessionPlacementRequest BuildAWSGameLiftStartGameSessionPlacementRequest(
|
||||
const AWSGameLiftCreateSessionOnQueueRequest& createSessionOnQueueRequest);
|
||||
|
||||
// Create StartGameSessionPlacementRequest and make a CreateGameSession call through GameLift client
|
||||
AZStd::string CreateSessionOnQueue(
|
||||
const Aws::GameLift::GameLiftClient& gameliftClient,
|
||||
const AWSGameLiftCreateSessionOnQueueRequest& createSessionOnQueueRequest);
|
||||
|
||||
// Validate CreateSessionOnQueueRequest and check required request parameters
|
||||
bool ValidateCreateSessionOnQueueRequest(const AzFramework::CreateSessionRequest& createSessionRequest);
|
||||
|
||||
} // namespace CreateSessionOnQueueActivity
|
||||
} // namespace AWSGameLift
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzFramework/Session/ISessionHandlingRequests.h>
|
||||
|
||||
#include <Activity/AWSGameLiftJoinSessionActivity.h>
|
||||
#include <AWSGameLiftSessionConstants.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
namespace JoinSessionActivity
|
||||
{
|
||||
Aws::GameLift::Model::CreatePlayerSessionRequest BuildAWSGameLiftCreatePlayerSessionRequest(
|
||||
const AWSGameLiftJoinSessionRequest& joinSessionRequest)
|
||||
{
|
||||
Aws::GameLift::Model::CreatePlayerSessionRequest request;
|
||||
// Optional attributes
|
||||
if (!joinSessionRequest.m_playerData.empty())
|
||||
{
|
||||
request.SetPlayerData(joinSessionRequest.m_playerData.c_str());
|
||||
}
|
||||
// Required attributes
|
||||
request.SetPlayerId(joinSessionRequest.m_playerId.c_str());
|
||||
request.SetGameSessionId(joinSessionRequest.m_sessionId.c_str());
|
||||
return request;
|
||||
}
|
||||
|
||||
AzFramework::SessionConnectionConfig BuildSessionConnectionConfig(
|
||||
const Aws::GameLift::Model::CreatePlayerSessionOutcome& createPlayerSessionOutcome)
|
||||
{
|
||||
AzFramework::SessionConnectionConfig sessionConnectionConfig;
|
||||
auto createPlayerSessionResult = createPlayerSessionOutcome.GetResult();
|
||||
// TODO: AWSNativeSDK needs to be updated to support this attribute, and it is a must have for TLS certificate enabled fleet
|
||||
//sessionConnectionConfig.m_dnsName = createPlayerSessionResult.GetPlayerSession().GetDnsName().c_str();
|
||||
sessionConnectionConfig.m_ipAddress = createPlayerSessionResult.GetPlayerSession().GetIpAddress().c_str();
|
||||
sessionConnectionConfig.m_playerSessionId = createPlayerSessionResult.GetPlayerSession().GetPlayerSessionId().c_str();
|
||||
sessionConnectionConfig.m_port = createPlayerSessionResult.GetPlayerSession().GetPort();
|
||||
return sessionConnectionConfig;
|
||||
}
|
||||
|
||||
Aws::GameLift::Model::CreatePlayerSessionOutcome CreatePlayerSession(
|
||||
const Aws::GameLift::GameLiftClient& gameliftClient,
|
||||
const AWSGameLiftJoinSessionRequest& joinSessionRequest)
|
||||
{
|
||||
AZ_TracePrintf(AWSGameLiftJoinSessionActivityName,
|
||||
"Requesting CreatePlayerSession for player %s against Amazon GameLift service ...",
|
||||
joinSessionRequest.m_playerId.c_str());
|
||||
|
||||
Aws::GameLift::Model::CreatePlayerSessionRequest request =
|
||||
BuildAWSGameLiftCreatePlayerSessionRequest(joinSessionRequest);
|
||||
auto createPlayerSessionOutcome = gameliftClient.CreatePlayerSession(request);
|
||||
|
||||
if (!createPlayerSessionOutcome.IsSuccess())
|
||||
{
|
||||
AZ_Error(AWSGameLiftJoinSessionActivityName, false, AWSGameLiftErrorMessageTemplate,
|
||||
createPlayerSessionOutcome.GetError().GetExceptionName().c_str(),
|
||||
createPlayerSessionOutcome.GetError().GetMessage().c_str());
|
||||
}
|
||||
return createPlayerSessionOutcome;
|
||||
}
|
||||
|
||||
bool RequestPlayerJoinSession(const Aws::GameLift::Model::CreatePlayerSessionOutcome& createPlayerSessionOutcome)
|
||||
{
|
||||
bool result = false;
|
||||
if (createPlayerSessionOutcome.IsSuccess())
|
||||
{
|
||||
auto clientRequestHandler = AZ::Interface<AzFramework::ISessionHandlingClientRequests>::Get();
|
||||
if (clientRequestHandler)
|
||||
{
|
||||
AZ_TracePrintf(AWSGameLiftJoinSessionActivityName, "Requesting player to connect to game session ...");
|
||||
|
||||
AzFramework::SessionConnectionConfig sessionConnectionConfig =
|
||||
BuildSessionConnectionConfig(createPlayerSessionOutcome);
|
||||
result = clientRequestHandler->RequestPlayerJoinSession(sessionConnectionConfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error(AWSGameLiftJoinSessionActivityName, false, AWSGameLiftJoinSessionMissingRequestHandlerErrorMessage);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ValidateJoinSessionRequest(const AzFramework::JoinSessionRequest& joinSessionRequest)
|
||||
{
|
||||
auto gameliftJoinSessionRequest = azrtti_cast<const AWSGameLiftJoinSessionRequest*>(&joinSessionRequest);
|
||||
|
||||
if (gameliftJoinSessionRequest &&
|
||||
!gameliftJoinSessionRequest->m_playerId.empty() &&
|
||||
!gameliftJoinSessionRequest->m_sessionId.empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error(AWSGameLiftJoinSessionActivityName, false, AWSGameLiftJoinSessionRequestInvalidErrorMessage);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace JoinSessionActivity
|
||||
} // namespace AWSGameLift
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzFramework/Session/ISessionHandlingRequests.h>
|
||||
|
||||
#include <Request/AWSGameLiftJoinSessionRequest.h>
|
||||
|
||||
#include <aws/core/utils/Outcome.h>
|
||||
#include <aws/gamelift/GameLiftClient.h>
|
||||
#include <aws/gamelift/model/CreatePlayerSessionRequest.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
namespace JoinSessionActivity
|
||||
{
|
||||
static constexpr const char AWSGameLiftJoinSessionActivityName[] = "AWSGameLiftJoinSessionActivity";
|
||||
static constexpr const char AWSGameLiftJoinSessionRequestInvalidErrorMessage[] =
|
||||
"Invalid GameLift JoinSession request.";
|
||||
static constexpr const char AWSGameLiftJoinSessionMissingRequestHandlerErrorMessage[] =
|
||||
"Missing GameLift JoinSession request handler, please make sure Multiplayer Gem is enabled and registered as handler.";
|
||||
|
||||
// Build AWS GameLift CreatePlayerSessionRequest by using AWSGameLiftJoinSessionRequest
|
||||
Aws::GameLift::Model::CreatePlayerSessionRequest BuildAWSGameLiftCreatePlayerSessionRequest(
|
||||
const AWSGameLiftJoinSessionRequest& joinSessionRequest);
|
||||
|
||||
// Build session connection config by using CreatePlayerSessionOutcome
|
||||
AzFramework::SessionConnectionConfig BuildSessionConnectionConfig(
|
||||
const Aws::GameLift::Model::CreatePlayerSessionOutcome& createPlayerSessionOutcome);
|
||||
|
||||
// Create CreatePlayerSessionRequest and make a CreatePlayerSession call through GameLift client
|
||||
Aws::GameLift::Model::CreatePlayerSessionOutcome CreatePlayerSession(
|
||||
const Aws::GameLift::GameLiftClient& gameliftClient,
|
||||
const AWSGameLiftJoinSessionRequest& joinSessionRequest);
|
||||
|
||||
// Request to setup networking connection for player
|
||||
bool RequestPlayerJoinSession(
|
||||
const Aws::GameLift::Model::CreatePlayerSessionOutcome& createPlayerSessionOutcome);
|
||||
|
||||
// Validate JoinSessionRequest and check required request parameters
|
||||
bool ValidateJoinSessionRequest(const AzFramework::JoinSessionRequest& joinSessionRequest);
|
||||
|
||||
} // namespace JoinSessionActivity
|
||||
} // namespace AWSGameLift
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Activity/AWSGameLiftLeaveSessionActivity.h>
|
||||
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzFramework/Session/ISessionHandlingRequests.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
namespace LeaveSessionActivity
|
||||
{
|
||||
void LeaveSession()
|
||||
{
|
||||
auto clientRequestHandler = AZ::Interface<AzFramework::ISessionHandlingClientRequests>::Get();
|
||||
if (clientRequestHandler)
|
||||
{
|
||||
AZ_TracePrintf(AWSGameLiftLeaveSessionActivityName, "Requesting to leave the current session...");
|
||||
|
||||
clientRequestHandler->RequestPlayerLeaveSession();
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error(AWSGameLiftLeaveSessionActivityName, false, AWSGameLiftLeaveSessionMissingRequestHandlerErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LeaveSessionActivity
|
||||
} // namespace AWSGameLift
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
namespace LeaveSessionActivity
|
||||
{
|
||||
static constexpr const char AWSGameLiftLeaveSessionActivityName[] = "AWSGameLiftLeaveSessionActivity";
|
||||
static constexpr const char AWSGameLiftLeaveSessionMissingRequestHandlerErrorMessage[] =
|
||||
"Missing GameLift LeaveSession request handler, please make sure Multiplayer Gem is enabled and registered as handler.";
|
||||
|
||||
// Request to leave the current session
|
||||
void LeaveSession();
|
||||
} // namespace LeaveSessionActivity
|
||||
} // namespace AWSGameLift
|
||||
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzFramework/Session/SessionConfig.h>
|
||||
|
||||
#include <Activity/AWSGameLiftSearchSessionsActivity.h>
|
||||
#include <AWSGameLiftSessionConstants.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
namespace SearchSessionsActivity
|
||||
{
|
||||
Aws::GameLift::Model::SearchGameSessionsRequest BuildAWSGameLiftSearchGameSessionsRequest(
|
||||
const AWSGameLiftSearchSessionsRequest& searchSessionsRequest)
|
||||
{
|
||||
Aws::GameLift::Model::SearchGameSessionsRequest request;
|
||||
// Optional attributes
|
||||
if (!searchSessionsRequest.m_filterExpression.empty())
|
||||
{
|
||||
request.SetFilterExpression(searchSessionsRequest.m_filterExpression.c_str());
|
||||
}
|
||||
if (!searchSessionsRequest.m_sortExpression.empty())
|
||||
{
|
||||
request.SetSortExpression(searchSessionsRequest.m_sortExpression.c_str());
|
||||
}
|
||||
if (searchSessionsRequest.m_maxResult > 0)
|
||||
{
|
||||
request.SetLimit(searchSessionsRequest.m_maxResult);
|
||||
}
|
||||
if (!searchSessionsRequest.m_nextToken.empty())
|
||||
{
|
||||
request.SetNextToken(searchSessionsRequest.m_nextToken.c_str());
|
||||
}
|
||||
// Required attributes
|
||||
if (!searchSessionsRequest.m_aliasId.empty())
|
||||
{
|
||||
request.SetAliasId(searchSessionsRequest.m_aliasId.c_str());
|
||||
}
|
||||
if (!searchSessionsRequest.m_fleetId.empty())
|
||||
{
|
||||
request.SetFleetId(searchSessionsRequest.m_fleetId.c_str());
|
||||
}
|
||||
// TODO: Update the AWS Native SDK to accept the new request parameter.
|
||||
//request.SetLocation(searchSessionsRequest.m_location.c_str());
|
||||
return request;
|
||||
}
|
||||
|
||||
AzFramework::SearchSessionsResponse SearchSessions(
|
||||
const Aws::GameLift::GameLiftClient& gameliftClient,
|
||||
const AWSGameLiftSearchSessionsRequest& searchSessionsRequest)
|
||||
{
|
||||
AZ_TracePrintf(AWSGameLiftSearchSessionsActivityName, "Requesting SearchGameSessions against Amazon GameLift service ...");
|
||||
|
||||
AzFramework::SearchSessionsResponse response;
|
||||
Aws::GameLift::Model::SearchGameSessionsRequest request = BuildAWSGameLiftSearchGameSessionsRequest(searchSessionsRequest);
|
||||
Aws::GameLift::Model::SearchGameSessionsOutcome outcome = gameliftClient.SearchGameSessions(request);
|
||||
|
||||
if (outcome.IsSuccess())
|
||||
{
|
||||
response = SearchSessionsActivity::ParseResponse(outcome.GetResult());
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error(AWSGameLiftSearchSessionsActivityName, false, AWSGameLiftErrorMessageTemplate,
|
||||
outcome.GetError().GetExceptionName().c_str(), outcome.GetError().GetMessage().c_str());
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
AzFramework::SearchSessionsResponse ParseResponse(
|
||||
const Aws::GameLift::Model::SearchGameSessionsResult& gameLiftSearchSessionsResult)
|
||||
{
|
||||
AzFramework::SearchSessionsResponse response;
|
||||
response.m_nextToken = gameLiftSearchSessionsResult.GetNextToken().c_str();
|
||||
|
||||
for (const Aws::GameLift::Model::GameSession& gameSession : gameLiftSearchSessionsResult.GetGameSessions())
|
||||
{
|
||||
AzFramework::SessionConfig session;
|
||||
session.m_creationTime = gameSession.GetCreationTime().Millis();
|
||||
session.m_creatorId = gameSession.GetCreatorId().c_str();
|
||||
session.m_currentPlayer = gameSession.GetCurrentPlayerSessionCount();
|
||||
session.m_ipAddress = gameSession.GetIpAddress().c_str();
|
||||
session.m_maxPlayer = gameSession.GetMaximumPlayerSessionCount();
|
||||
session.m_port = gameSession.GetPort();
|
||||
session.m_sessionId = gameSession.GetGameSessionId().c_str();
|
||||
session.m_sessionName = gameSession.GetName().c_str();
|
||||
session.m_status = AWSGameLiftSessionStatusNames[(int)gameSession.GetStatus()];
|
||||
session.m_statusReason = AWSGameLiftSessionStatusReasons[(int)gameSession.GetStatusReason()];
|
||||
session.m_terminationTime = gameSession.GetTerminationTime().Millis();
|
||||
// TODO: Update the AWS Native SDK to get the new game session attributes.
|
||||
//session.m_dnsName = gameSession.GetDnsName();
|
||||
|
||||
for (const auto& gameProperty : gameSession.GetGameProperties())
|
||||
{
|
||||
session.m_sessionProperties[gameProperty.GetKey().c_str()] = gameProperty.GetValue().c_str();
|
||||
}
|
||||
|
||||
response.m_sessionConfigs.emplace_back(AZStd::move(session));
|
||||
}
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
bool ValidateSearchSessionsRequest(const AzFramework::SearchSessionsRequest& searchSessionsRequest)
|
||||
{
|
||||
auto gameliftSearchSessionsRequest = azrtti_cast<const AWSGameLiftSearchSessionsRequest*>(&searchSessionsRequest);
|
||||
if (gameliftSearchSessionsRequest &&
|
||||
(!gameliftSearchSessionsRequest->m_aliasId.empty() || !gameliftSearchSessionsRequest->m_fleetId.empty()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error(AWSGameLiftSearchSessionsActivityName, false, AWSGameLiftSearchSessionsRequestInvalidErrorMessage);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AWSGameLift
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Request/AWSGameLiftSearchSessionsRequest.h>
|
||||
|
||||
#include <aws/core/utils/Outcome.h>
|
||||
#include <aws/gamelift/GameLiftClient.h>
|
||||
#include <aws/gamelift/model/SearchGameSessionsRequest.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
namespace SearchSessionsActivity
|
||||
{
|
||||
static constexpr const char AWSGameLiftSearchSessionsActivityName[] = "AWSGameLiftSearchSessionsActivity";
|
||||
static constexpr const char AWSGameLiftSearchSessionsRequestInvalidErrorMessage[] =
|
||||
"Invalid GameLift SearchSessions request.";
|
||||
|
||||
// Build AWS GameLift SearchGameSessionsRequest by using AWSGameLiftSearchSessionsRequest
|
||||
Aws::GameLift::Model::SearchGameSessionsRequest BuildAWSGameLiftSearchGameSessionsRequest(
|
||||
const AWSGameLiftSearchSessionsRequest& searchSessionsRequest);
|
||||
|
||||
// Create SearchGameSessionsRequest and make a SeachGameSessions call through GameLift client
|
||||
AzFramework::SearchSessionsResponse SearchSessions(
|
||||
const Aws::GameLift::GameLiftClient& gameliftClient,
|
||||
const AWSGameLiftSearchSessionsRequest& searchSessionsRequest);
|
||||
|
||||
// Convert from Aws::GameLift::Model::SearchGameSessionsResult to AzFramework::SearchSessionsResponse.
|
||||
AzFramework::SearchSessionsResponse ParseResponse(
|
||||
const Aws::GameLift::Model::SearchGameSessionsResult& gameLiftSearchSessionsResult);
|
||||
|
||||
// Validate SearchSessionsRequest and check required request parameters
|
||||
bool ValidateSearchSessionsRequest(const AzFramework::SearchSessionsRequest& searchSessionsRequest);
|
||||
} // namespace SearchSessionsActivity
|
||||
} // namespace AWSGameLift
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
#include <Request/AWSGameLiftCreateSessionOnQueueRequest.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
void AWSGameLiftCreateSessionOnQueueRequest::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<AWSGameLiftCreateSessionOnQueueRequest, AzFramework::CreateSessionRequest>()
|
||||
->Version(0)
|
||||
->Field("queueName", &AWSGameLiftCreateSessionOnQueueRequest::m_queueName)
|
||||
->Field("placementId", &AWSGameLiftCreateSessionOnQueueRequest::m_placementId)
|
||||
;
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<AWSGameLiftCreateSessionOnQueueRequest>("AWSGameLiftCreateSessionOnQueueRequest", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &AWSGameLiftCreateSessionOnQueueRequest::m_queueName, "QueueName (Required)",
|
||||
"Name of the queue to use to place the new game session")
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &AWSGameLiftCreateSessionOnQueueRequest::m_placementId, "PlacementId (Required)",
|
||||
"A unique identifier to assign to the new game session placement")
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<AWSGameLiftCreateSessionOnQueueRequest>("AWSGameLiftCreateSessionOnQueueRequest")
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
|
||||
->Property("CreatorId", BehaviorValueProperty(&AWSGameLiftCreateSessionOnQueueRequest::m_creatorId))
|
||||
->Property("SessionProperties", BehaviorValueProperty(&AWSGameLiftCreateSessionOnQueueRequest::m_sessionProperties))
|
||||
->Property("SessionName", BehaviorValueProperty(&AWSGameLiftCreateSessionOnQueueRequest::m_sessionName))
|
||||
->Property("MaxPlayer", BehaviorValueProperty(&AWSGameLiftCreateSessionOnQueueRequest::m_maxPlayer))
|
||||
->Property("QueueName", BehaviorValueProperty(&AWSGameLiftCreateSessionOnQueueRequest::m_queueName))
|
||||
->Property("PlacementId", BehaviorValueProperty(&AWSGameLiftCreateSessionOnQueueRequest::m_placementId))
|
||||
;
|
||||
}
|
||||
}
|
||||
} // namespace AWSGameLift
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
#include <Request/AWSGameLiftCreateSessionRequest.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
void AWSGameLiftCreateSessionRequest::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<AWSGameLiftCreateSessionRequest, AzFramework::CreateSessionRequest>()
|
||||
->Version(0)
|
||||
->Field("aliasId", &AWSGameLiftCreateSessionRequest::m_aliasId)
|
||||
->Field("fleetId", &AWSGameLiftCreateSessionRequest::m_fleetId)
|
||||
->Field("idempotencyToken", &AWSGameLiftCreateSessionRequest::m_idempotencyToken)
|
||||
;
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<AWSGameLiftCreateSessionRequest>("AWSGameLiftCreateSessionRequest", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &AWSGameLiftCreateSessionRequest::m_aliasId, "AliasId (Required, or FleetId)",
|
||||
"A unique identifier for the alias associated with the fleet to create a game session in")
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &AWSGameLiftCreateSessionRequest::m_fleetId, "FleetId (Required, or AliasId)",
|
||||
"A unique identifier for the fleet to create a game session in")
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &AWSGameLiftCreateSessionRequest::m_idempotencyToken, "IdempotencyToken",
|
||||
"Custom string that uniquely identifies the new game session request")
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<AWSGameLiftCreateSessionRequest>("AWSGameLiftCreateSessionRequest")
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
|
||||
->Property("CreatorId", BehaviorValueProperty(&AWSGameLiftCreateSessionRequest::m_creatorId))
|
||||
->Property("SessionProperties", BehaviorValueProperty(&AWSGameLiftCreateSessionRequest::m_sessionProperties))
|
||||
->Property("SessionName", BehaviorValueProperty(&AWSGameLiftCreateSessionRequest::m_sessionName))
|
||||
->Property("MaxPlayer", BehaviorValueProperty(&AWSGameLiftCreateSessionRequest::m_maxPlayer))
|
||||
->Property("AliasId", BehaviorValueProperty(&AWSGameLiftCreateSessionRequest::m_aliasId))
|
||||
->Property("FleetId", BehaviorValueProperty(&AWSGameLiftCreateSessionRequest::m_fleetId))
|
||||
->Property("IdempotencyToken", BehaviorValueProperty(&AWSGameLiftCreateSessionRequest::m_idempotencyToken))
|
||||
;
|
||||
}
|
||||
}
|
||||
} // namespace AWSGameLift
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
#include <Request/AWSGameLiftJoinSessionRequest.h>
|
||||
|
||||
namespace AWSGameLift
|
||||
{
|
||||
void AWSGameLiftJoinSessionRequest::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
AzFramework::JoinSessionRequest::Reflect(context);
|
||||
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<AWSGameLiftJoinSessionRequest, AzFramework::JoinSessionRequest>()
|
||||
->Version(0)
|
||||
;
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<AWSGameLiftJoinSessionRequest>("AWSGameLiftJoinSessionRequest", "")
|
||||
->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<AzFramework::JoinSessionRequest>("JoinSessionRequest")
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
|
||||
// Expose base type to BehaviorContext, but hide it to be used directly
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
;
|
||||
behaviorContext->Class<AWSGameLiftJoinSessionRequest>("AWSGameLiftJoinSessionRequest")
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
|
||||
->Property("PlayerData", BehaviorValueProperty(&AWSGameLiftJoinSessionRequest::m_playerData))
|
||||
->Property("PlayerId", BehaviorValueProperty(&AWSGameLiftJoinSessionRequest::m_playerId))
|
||||
->Property("SessionId", BehaviorValueProperty(&AWSGameLiftJoinSessionRequest::m_sessionId))
|
||||
;
|
||||
}
|
||||
}
|
||||
} // namespace AWSGameLift
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#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)
|
||||
{
|
||||
AzFramework::SearchSessionsRequest::Reflect(context);
|
||||
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<AWSGameLiftSearchSessionsRequest, AzFramework::SearchSessionsRequest>()
|
||||
->Version(0)
|
||||
->Field("aliasId", &AWSGameLiftSearchSessionsRequest::m_aliasId)
|
||||
->Field("fleetId", &AWSGameLiftSearchSessionsRequest::m_fleetId)
|
||||
->Field("location", &AWSGameLiftSearchSessionsRequest::m_location);
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<AWSGameLiftSearchSessionsRequest>("AWSGameLiftSearchSessionsRequest", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &AWSGameLiftSearchSessionsRequest::m_aliasId, "AliasId (Required, or FleetId)",
|
||||
"A unique identifier for the alias associated with the fleet to search for active game sessions.")
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &AWSGameLiftSearchSessionsRequest::m_fleetId, "FleetId (Required, or AliasId)",
|
||||
"A unique identifier for the fleet to search for active game sessions.")
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &AWSGameLiftSearchSessionsRequest::m_location, "Location",
|
||||
"A fleet location to search for game sessions.");
|
||||
}
|
||||
}
|
||||
|
||||
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<AzFramework::SearchSessionsRequest>("SearchSessionsRequest")
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
|
||||
// Expose base type to BehaviorContext, but hide it to be used directly
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All);
|
||||
behaviorContext->Class<AWSGameLiftSearchSessionsRequest>("AWSGameLiftSearchSessionsRequest")
|
||||
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
|
||||
->Property("FilterExpression", BehaviorValueProperty(&AWSGameLiftSearchSessionsRequest::m_filterExpression))
|
||||
->Property("SortExpression", BehaviorValueProperty(&AWSGameLiftSearchSessionsRequest::m_sortExpression))
|
||||
->Property("MaxResult", BehaviorValueProperty(&AWSGameLiftSearchSessionsRequest::m_maxResult))
|
||||
->Property("NextToken", BehaviorValueProperty(&AWSGameLiftSearchSessionsRequest::m_nextToken))
|
||||
->Property("AliasId", BehaviorValueProperty(&AWSGameLiftSearchSessionsRequest::m_aliasId))
|
||||
->Property("FleetId", BehaviorValueProperty(&AWSGameLiftSearchSessionsRequest::m_fleetId))
|
||||
->Property("Location", BehaviorValueProperty(&AWSGameLiftSearchSessionsRequest::m_location));
|
||||
}
|
||||
}
|
||||
} // namespace AWSGameLift
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AWSNativeSDKInit/AWSNativeSDKInit.h>
|
||||
#include <AzCore/Jobs/JobManager.h>
|
||||
#include <AzCore/Jobs/JobManagerBus.h>
|
||||
#include <AzCore/Jobs/JobContext.h>
|
||||
#include <AzCore/Memory/PoolAllocator.h>
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
|
||||
class AWSGameLiftClientFixture
|
||||
: public UnitTest::ScopedAllocatorSetupFixture
|
||||
{
|
||||
public:
|
||||
AWSGameLiftClientFixture() {}
|
||||
virtual ~AWSGameLiftClientFixture() = default;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AZ::AllocatorInstance<AZ::ThreadPoolAllocator>::Create();
|
||||
AZ::AllocatorInstance<AZ::PoolAllocator>::Create();
|
||||
|
||||
AZ::JobManagerDesc jobManagerDesc;
|
||||
AZ::JobManagerThreadDesc threadDesc;
|
||||
|
||||
m_jobManager.reset(aznew AZ::JobManager(jobManagerDesc));
|
||||
m_jobCancelGroup.reset(aznew AZ::JobCancelGroup());
|
||||
jobManagerDesc.m_workerThreads.push_back(threadDesc);
|
||||
jobManagerDesc.m_workerThreads.push_back(threadDesc);
|
||||
jobManagerDesc.m_workerThreads.push_back(threadDesc);
|
||||
m_jobContext.reset(aznew AZ::JobContext(*m_jobManager, *m_jobCancelGroup));
|
||||
AZ::JobContext::SetGlobalContext(m_jobContext.get());
|
||||
|
||||
AWSNativeSDKInit::InitializationManager::InitAwsApi();
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
AWSNativeSDKInit::InitializationManager::Shutdown();
|
||||
|
||||
AZ::JobContext::SetGlobalContext(nullptr);
|
||||
m_jobContext.reset();
|
||||
m_jobCancelGroup.reset();
|
||||
m_jobManager.reset();
|
||||
AZ::AllocatorInstance<AZ::PoolAllocator>::Destroy();
|
||||
AZ::AllocatorInstance<AZ::ThreadPoolAllocator>::Destroy();
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<AZ::JobContext> m_jobContext;
|
||||
AZStd::unique_ptr<AZ::JobCancelGroup> m_jobCancelGroup;
|
||||
AZStd::unique_ptr<AZ::JobManager> m_jobManager;
|
||||
};
|
||||
@@ -0,0 +1,773 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Component/ComponentApplication.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/std/smart_ptr/make_shared.h>
|
||||
#include <AzFramework/Session/SessionConfig.h>
|
||||
#include <Credential/AWSCredentialBus.h>
|
||||
#include <ResourceMapping/AWSResourceMappingBus.h>
|
||||
|
||||
#include <AWSCoreBus.h>
|
||||
#include <AWSGameLiftClientFixture.h>
|
||||
#include <AWSGameLiftClientManager.h>
|
||||
#include <AWSGameLiftClientMocks.h>
|
||||
|
||||
#include <Request/AWSGameLiftCreateSessionOnQueueRequest.h>
|
||||
#include <Request/AWSGameLiftCreateSessionRequest.h>
|
||||
#include <Request/AWSGameLiftJoinSessionRequest.h>
|
||||
#include <Request/AWSGameLiftSearchSessionsRequest.h>
|
||||
|
||||
#include <aws/gamelift/GameLiftClient.h>
|
||||
|
||||
using namespace AWSGameLift;
|
||||
|
||||
MATCHER_P(SearchSessionsResponseMatcher, expectedResponse, "")
|
||||
{
|
||||
// Custome matcher for checking the SearchSessionsResponse type argument.
|
||||
AZ_UNUSED(result_listener);
|
||||
|
||||
bool result = arg.m_nextToken == expectedResponse.m_nextToken;
|
||||
result &= arg.m_sessionConfigs.size() == expectedResponse.m_sessionConfigs.size();
|
||||
|
||||
for (int index = 0; index < arg.m_sessionConfigs.size(); ++index)
|
||||
{
|
||||
result &= arg.m_sessionConfigs[index].m_creationTime == expectedResponse.m_sessionConfigs[index].m_creationTime;
|
||||
result &= arg.m_sessionConfigs[index].m_terminationTime == expectedResponse.m_sessionConfigs[index].m_terminationTime;
|
||||
result &= arg.m_sessionConfigs[index].m_creatorId == expectedResponse.m_sessionConfigs[index].m_creatorId;
|
||||
result &= arg.m_sessionConfigs[index].m_sessionProperties == expectedResponse.m_sessionConfigs[index].m_sessionProperties;
|
||||
result &= arg.m_sessionConfigs[index].m_sessionId == expectedResponse.m_sessionConfigs[index].m_sessionId;
|
||||
result &= arg.m_sessionConfigs[index].m_sessionName == expectedResponse.m_sessionConfigs[index].m_sessionName;
|
||||
result &= arg.m_sessionConfigs[index].m_dnsName == expectedResponse.m_sessionConfigs[index].m_dnsName;
|
||||
result &= arg.m_sessionConfigs[index].m_ipAddress == expectedResponse.m_sessionConfigs[index].m_ipAddress;
|
||||
result &= arg.m_sessionConfigs[index].m_port == expectedResponse.m_sessionConfigs[index].m_port;
|
||||
result &= arg.m_sessionConfigs[index].m_maxPlayer == expectedResponse.m_sessionConfigs[index].m_maxPlayer;
|
||||
result &= arg.m_sessionConfigs[index].m_currentPlayer == expectedResponse.m_sessionConfigs[index].m_currentPlayer;
|
||||
result &= arg.m_sessionConfigs[index].m_status == expectedResponse.m_sessionConfigs[index].m_status;
|
||||
result &= arg.m_sessionConfigs[index].m_statusReason == expectedResponse.m_sessionConfigs[index].m_statusReason;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
class AWSResourceMappingRequestsHandlerMock
|
||||
: public AWSCore::AWSResourceMappingRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AWSResourceMappingRequestsHandlerMock()
|
||||
{
|
||||
AWSCore::AWSResourceMappingRequestBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
~ AWSResourceMappingRequestsHandlerMock()
|
||||
{
|
||||
AWSCore::AWSResourceMappingRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
MOCK_CONST_METHOD0(GetDefaultRegion, AZStd::string());
|
||||
MOCK_CONST_METHOD0(GetDefaultAccountId, AZStd::string());
|
||||
MOCK_CONST_METHOD1(GetResourceAccountId, AZStd::string(const AZStd::string&));
|
||||
MOCK_CONST_METHOD1(GetResourceNameId, AZStd::string(const AZStd::string&));
|
||||
MOCK_CONST_METHOD1(GetResourceRegion, AZStd::string(const AZStd::string&));
|
||||
MOCK_CONST_METHOD1(GetResourceType, AZStd::string(const AZStd::string&));
|
||||
MOCK_CONST_METHOD1(GetServiceUrlByServiceName, AZStd::string(const AZStd::string&));
|
||||
MOCK_CONST_METHOD2(GetServiceUrlByRESTApiIdAndStage, AZStd::string(const AZStd::string&, const AZStd::string&));
|
||||
MOCK_METHOD1(ReloadConfigFile, void(bool));
|
||||
};
|
||||
|
||||
class AWSCredentialRequestsHandlerMock
|
||||
: public AWSCore::AWSCredentialRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AWSCredentialRequestsHandlerMock()
|
||||
{
|
||||
AWSCore::AWSCredentialRequestBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
~AWSCredentialRequestsHandlerMock()
|
||||
{
|
||||
AWSCore::AWSCredentialRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
MOCK_CONST_METHOD0(GetCredentialHandlerOrder, int());
|
||||
MOCK_METHOD0(GetCredentialsProvider, std::shared_ptr<Aws::Auth::AWSCredentialsProvider>());
|
||||
};
|
||||
|
||||
class AWSCoreRequestsHandlerMock
|
||||
: public AWSCore::AWSCoreRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AWSCoreRequestsHandlerMock()
|
||||
{
|
||||
AWSCore::AWSCoreRequestBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
~AWSCoreRequestsHandlerMock()
|
||||
{
|
||||
AWSCore::AWSCoreRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
MOCK_METHOD0(GetDefaultJobContext, AZ::JobContext*());
|
||||
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
|
||||
{
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
AWSGameLiftClientFixture::SetUp();
|
||||
|
||||
m_gameliftClientManager = AZStd::make_unique<TestAWSGameLiftClientManager>();
|
||||
m_gameliftClientManager->SetUpMockClient();
|
||||
m_gameliftClientManager->ActivateManager();
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_gameliftClientManager->DeactivateManager();
|
||||
m_gameliftClientManager.reset();
|
||||
|
||||
AWSGameLiftClientFixture::TearDown();
|
||||
}
|
||||
|
||||
AWSGameLiftSearchSessionsRequest GetValidSearchSessionsRequest()
|
||||
{
|
||||
AWSGameLiftSearchSessionsRequest request;
|
||||
request.m_aliasId = "dummyAliasId";
|
||||
request.m_fleetId = "dummyFleetId";
|
||||
request.m_location = "dummyLocation";
|
||||
request.m_filterExpression = "dummyFilterExpression";
|
||||
request.m_sortExpression = "dummySortExpression";
|
||||
request.m_maxResult = 1;
|
||||
request.m_nextToken = "dummyNextToken";
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
Aws::GameLift::Model::SearchGameSessionsOutcome GetValidSearchGameSessionsOutcome()
|
||||
{
|
||||
Aws::GameLift::Model::GameProperty gameProperty;
|
||||
gameProperty.SetKey("dummyKey");
|
||||
gameProperty.SetValue("dummyValue");
|
||||
Aws::Vector<Aws::GameLift::Model::GameProperty> gameProperties = { gameProperty };
|
||||
|
||||
Aws::GameLift::Model::GameSession gameSession;
|
||||
gameSession.SetCreationTime(Aws::Utils::DateTime(0.0));
|
||||
gameSession.SetTerminationTime(Aws::Utils::DateTime(0.0));
|
||||
gameSession.SetCreatorId("dummyCreatorId");
|
||||
gameSession.SetGameProperties(gameProperties);
|
||||
gameSession.SetGameSessionId("dummyGameSessionId");
|
||||
gameSession.SetName("dummyGameSessionName");
|
||||
gameSession.SetIpAddress("dummyIpAddress");
|
||||
gameSession.SetPort(0);
|
||||
gameSession.SetMaximumPlayerSessionCount(2);
|
||||
gameSession.SetCurrentPlayerSessionCount(1);
|
||||
gameSession.SetStatus(Aws::GameLift::Model::GameSessionStatus::TERMINATED);
|
||||
gameSession.SetStatusReason(Aws::GameLift::Model::GameSessionStatusReason::INTERRUPTED);
|
||||
// TODO: Update the AWS Native SDK to set the new game session attributes.
|
||||
// gameSession.SetDnsName("dummyDnsName");
|
||||
|
||||
Aws::GameLift::Model::SearchGameSessionsResult result;
|
||||
result.SetNextToken("dummyNextToken");
|
||||
result.SetGameSessions({ gameSession });
|
||||
|
||||
return Aws::GameLift::Model::SearchGameSessionsOutcome(result);
|
||||
}
|
||||
|
||||
AzFramework::SearchSessionsResponse GetValidSearchSessionsResponse()
|
||||
{
|
||||
AzFramework::SessionConfig sessionConfig;
|
||||
sessionConfig.m_creationTime = 0;
|
||||
sessionConfig.m_terminationTime = 0;
|
||||
sessionConfig.m_creatorId = "dummyCreatorId";
|
||||
sessionConfig.m_sessionProperties["dummyKey"] = "dummyValue";
|
||||
sessionConfig.m_sessionId = "dummyGameSessionId";
|
||||
sessionConfig.m_sessionName = "dummyGameSessionName";
|
||||
sessionConfig.m_ipAddress = "dummyIpAddress";
|
||||
sessionConfig.m_port = 0;
|
||||
sessionConfig.m_maxPlayer = 2;
|
||||
sessionConfig.m_currentPlayer = 1;
|
||||
sessionConfig.m_status = "Terminated";
|
||||
sessionConfig.m_statusReason = "Interrupted";
|
||||
// TODO: Update the AWS Native SDK to set the new game session attributes.
|
||||
// sessionConfig.m_dnsName = "dummyDnsName";
|
||||
|
||||
AzFramework::SearchSessionsResponse response;
|
||||
response.m_nextToken = "dummyNextToken";
|
||||
response.m_sessionConfigs = { sessionConfig };
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public:
|
||||
AZStd::unique_ptr<TestAWSGameLiftClientManager> m_gameliftClientManager;
|
||||
};
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, ConfigureGameLiftClient_CallWithoutRegion_GetFalseAsResult)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto result = m_gameliftClientManager->ConfigureGameLiftClient("");
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, ConfigureGameLiftClient_CallWithoutCredential_GetFalseAsResult)
|
||||
{
|
||||
AWSResourceMappingRequestsHandlerMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, GetDefaultRegion()).Times(1).WillOnce(::testing::Return("us-west-2"));
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto result = m_gameliftClientManager->ConfigureGameLiftClient("");
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, ConfigureGameLiftClient_CallWithRegionAndCredential_GetTrueAsResult)
|
||||
{
|
||||
AWSCredentialRequestsHandlerMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, GetCredentialsProvider())
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(std::make_shared<Aws::Auth::SimpleAWSCredentialsProvider>("dummyAccess", "dummySecret", "")));
|
||||
auto result = m_gameliftClientManager->ConfigureGameLiftClient("us-west-2");
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreatePlayerId_CreateWithoutBracketsOrDashes_GetExpectedResult)
|
||||
{
|
||||
auto result = m_gameliftClientManager->CreatePlayerId(false, false);
|
||||
EXPECT_FALSE(result.starts_with("{"));
|
||||
EXPECT_FALSE(result.ends_with("}"));
|
||||
EXPECT_FALSE(result.contains("-"));
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreatePlayerId_CreateWithBrackets_GetExpectedResult)
|
||||
{
|
||||
auto result = m_gameliftClientManager->CreatePlayerId(true, false);
|
||||
EXPECT_TRUE(result.starts_with("{"));
|
||||
EXPECT_TRUE(result.ends_with("}"));
|
||||
EXPECT_FALSE(result.contains("-"));
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreatePlayerId_CreateWithDashes_GetExpectedResult)
|
||||
{
|
||||
auto result = m_gameliftClientManager->CreatePlayerId(false, true);
|
||||
EXPECT_FALSE(result.starts_with("{"));
|
||||
EXPECT_FALSE(result.ends_with("}"));
|
||||
EXPECT_TRUE(result.contains("-"));
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreatePlayerId_CreateWithBracketsAndDashes_GetExpectedResult)
|
||||
{
|
||||
auto result = m_gameliftClientManager->CreatePlayerId(true, true);
|
||||
EXPECT_TRUE(result.starts_with("{"));
|
||||
EXPECT_TRUE(result.ends_with("}"));
|
||||
EXPECT_TRUE(result.contains("-"));
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreateSession_CallWithoutClientSetup_GetEmptyResponse)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->ConfigureGameLiftClient("");
|
||||
AWSGameLiftCreateSessionRequest request;
|
||||
request.m_aliasId = "dummyAlias";
|
||||
auto response = m_gameliftClientManager->CreateSession(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(2); // capture 2 error message
|
||||
EXPECT_TRUE(response == "");
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreateSession_CallWithInvalidRequest_GetEmptyResponse)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto response = m_gameliftClientManager->CreateSession(AzFramework::CreateSessionRequest());
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
EXPECT_TRUE(response == "");
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreateSession_CallWithValidRequest_GetSuccessOutcome)
|
||||
{
|
||||
AWSGameLiftCreateSessionRequest request;
|
||||
request.m_aliasId = "dummyAlias";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
m_gameliftClientManager->CreateSession(request);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreateSession_CallWithValidRequest_GetErrorOutcome)
|
||||
{
|
||||
AWSGameLiftCreateSessionRequest request;
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->CreateSession(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreateSessionAsync_CallWithInvalidRequest_GetNotificationWithEmptyResponse)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock, OnCreateSessionAsyncComplete(AZStd::string())).Times(1);
|
||||
m_gameliftClientManager->CreateSessionAsync(AzFramework::CreateSessionRequest());
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreateSessionAsync_CallWithValidRequest_GetNotificationWithSuccessOutcome)
|
||||
{
|
||||
AWSCoreRequestsHandlerMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
|
||||
AWSGameLiftCreateSessionRequest request;
|
||||
request.m_aliasId = "dummyAlias";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock, OnCreateSessionAsyncComplete(::testing::_)).Times(1);
|
||||
m_gameliftClientManager->CreateSessionAsync(request);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreateSessionAsync_CallWithValidRequest_GetNotificationWithErrorOutcome)
|
||||
{
|
||||
AWSCoreRequestsHandlerMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
|
||||
AWSGameLiftCreateSessionRequest request;
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock, OnCreateSessionAsyncComplete(AZStd::string(""))).Times(1);
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->CreateSessionAsync(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueue_CallWithoutClientSetup_GetEmptyResponse)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->ConfigureGameLiftClient("");
|
||||
AWSGameLiftCreateSessionOnQueueRequest request;
|
||||
request.m_queueName = "dummyQueue";
|
||||
request.m_placementId = "dummyPlacementId";
|
||||
auto response = m_gameliftClientManager->CreateSession(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(2); // capture 2 error message
|
||||
EXPECT_TRUE(response == "");
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueue_CallWithValidRequest_GetSuccessOutcome)
|
||||
{
|
||||
AWSGameLiftCreateSessionOnQueueRequest request;
|
||||
request.m_queueName = "dummyQueue";
|
||||
request.m_placementId = "dummyPlacementId";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
m_gameliftClientManager->CreateSession(request);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueue_CallWithValidRequest_GetErrorOutcome)
|
||||
{
|
||||
AWSGameLiftCreateSessionOnQueueRequest request;
|
||||
request.m_queueName = "dummyQueue";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->CreateSession(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueueAsync_CallWithValidRequest_GetNotificationWithSuccessOutcome)
|
||||
{
|
||||
AWSCoreRequestsHandlerMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
|
||||
AWSGameLiftCreateSessionOnQueueRequest request;
|
||||
request.m_queueName = "dummyQueue";
|
||||
request.m_placementId = "dummyPlacementId";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock, OnCreateSessionAsyncComplete(::testing::_)).Times(1);
|
||||
m_gameliftClientManager->CreateSessionAsync(request);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, CreateSessionOnQueueAsync_CallWithValidRequest_GetNotificationWithErrorOutcome)
|
||||
{
|
||||
AWSCoreRequestsHandlerMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
|
||||
AWSGameLiftCreateSessionOnQueueRequest request;
|
||||
request.m_queueName = "dummyQueue";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock, OnCreateSessionAsyncComplete(AZStd::string(""))).Times(1);
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->CreateSessionAsync(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithoutClientSetup_GetFalseResponse)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->ConfigureGameLiftClient("");
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_playerId = "dummyPlayerId";
|
||||
request.m_sessionId = "dummySessionId";
|
||||
auto response = m_gameliftClientManager->JoinSession(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(2); // capture 2 error message
|
||||
EXPECT_FALSE(response);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithInvalidRequest_GetFalseResponse)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto response = m_gameliftClientManager->JoinSession(AzFramework::JoinSessionRequest());
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
EXPECT_FALSE(response);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithValidRequestButNoRequestHandler_GetSuccessOutcomeButFalseResponse)
|
||||
{
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_sessionId = "dummySessionId";
|
||||
request.m_playerId = "dummyPlayerId";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto response = m_gameliftClientManager->JoinSession(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
EXPECT_FALSE(response);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithValidRequest_GetErrorOutcomeAndFalseResponse)
|
||||
{
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_sessionId = "dummySessionId";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto response = m_gameliftClientManager->JoinSession(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
EXPECT_FALSE(response);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithValidRequestAndRequestHandler_GetSuccessOutcomeButFalseResponse)
|
||||
{
|
||||
SessionHandlingClientRequestsMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, RequestPlayerJoinSession(::testing::_)).Times(1).WillOnce(::testing::Return(false));
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_sessionId = "dummySessionId";
|
||||
request.m_playerId = "dummyPlayerId";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
auto response = m_gameliftClientManager->JoinSession(request);
|
||||
EXPECT_FALSE(response);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, JoinSession_CallWithValidRequestAndRequestHandler_GetSuccessOutcomeAndTrueResponse)
|
||||
{
|
||||
SessionHandlingClientRequestsMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, RequestPlayerJoinSession(::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_sessionId = "dummySessionId";
|
||||
request.m_playerId = "dummyPlayerId";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
auto response = m_gameliftClientManager->JoinSession(request);
|
||||
EXPECT_TRUE(response);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithInvalidRequest_GetNotificationWithFalseResponse)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock, OnJoinSessionAsyncComplete(false)).Times(1);
|
||||
m_gameliftClientManager->JoinSessionAsync(AzFramework::JoinSessionRequest());
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithValidRequestButNoRequestHandler_GetSuccessOutcomeButNotificationWithFalseResponse)
|
||||
{
|
||||
AWSCoreRequestsHandlerMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_sessionId = "dummySessionId";
|
||||
request.m_playerId = "dummyPlayerId";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock, OnJoinSessionAsyncComplete(false)).Times(1);
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->JoinSessionAsync(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithValidRequest_GetErrorOutcomeAndNotificationWithFalseResponse)
|
||||
{
|
||||
AWSCoreRequestsHandlerMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_sessionId = "dummySessionId";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock, OnJoinSessionAsyncComplete(false)).Times(1);
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->JoinSessionAsync(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithValidRequestAndRequestHandler_GetSuccessOutcomeButNotificationWithFalseResponse)
|
||||
{
|
||||
AWSCoreRequestsHandlerMock coreHandlerMock;
|
||||
EXPECT_CALL(coreHandlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
|
||||
SessionHandlingClientRequestsMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, RequestPlayerJoinSession(::testing::_)).Times(1).WillOnce(::testing::Return(false));
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_sessionId = "dummySessionId";
|
||||
request.m_playerId = "dummyPlayerId";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock, OnJoinSessionAsyncComplete(false)).Times(1);
|
||||
m_gameliftClientManager->JoinSessionAsync(request);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, JoinSessionAsync_CallWithValidRequestAndRequestHandler_GetSuccessOutcomeAndNotificationWithTrueResponse)
|
||||
{
|
||||
AWSCoreRequestsHandlerMock coreHandlerMock;
|
||||
EXPECT_CALL(coreHandlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
|
||||
SessionHandlingClientRequestsMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, RequestPlayerJoinSession(::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_sessionId = "dummySessionId";
|
||||
request.m_playerId = "dummyPlayerId";
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock, OnJoinSessionAsyncComplete(true)).Times(1);
|
||||
m_gameliftClientManager->JoinSessionAsync(request);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, SearchSessions_CallWithValidRequestAndErrorOutcome_GetErrorWithEmptyResponse)
|
||||
{
|
||||
AWSGameLiftSearchSessionsRequest request = GetValidSearchSessionsRequest();
|
||||
|
||||
Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
|
||||
Aws::GameLift::Model::SearchGameSessionsOutcome outcome(error);
|
||||
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), SearchGameSessions(::testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto result = m_gameliftClientManager->SearchSessions(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
EXPECT_TRUE(result.m_sessionConfigs.size() == 0);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, SearchSessions_CallWithValidRequestAndSuccessOutcome_GetNotificationWithValidResponse)
|
||||
{
|
||||
AWSGameLiftSearchSessionsRequest request = GetValidSearchSessionsRequest();
|
||||
|
||||
Aws::GameLift::Model::SearchGameSessionsOutcome outcome = GetValidSearchGameSessionsOutcome();
|
||||
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), SearchGameSessions(::testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
|
||||
AzFramework::SearchSessionsResponse expectedResponse = GetValidSearchSessionsResponse();
|
||||
auto result = m_gameliftClientManager->SearchSessions(request);
|
||||
EXPECT_TRUE(result.m_sessionConfigs.size() != 0);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, SearchSessionsAsync_CallWithoutClientSetup_GetErrorWithEmptyResponse)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
EXPECT_FALSE(m_gameliftClientManager->ConfigureGameLiftClient(""));
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
|
||||
AWSGameLiftSearchSessionsRequest request = GetValidSearchSessionsRequest();
|
||||
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock,
|
||||
OnSearchSessionsAsyncComplete(SearchSessionsResponseMatcher(AzFramework::SearchSessionsResponse()))).Times(1);
|
||||
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->SearchSessionsAsync(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, SearchSessionsAsync_CallWithInvalidRequest_GetErrorWithEmptyResponse)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock,
|
||||
OnSearchSessionsAsyncComplete(SearchSessionsResponseMatcher(AzFramework::SearchSessionsResponse()))).Times(1);
|
||||
|
||||
m_gameliftClientManager->SearchSessionsAsync(AzFramework::SearchSessionsRequest());
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, SearchSessionsAsync_CallWithValidRequestAndErrorOutcome_GetErrorWithEmptyResponse)
|
||||
{
|
||||
AWSGameLiftSearchSessionsRequest request = GetValidSearchSessionsRequest();
|
||||
|
||||
AWSCoreRequestsHandlerMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, GetDefaultJobContext()).Times(1).WillOnce(::testing::Return(m_jobContext.get()));
|
||||
|
||||
Aws::Client::AWSError<Aws::GameLift::GameLiftErrors> error;
|
||||
Aws::GameLift::Model::SearchGameSessionsOutcome outcome(error);
|
||||
EXPECT_CALL(*(m_gameliftClientManager->m_gameliftClientMockPtr), SearchGameSessions(::testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock,
|
||||
OnSearchSessionsAsyncComplete(SearchSessionsResponseMatcher(AzFramework::SearchSessionsResponse()))).Times(1);
|
||||
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->SearchSessionsAsync(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, SearchSessionsAsync_CallWithValidRequestAndSuccessOutcome_GetNotificationWithValidResponse)
|
||||
{
|
||||
AWSGameLiftSearchSessionsRequest request = GetValidSearchSessionsRequest();
|
||||
|
||||
AWSCoreRequestsHandlerMock coreHandlerMock;
|
||||
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::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(outcome));
|
||||
|
||||
AzFramework::SearchSessionsResponse expectedResponse = GetValidSearchSessionsResponse();
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock,
|
||||
OnSearchSessionsAsyncComplete(SearchSessionsResponseMatcher(expectedResponse))).Times(1);
|
||||
|
||||
m_gameliftClientManager->SearchSessionsAsync(request);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, LeaveSession_CallWithInterfaceNotRegistered_GetExpectedError)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->LeaveSession();
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, LeaveSession_CallWithInterfaceRegistered_LeaveSessionRequestSent)
|
||||
{
|
||||
SessionHandlingClientRequestsMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, RequestPlayerLeaveSession).Times(1);
|
||||
|
||||
m_gameliftClientManager->LeaveSession();
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, LeaveSessionAsync_CallWithInterfaceNotRegistered_GetExpectedError)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_gameliftClientManager->LeaveSessionAsync();
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftClientManagerTest, LeaveSessionAsync_CallWithInterfaceRegistered_LeaveSessionAsyncRequestSentAndGetNotification)
|
||||
{
|
||||
SessionHandlingClientRequestsMock handlerMock;
|
||||
EXPECT_CALL(handlerMock, RequestPlayerLeaveSession).Times(1);
|
||||
SessionAsyncRequestNotificationsHandlerMock sessionHandlerMock;
|
||||
EXPECT_CALL(sessionHandlerMock, OnLeaveSessionAsyncComplete()).Times(1);
|
||||
|
||||
m_gameliftClientManager->LeaveSessionAsync();
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzFramework/Session/ISessionRequests.h>
|
||||
#include <AzFramework/Session/ISessionHandlingRequests.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <aws/core/auth/AWSCredentialsProvider.h>
|
||||
#include <aws/core/utils/Outcome.h>
|
||||
#include <aws/gamelift/GameLiftClient.h>
|
||||
#include <aws/gamelift/GameLiftErrors.h>
|
||||
#include <aws/gamelift/model/CreateGameSessionRequest.h>
|
||||
#include <aws/gamelift/model/CreateGameSessionResult.h>
|
||||
#include <aws/gamelift/model/CreatePlayerSessionRequest.h>
|
||||
#include <aws/gamelift/model/CreatePlayerSessionResult.h>
|
||||
#include <aws/gamelift/model/SearchGameSessionsRequest.h>
|
||||
#include <aws/gamelift/model/SearchGameSessionsResult.h>
|
||||
#include <aws/gamelift/model/StartGameSessionPlacementRequest.h>
|
||||
#include <aws/gamelift/model/StartGameSessionPlacementResult.h>
|
||||
|
||||
using namespace Aws::GameLift;
|
||||
|
||||
class GameLiftClientMock
|
||||
: public GameLiftClient
|
||||
{
|
||||
public:
|
||||
GameLiftClientMock()
|
||||
: GameLiftClient(Aws::Auth::AWSCredentials())
|
||||
{
|
||||
}
|
||||
|
||||
MOCK_CONST_METHOD1(CreateGameSession, Model::CreateGameSessionOutcome(const Model::CreateGameSessionRequest&));
|
||||
MOCK_CONST_METHOD1(CreatePlayerSession, Model::CreatePlayerSessionOutcome(const Model::CreatePlayerSessionRequest&));
|
||||
MOCK_CONST_METHOD1(SearchGameSessions, Model::SearchGameSessionsOutcome(const Model::SearchGameSessionsRequest&));
|
||||
MOCK_CONST_METHOD1(StartGameSessionPlacement, Model::StartGameSessionPlacementOutcome(const Model::StartGameSessionPlacementRequest&));
|
||||
};
|
||||
|
||||
class SessionAsyncRequestNotificationsHandlerMock
|
||||
: public AzFramework::SessionAsyncRequestNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
SessionAsyncRequestNotificationsHandlerMock()
|
||||
{
|
||||
AzFramework::SessionAsyncRequestNotificationBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
~SessionAsyncRequestNotificationsHandlerMock()
|
||||
{
|
||||
AzFramework::SessionAsyncRequestNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
MOCK_METHOD1(OnCreateSessionAsyncComplete, void(const AZStd::string&));
|
||||
MOCK_METHOD1(OnSearchSessionsAsyncComplete, void(const AzFramework::SearchSessionsResponse&));
|
||||
MOCK_METHOD1(OnJoinSessionAsyncComplete, void(bool));
|
||||
MOCK_METHOD0(OnLeaveSessionAsyncComplete, void());
|
||||
};
|
||||
|
||||
class SessionHandlingClientRequestsMock
|
||||
: public AzFramework::ISessionHandlingClientRequests
|
||||
{
|
||||
public:
|
||||
SessionHandlingClientRequestsMock()
|
||||
{
|
||||
AZ::Interface<AzFramework::ISessionHandlingClientRequests>::Register(this);
|
||||
}
|
||||
|
||||
virtual ~SessionHandlingClientRequestsMock()
|
||||
{
|
||||
AZ::Interface<AzFramework::ISessionHandlingClientRequests>::Unregister(this);
|
||||
}
|
||||
|
||||
MOCK_METHOD1(RequestPlayerJoinSession, bool(const AzFramework::SessionConnectionConfig&));
|
||||
MOCK_METHOD0(RequestPlayerLeaveSession, void());
|
||||
};
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Component/ComponentApplication.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
|
||||
#include <AWSGameLiftClientFixture.h>
|
||||
#include <AWSGameLiftClientManager.h>
|
||||
#include <AWSGameLiftClientSystemComponent.h>
|
||||
|
||||
#include <aws/gamelift/GameLiftClient.h>
|
||||
|
||||
using namespace AWSGameLift;
|
||||
|
||||
class AWSGameLiftClientManagerMock
|
||||
: public AWSGameLiftClientManager
|
||||
{
|
||||
public:
|
||||
AWSGameLiftClientManagerMock() = default;
|
||||
~AWSGameLiftClientManagerMock() = default;
|
||||
|
||||
MOCK_METHOD0(ActivateManager, void());
|
||||
MOCK_METHOD0(DeactivateManager, void());
|
||||
};
|
||||
|
||||
class TestAWSGameLiftClientSystemComponent
|
||||
: public AWSGameLiftClientSystemComponent
|
||||
{
|
||||
public:
|
||||
TestAWSGameLiftClientSystemComponent()
|
||||
{
|
||||
m_gameliftClientManagerMockPtr = nullptr;
|
||||
}
|
||||
~TestAWSGameLiftClientSystemComponent()
|
||||
{
|
||||
m_gameliftClientManagerMockPtr = nullptr;
|
||||
}
|
||||
|
||||
void SetUpMockManager()
|
||||
{
|
||||
AZStd::unique_ptr<AWSGameLiftClientManagerMock> gameliftClientManagerMock = AZStd::make_unique<AWSGameLiftClientManagerMock>();
|
||||
m_gameliftClientManagerMockPtr = gameliftClientManagerMock.get();
|
||||
SetGameLiftClientManager(AZStd::move(gameliftClientManagerMock));
|
||||
}
|
||||
|
||||
AWSGameLiftClientManagerMock* m_gameliftClientManagerMockPtr;
|
||||
};
|
||||
|
||||
class AWSCoreSystemComponentMock
|
||||
: public AZ::Component
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(AWSCoreSystemComponentMock, "{52DB1342-30C6-412F-B7CC-B23F8B0629EA}");
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
AZ_UNUSED(context);
|
||||
}
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
{
|
||||
provided.push_back(AZ_CRC_CE("AWSCoreService"));
|
||||
}
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
||||
{
|
||||
AZ_UNUSED(incompatible);
|
||||
}
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
|
||||
{
|
||||
AZ_UNUSED(required);
|
||||
}
|
||||
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
|
||||
{
|
||||
AZ_UNUSED(dependent);
|
||||
}
|
||||
|
||||
AWSCoreSystemComponentMock() = default;
|
||||
~AWSCoreSystemComponentMock() = default;
|
||||
|
||||
void Init() override {}
|
||||
void Activate() override {}
|
||||
void Deactivate() override {}
|
||||
};
|
||||
|
||||
class AWSGameLiftClientSystemComponentTest
|
||||
: public AWSGameLiftClientFixture
|
||||
{
|
||||
protected:
|
||||
AZStd::unique_ptr<AZ::SerializeContext> m_serializeContext;
|
||||
AZStd::unique_ptr<AZ::BehaviorContext> m_behaviorContext;
|
||||
AZStd::unique_ptr<AZ::ComponentDescriptor> m_coreComponentDescriptor;
|
||||
AZStd::unique_ptr<AZ::ComponentDescriptor> m_gameliftClientComponentDescriptor;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AWSGameLiftClientFixture::SetUp();
|
||||
|
||||
m_serializeContext = AZStd::make_unique<AZ::SerializeContext>();
|
||||
m_serializeContext->CreateEditContext();
|
||||
m_behaviorContext = AZStd::make_unique<AZ::BehaviorContext>();
|
||||
m_coreComponentDescriptor.reset(AWSCoreSystemComponentMock::CreateDescriptor());
|
||||
m_gameliftClientComponentDescriptor.reset(TestAWSGameLiftClientSystemComponent::CreateDescriptor());
|
||||
m_gameliftClientComponentDescriptor->Reflect(m_serializeContext.get());
|
||||
m_gameliftClientComponentDescriptor->Reflect(m_behaviorContext.get());
|
||||
|
||||
m_entity = aznew AZ::Entity();
|
||||
m_coreSystemComponent = AZStd::make_unique<AWSCoreSystemComponentMock>();
|
||||
m_entity->AddComponent(m_coreSystemComponent.get());
|
||||
m_gameliftClientSystemComponent = AZStd::make_unique<TestAWSGameLiftClientSystemComponent>();
|
||||
m_gameliftClientSystemComponent->SetUpMockManager();
|
||||
m_entity->AddComponent(m_gameliftClientSystemComponent.get());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_entity->RemoveComponent(m_gameliftClientSystemComponent.get());
|
||||
m_gameliftClientSystemComponent.reset();
|
||||
m_entity->RemoveComponent(m_coreSystemComponent.get());
|
||||
m_coreSystemComponent.reset();
|
||||
delete m_entity;
|
||||
m_entity = nullptr;
|
||||
|
||||
m_gameliftClientComponentDescriptor.reset();
|
||||
m_coreComponentDescriptor.reset();
|
||||
m_behaviorContext.reset();
|
||||
m_serializeContext.reset();
|
||||
|
||||
AWSGameLiftClientFixture::TearDown();
|
||||
}
|
||||
|
||||
public:
|
||||
AZStd::unique_ptr<AWSCoreSystemComponentMock> m_coreSystemComponent;
|
||||
AZStd::unique_ptr<TestAWSGameLiftClientSystemComponent> m_gameliftClientSystemComponent;
|
||||
AZ::Entity* m_entity;
|
||||
};
|
||||
|
||||
TEST_F(AWSGameLiftClientSystemComponentTest, ActivateDeactivate_Call_GameLiftClientManagerGetsInvoked)
|
||||
{
|
||||
m_entity->Init();
|
||||
EXPECT_CALL(*(m_gameliftClientSystemComponent->m_gameliftClientManagerMockPtr), ActivateManager()).Times(1);
|
||||
m_entity->Activate();
|
||||
|
||||
EXPECT_CALL(*(m_gameliftClientSystemComponent->m_gameliftClientManagerMockPtr), DeactivateManager()).Times(1);
|
||||
m_entity->Deactivate();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV);
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Activity/AWSGameLiftCreateSessionActivity.h>
|
||||
#include <AWSGameLiftClientFixture.h>
|
||||
|
||||
using namespace AWSGameLift;
|
||||
|
||||
using AWSGameLiftCreateSessionActivityTest = AWSGameLiftClientFixture;
|
||||
|
||||
TEST_F(AWSGameLiftCreateSessionActivityTest, BuildAWSGameLiftCreateGameSessionRequest_Call_GetExpectedResult)
|
||||
{
|
||||
AWSGameLiftCreateSessionRequest request;
|
||||
request.m_creatorId = "dummyCreatorId";
|
||||
request.m_sessionName = "dummySessionName";
|
||||
request.m_maxPlayer = 1;
|
||||
request.m_sessionProperties.emplace("dummyKey", "dummyValue");
|
||||
request.m_aliasId = "dummyAliasId";
|
||||
request.m_fleetId = "dummyFleetId";
|
||||
request.m_idempotencyToken = "dummyIdempotencyToken";
|
||||
auto awsRequest = CreateSessionActivity::BuildAWSGameLiftCreateGameSessionRequest(request);
|
||||
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetCreatorId().c_str(), request.m_creatorId.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetName().c_str(), request.m_sessionName.c_str()) == 0);
|
||||
EXPECT_TRUE(awsRequest.GetMaximumPlayerSessionCount() == request.m_maxPlayer);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetGameProperties()[0].GetKey().c_str(), request.m_sessionProperties.begin()->first.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetGameProperties()[0].GetValue().c_str(), request.m_sessionProperties.begin()->second.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetAliasId().c_str(), request.m_aliasId.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetFleetId().c_str(), request.m_fleetId.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetIdempotencyToken().c_str(), request.m_idempotencyToken.c_str()) == 0);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftCreateSessionActivityTest, ValidateCreateSessionRequest_CallWithBaseType_GetFalseResult)
|
||||
{
|
||||
auto result = CreateSessionActivity::ValidateCreateSessionRequest(AzFramework::CreateSessionRequest());
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftCreateSessionActivityTest, ValidateCreateSessionRequest_CallWithNegativeMaxPlayer_GetFalseResult)
|
||||
{
|
||||
AWSGameLiftCreateSessionRequest request;
|
||||
request.m_maxPlayer = -1;
|
||||
|
||||
auto result = CreateSessionActivity::ValidateCreateSessionRequest(request);
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftCreateSessionActivityTest, ValidateCreateSessionRequest_CallWithoutAliasOrFleetId_GetFalseResult)
|
||||
{
|
||||
AWSGameLiftCreateSessionRequest request;
|
||||
request.m_maxPlayer = 1;
|
||||
auto result = CreateSessionActivity::ValidateCreateSessionRequest(request);
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftCreateSessionActivityTest, ValidateCreateSessionRequest_CallWithAliasId_GetTrueResult)
|
||||
{
|
||||
AWSGameLiftCreateSessionRequest request;
|
||||
request.m_maxPlayer = 1;
|
||||
request.m_aliasId = "dummyAliasId";
|
||||
auto result = CreateSessionActivity::ValidateCreateSessionRequest(request);
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftCreateSessionActivityTest, ValidateCreateSessionRequest_CallWithFleetId_GetTrueResult)
|
||||
{
|
||||
AWSGameLiftCreateSessionRequest request;
|
||||
request.m_maxPlayer = 1;
|
||||
request.m_fleetId = "dummyFleetId";
|
||||
auto result = CreateSessionActivity::ValidateCreateSessionRequest(request);
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AWSGameLiftClientFixture.h>
|
||||
#include <Activity/AWSGameLiftCreateSessionOnQueueActivity.h>
|
||||
|
||||
using namespace AWSGameLift;
|
||||
|
||||
using AWSGameLiftCreateSessionOnQueueActivityTest = AWSGameLiftClientFixture;
|
||||
|
||||
TEST_F(AWSGameLiftCreateSessionOnQueueActivityTest, BuildAWSGameLiftCreateGameSessionRequest_Call_GetExpectedResult)
|
||||
{
|
||||
AWSGameLiftCreateSessionOnQueueRequest request;
|
||||
request.m_sessionName = "dummySessionName";
|
||||
request.m_maxPlayer = 1;
|
||||
request.m_sessionProperties.emplace("dummyKey", "dummyValue");
|
||||
request.m_queueName = "dummyQueueName";
|
||||
request.m_placementId = "dummyPlacementId";
|
||||
auto awsRequest = CreateSessionOnQueueActivity::BuildAWSGameLiftStartGameSessionPlacementRequest(request);
|
||||
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetGameSessionName().c_str(), request.m_sessionName.c_str()) == 0);
|
||||
EXPECT_TRUE(awsRequest.GetMaximumPlayerSessionCount() == request.m_maxPlayer);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetGameProperties()[0].GetKey().c_str(), request.m_sessionProperties.begin()->first.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetGameProperties()[0].GetValue().c_str(), request.m_sessionProperties.begin()->second.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetGameSessionQueueName().c_str(), request.m_queueName.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetPlacementId().c_str(), request.m_placementId.c_str()) == 0);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftCreateSessionOnQueueActivityTest, ValidateCreateSessionOnQueueRequest_CallWithBaseType_GetFalseResult)
|
||||
{
|
||||
auto result = CreateSessionOnQueueActivity::ValidateCreateSessionOnQueueRequest(AzFramework::CreateSessionRequest());
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftCreateSessionOnQueueActivityTest, ValidateCreateSessionOnQueueRequest_CallWithNegativeMaxPlayer_GetFalseResult)
|
||||
{
|
||||
AWSGameLiftCreateSessionOnQueueRequest request;
|
||||
request.m_maxPlayer = -1;
|
||||
|
||||
auto result = CreateSessionOnQueueActivity::ValidateCreateSessionOnQueueRequest(request);
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftCreateSessionOnQueueActivityTest, ValidateCreateSessionOnQueueRequest_CallWithoutQueueName_GetFalseResult)
|
||||
{
|
||||
AWSGameLiftCreateSessionOnQueueRequest request;
|
||||
request.m_maxPlayer = 1;
|
||||
request.m_placementId = "dummyPlacementId";
|
||||
auto result = CreateSessionOnQueueActivity::ValidateCreateSessionOnQueueRequest(request);
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftCreateSessionOnQueueActivityTest, ValidateCreateSessionOnQueueRequest_CallWithoutPlacementId_GetFalseResult)
|
||||
{
|
||||
AWSGameLiftCreateSessionOnQueueRequest request;
|
||||
request.m_maxPlayer = 1;
|
||||
request.m_queueName = "dummyQueueName";
|
||||
auto result = CreateSessionOnQueueActivity::ValidateCreateSessionOnQueueRequest(request);
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftCreateSessionOnQueueActivityTest, ValidateCreateSessionOnQueueRequest_CallWithValidRequest_GetTrueResult)
|
||||
{
|
||||
AWSGameLiftCreateSessionOnQueueRequest request;
|
||||
request.m_maxPlayer = 1;
|
||||
request.m_queueName = "dummyQueueName";
|
||||
request.m_placementId = "dummyPlacementId";
|
||||
auto result = CreateSessionOnQueueActivity::ValidateCreateSessionOnQueueRequest(request);
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AWSGameLiftClientFixture.h>
|
||||
#include <Activity/AWSGameLiftJoinSessionActivity.h>
|
||||
|
||||
using namespace AWSGameLift;
|
||||
|
||||
using AWSGameLiftJoinSessionActivityTest = AWSGameLiftClientFixture;
|
||||
|
||||
TEST_F(AWSGameLiftJoinSessionActivityTest, BuildAWSGameLiftCreatePlayerSessionRequest_Call_GetExpectedResult)
|
||||
{
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_playerData = "dummyPlayerData";
|
||||
request.m_playerId = "dummyPlayerId";
|
||||
request.m_sessionId = "dummySessionId";
|
||||
auto awsRequest = JoinSessionActivity::BuildAWSGameLiftCreatePlayerSessionRequest(request);
|
||||
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetPlayerData().c_str(), request.m_playerData.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetPlayerId().c_str(), request.m_playerId.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetGameSessionId().c_str(), request.m_sessionId.c_str()) == 0);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftJoinSessionActivityTest, BuildSessionConnectionConfig_Call_GetExpectedResult)
|
||||
{
|
||||
Aws::GameLift::Model::PlayerSession playerSession;
|
||||
playerSession.SetIpAddress("dummyIpAddress");
|
||||
playerSession.SetPlayerSessionId("dummyPlayerSessionId");
|
||||
playerSession.SetPort(123);
|
||||
Aws::GameLift::Model::CreatePlayerSessionResult createPlayerSessionResult;
|
||||
createPlayerSessionResult.SetPlayerSession(playerSession);
|
||||
Aws::GameLift::Model::CreatePlayerSessionOutcome createPlayerSessionOutcome(createPlayerSessionResult);
|
||||
auto connectionConfig = JoinSessionActivity::BuildSessionConnectionConfig(createPlayerSessionOutcome);
|
||||
|
||||
EXPECT_TRUE(strcmp(connectionConfig.m_ipAddress.c_str(), playerSession.GetIpAddress().c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(connectionConfig.m_playerSessionId.c_str(), playerSession.GetPlayerSessionId().c_str()) == 0);
|
||||
EXPECT_TRUE(connectionConfig.m_port == playerSession.GetPort());
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftJoinSessionActivityTest, ValidateJoinSessionRequest_CallWithBaseType_GetFalseResult)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto result = JoinSessionActivity::ValidateJoinSessionRequest(AzFramework::JoinSessionRequest());
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftJoinSessionActivityTest, ValidateJoinSessionRequest_CallWithEmptyPlayerId_GetFalseResult)
|
||||
{
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_sessionId = "dummySessionId";
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto result = JoinSessionActivity::ValidateJoinSessionRequest(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftJoinSessionActivityTest, ValidateJoinSessionRequest_CallWithEmptySessionId_GetFalseResult)
|
||||
{
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_playerId = "dummyPlayerId";
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto result = JoinSessionActivity::ValidateJoinSessionRequest(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftJoinSessionActivityTest, ValidateJoinSessionRequest_CallWithPlayerAndSessionId_GetTrueResult)
|
||||
{
|
||||
AWSGameLiftJoinSessionRequest request;
|
||||
request.m_playerId = "dummyPlayerId";
|
||||
request.m_sessionId = "dummySessionId";
|
||||
auto result = JoinSessionActivity::ValidateJoinSessionRequest(request);
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzFramework/Session/SessionConfig.h>
|
||||
|
||||
#include <Activity/AWSGameLiftSearchSessionsActivity.h>
|
||||
#include <AWSGameLiftClientFixture.h>
|
||||
#include <AWSGameLiftSessionConstants.h>
|
||||
|
||||
using namespace AWSGameLift;
|
||||
|
||||
using AWSGameLiftSearchSessionsActivityTest = AWSGameLiftClientFixture;
|
||||
|
||||
TEST_F(AWSGameLiftSearchSessionsActivityTest, BuildAWSGameLiftSearchGameSessionsRequest_Call_GetExpectedResult)
|
||||
{
|
||||
AWSGameLiftSearchSessionsRequest request;
|
||||
request.m_aliasId = "dummyAliasId";
|
||||
request.m_fleetId = "dummyFleetId";
|
||||
request.m_location = "dummyLocation";
|
||||
request.m_filterExpression = "dummyFilterExpression";
|
||||
request.m_sortExpression = "dummySortExpression";
|
||||
request.m_maxResult = 1;
|
||||
request.m_nextToken = "dummyNextToken";
|
||||
|
||||
auto awsRequest = SearchSessionsActivity::BuildAWSGameLiftSearchGameSessionsRequest(request);
|
||||
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetFleetId().c_str(), request.m_fleetId.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetAliasId().c_str(), request.m_aliasId.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetFilterExpression().c_str(), request.m_filterExpression.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetSortExpression().c_str(), request.m_sortExpression.c_str()) == 0);
|
||||
EXPECT_TRUE(awsRequest.GetLimit() == request.m_maxResult);
|
||||
EXPECT_TRUE(strcmp(awsRequest.GetNextToken().c_str(), request.m_nextToken.c_str()) == 0);
|
||||
// TODO: Update the AWS Native SDK to get the new request attributes.
|
||||
//EXPECT_TRUE(strcmp(awsRequest.GetLocation().c_str(), request.m_location.c_str()) == 0);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftSearchSessionsActivityTest, ValidateSearchSessionsRequest_CallWithBaseType_GetFalseResult)
|
||||
{
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto result = SearchSessionsActivity::ValidateSearchSessionsRequest(AzFramework::SearchSessionsRequest());
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftSearchSessionsActivityTest, ValidateSearchSessionsRequest_CallWithoutAliasOrFleetId_GetFalseResult)
|
||||
{
|
||||
AWSGameLiftSearchSessionsRequest request;
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
auto result = SearchSessionsActivity::ValidateSearchSessionsRequest(request);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
|
||||
EXPECT_FALSE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftSearchSessionsActivityTest, ValidateSearchSessionsRequest_CallWithAliasId_GetTrueResult)
|
||||
{
|
||||
AWSGameLiftSearchSessionsRequest request;
|
||||
request.m_aliasId = "dummyAliasId";
|
||||
auto result = SearchSessionsActivity::ValidateSearchSessionsRequest(request);
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftSearchSessionsActivityTest, ValidateSearchSessionsRequest_CallWithFleetId_GetTrueResult)
|
||||
{
|
||||
AWSGameLiftSearchSessionsRequest request;
|
||||
request.m_fleetId = "dummyFleetId";
|
||||
auto result = SearchSessionsActivity::ValidateSearchSessionsRequest(request);
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
|
||||
TEST_F(AWSGameLiftSearchSessionsActivityTest, ParseResponse_Call_GetExpectedResult)
|
||||
{
|
||||
Aws::GameLift::Model::GameProperty gameProperty;
|
||||
gameProperty.SetKey("dummyKey");
|
||||
gameProperty.SetValue("dummyValue");
|
||||
Aws::Vector<Aws::GameLift::Model::GameProperty> gameProperties = { gameProperty };
|
||||
|
||||
Aws::GameLift::Model::GameSession gameSession;
|
||||
gameSession.SetCreationTime(Aws::Utils::DateTime(0.0));
|
||||
gameSession.SetTerminationTime(Aws::Utils::DateTime(0.0));
|
||||
gameSession.SetCreatorId("dummyCreatorId");
|
||||
gameSession.SetGameProperties(gameProperties);
|
||||
gameSession.SetGameSessionId("dummyGameSessionId");
|
||||
gameSession.SetName("dummyGameSessionName");
|
||||
gameSession.SetIpAddress("dummyIpAddress");
|
||||
gameSession.SetPort(0);
|
||||
gameSession.SetMaximumPlayerSessionCount(2);
|
||||
gameSession.SetCurrentPlayerSessionCount(1);
|
||||
gameSession.SetStatus(Aws::GameLift::Model::GameSessionStatus::TERMINATED);
|
||||
gameSession.SetStatusReason(Aws::GameLift::Model::GameSessionStatusReason::INTERRUPTED);
|
||||
// TODO: Update the AWS Native SDK to set the new game session attributes.
|
||||
//gameSession.SetDnsName("dummyDnsName");
|
||||
Aws::Vector<Aws::GameLift::Model::GameSession> gameSessions = { gameSession };
|
||||
|
||||
Aws::GameLift::Model::SearchGameSessionsResult result;
|
||||
result.SetNextToken("dummyNextToken");
|
||||
result.SetGameSessions(gameSessions);
|
||||
|
||||
auto response = SearchSessionsActivity::ParseResponse(result);
|
||||
|
||||
EXPECT_TRUE(strcmp(response.m_nextToken.c_str(), result.GetNextToken().c_str()) == 0);
|
||||
EXPECT_EQ(response.m_sessionConfigs.size(), 1);
|
||||
|
||||
const auto& sessionConfig = response.m_sessionConfigs[0];
|
||||
EXPECT_EQ(gameSession.GetCreationTime().Millis(), sessionConfig.m_creationTime);
|
||||
EXPECT_EQ(gameSession.GetTerminationTime().Millis(), sessionConfig.m_terminationTime);
|
||||
EXPECT_TRUE(strcmp(gameSession.GetCreatorId().c_str(), sessionConfig.m_creatorId.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(gameSession.GetGameSessionId().c_str(), sessionConfig.m_sessionId.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(gameSession.GetName().c_str(), sessionConfig.m_sessionName.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(gameSession.GetIpAddress().c_str(), sessionConfig.m_ipAddress.c_str()) == 0);
|
||||
EXPECT_EQ(gameSession.GetPort(), 0);
|
||||
EXPECT_EQ(gameSession.GetMaximumPlayerSessionCount(), 2);
|
||||
EXPECT_EQ(gameSession.GetCurrentPlayerSessionCount(), 1);
|
||||
EXPECT_TRUE(strcmp(AWSGameLiftSessionStatusNames[(int)gameSession.GetStatus()], sessionConfig.m_status.c_str()) == 0);
|
||||
EXPECT_TRUE(strcmp(AWSGameLiftSessionStatusReasons[(int)gameSession.GetStatusReason()], sessionConfig.m_statusReason.c_str()) == 0);
|
||||
// TODO: Update the AWS Native SDK to get the new game session attributes.
|
||||
// EXPECT_TRUE(strcmp(gameSession.GetDnsName().c_str(), sessionConfig.m_dnsName.c_str()) == 0);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Include/Request/AWSGameLiftCreateSessionOnQueueRequest.h
|
||||
Include/Request/AWSGameLiftCreateSessionRequest.h
|
||||
Include/Request/AWSGameLiftJoinSessionRequest.h
|
||||
Include/Request/AWSGameLiftSearchSessionsRequest.h
|
||||
Include/Request/IAWSGameLiftRequests.h
|
||||
Source/Activity/AWSGameLiftCreateSessionActivity.cpp
|
||||
Source/Activity/AWSGameLiftCreateSessionActivity.h
|
||||
Source/Activity/AWSGameLiftCreateSessionOnQueueActivity.cpp
|
||||
Source/Activity/AWSGameLiftCreateSessionOnQueueActivity.h
|
||||
Source/Activity/AWSGameLiftJoinSessionActivity.cpp
|
||||
Source/Activity/AWSGameLiftJoinSessionActivity.h
|
||||
Source/Activity/AWSGameLiftLeaveSessionActivity.cpp
|
||||
Source/Activity/AWSGameLiftLeaveSessionActivity.h
|
||||
Source/Activity/AWSGameLiftSearchSessionsActivity.cpp
|
||||
Source/Activity/AWSGameLiftSearchSessionsActivity.h
|
||||
Source/AWSGameLiftClientManager.cpp
|
||||
Source/AWSGameLiftClientManager.h
|
||||
Source/AWSGameLiftClientSystemComponent.cpp
|
||||
Source/AWSGameLiftClientSystemComponent.h
|
||||
Source/Request/AWSGameLiftCreateSessionOnQueueRequest.cpp
|
||||
Source/Request/AWSGameLiftCreateSessionRequest.cpp
|
||||
Source/Request/AWSGameLiftJoinSessionRequest.cpp
|
||||
Source/Request/AWSGameLiftSearchSessionsRequest.cpp
|
||||
)
|
||||
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Source/AWSGameLiftClientModule.cpp
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Tests/Activity/AWSGameLiftCreateSessionActivityTest.cpp
|
||||
Tests/Activity/AWSGameLiftCreateSessionOnQueueActivityTest.cpp
|
||||
Tests/Activity/AWSGameLiftJoinSessionActivityTest.cpp
|
||||
Tests/Activity/AWSGameLiftSearchSessionsActivityTest.cpp
|
||||
Tests/AWSGameLiftClientFixture.h
|
||||
Tests/AWSGameLiftClientManagerTest.cpp
|
||||
Tests/AWSGameLiftClientMocks.h
|
||||
Tests/AWSGameLiftClientSystemComponentTest.cpp
|
||||
Tests/AWSGameLiftClientTest.cpp
|
||||
)
|
||||
Reference in New Issue
Block a user