Merge 'gameliftfeature' branch into 'development' branch (#1534)

This commit is contained in:
Vincent Liu
2021-06-24 09:13:35 -07:00
committed by GitHub
parent 5ec274d800
commit 149cb2e2f2
70 changed files with 5914 additions and 0 deletions
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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