[LYN-4820] Add more logs for gamelift workflow (#1651)

* [LYN-4820] Add more logs for gamelift workflow

Signed-off-by: onecent1101 <liug@amazon.com>

* Address feedback

Signed-off-by: onecent1101 <liug@amazon.com>
monroegm-disable-blank-issue-2
Vincent Liu 5 years ago committed by GitHub
parent 06c65be40a
commit 43a0e89c20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -27,7 +27,7 @@ namespace AzFramework
AZStd::string m_ipAddress;
// The port number for the session.
uint16_t m_port;
uint16_t m_port = 0;
};
//! SessionConnectionConfig
@ -35,7 +35,7 @@ namespace AzFramework
struct PlayerConnectionConfig
{
// A unique identifier for player connection.
uint32_t m_playerConnectionId;
uint32_t m_playerConnectionId = 0;
// A unique identifier for registered player in session.
AZStd::string m_playerSessionId;

@ -37,7 +37,7 @@ namespace AzFramework
AZStd::string m_sessionName;
// The maximum number of players that can be connected simultaneously to the session.
uint64_t m_maxPlayer;
uint64_t m_maxPlayer = 0;
};
//! SearchSessionsRequest
@ -58,7 +58,7 @@ namespace AzFramework
AZStd::string m_sortExpression;
// The maximum number of results to return.
uint8_t m_maxResult;
uint8_t m_maxResult = 0;
// A token that indicates the start of the next sequential page of results.
AZStd::string m_nextToken;

@ -24,10 +24,10 @@ namespace AzFramework
virtual ~SessionConfig() = default;
// A time stamp indicating when this session was created. Format is a number expressed in Unix time as milliseconds.
uint64_t m_creationTime;
uint64_t m_creationTime = 0;
// A time stamp indicating when this data object was terminated. Same format as creation time.
uint64_t m_terminationTime;
uint64_t m_terminationTime = 0;
// A unique identifier for a player or entity creating the session.
AZStd::string m_creatorId;
@ -48,13 +48,13 @@ namespace AzFramework
AZStd::string m_ipAddress;
// The port number for the session.
uint16_t m_port;
uint16_t m_port = 0;
// The maximum number of players that can be connected simultaneously to the session.
uint64_t m_maxPlayer;
uint64_t m_maxPlayer = 0;
// Number of players currently in the session.
uint64_t m_currentPlayer;
uint64_t m_currentPlayer = 0;
// Current status of the session.
AZStd::string m_status;

@ -0,0 +1,34 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Activity/AWSGameLiftActivityUtils.h>
namespace AWSGameLift
{
namespace AWSGameLiftActivityUtils
{
void GetGameProperties(
const AZStd::unordered_map<AZStd::string, AZStd::string>& sessionProperties,
Aws::Vector<Aws::GameLift::Model::GameProperty>& outGameProperties,
AZStd::string& outGamePropertiesOutput)
{
for (auto iter = sessionProperties.begin(); iter != sessionProperties.end(); iter++)
{
Aws::GameLift::Model::GameProperty sessionProperty;
sessionProperty.SetKey(iter->first.c_str());
sessionProperty.SetValue(iter->second.c_str());
outGameProperties.push_back(sessionProperty);
outGamePropertiesOutput += AZStd::string::format("{Key=%s,Value=%s},", iter->first.c_str(), iter->second.c_str());
}
if (!outGamePropertiesOutput.empty())
{
outGamePropertiesOutput =
outGamePropertiesOutput.substr(0, outGamePropertiesOutput.size() - 1); // Trim last comma to fit array format
}
}
} // namespace AWSGameLiftActivityUtils
} // namespace AWSGameLift

@ -0,0 +1,24 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/string/string.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/gamelift/model/GameProperty.h>
namespace AWSGameLift
{
namespace AWSGameLiftActivityUtils
{
void GetGameProperties(
const AZStd::unordered_map<AZStd::string, AZStd::string>& sessionProperties,
Aws::Vector<Aws::GameLift::Model::GameProperty>& outGameProperties,
AZStd::string& outGamePropertiesOutput);
} // namespace AWSGameLiftActivityUtils
} // namespace AWSGameLift

@ -5,6 +5,7 @@
*
*/
#include <Activity/AWSGameLiftActivityUtils.h>
#include <Activity/AWSGameLiftCreateSessionActivity.h>
#include <AWSGameLiftSessionConstants.h>
@ -29,13 +30,12 @@ namespace AWSGameLift
{
request.SetIdempotencyToken(createSessionRequest.m_idempotencyToken.c_str());
}
for (auto iter = createSessionRequest.m_sessionProperties.begin();
iter != createSessionRequest.m_sessionProperties.end(); iter++)
AZStd::string propertiesOutput = "";
Aws::Vector<Aws::GameLift::Model::GameProperty> properties;
AWSGameLiftActivityUtils::GetGameProperties(createSessionRequest.m_sessionProperties, properties, propertiesOutput);
if (!properties.empty())
{
Aws::GameLift::Model::GameProperty sessionProperty;
sessionProperty.SetKey(iter->first.c_str());
sessionProperty.SetValue(iter->second.c_str());
request.AddGameProperties(sessionProperty);
request.SetGameProperties(properties);
}
// Required attributes
@ -49,6 +49,16 @@ namespace AWSGameLift
}
request.SetMaximumPlayerSessionCount(createSessionRequest.m_maxPlayer);
AZ_TracePrintf(AWSGameLiftCreateSessionActivityName,
"Built CreateGameSessionRequest with CreatorId=%s, Name=%s, IdempotencyToken=%s, GameProperties=%s, AliasId=%s, FleetId=%s and MaximumPlayerSessionCount=%d",
request.GetCreatorId().c_str(),
request.GetName().c_str(),
request.GetIdempotencyToken().c_str(),
AZStd::string::format("[%s]", propertiesOutput.c_str()).c_str(),
request.GetAliasId().c_str(),
request.GetFleetId().c_str(),
request.GetMaximumPlayerSessionCount());
return request;
}
@ -61,6 +71,7 @@ namespace AWSGameLift
AZStd::string result = "";
Aws::GameLift::Model::CreateGameSessionRequest request = BuildAWSGameLiftCreateGameSessionRequest(createSessionRequest);
auto createSessionOutcome = gameliftClient.CreateGameSession(request);
AZ_TracePrintf(AWSGameLiftCreateSessionActivityName, "CreateGameSession request against Amazon GameLift service is complete");
if (createSessionOutcome.IsSuccess())
{

@ -6,6 +6,7 @@
*/
#include <AWSGameLiftSessionConstants.h>
#include <Activity/AWSGameLiftActivityUtils.h>
#include <Activity/AWSGameLiftCreateSessionOnQueueActivity.h>
namespace AWSGameLift
@ -21,13 +22,12 @@ namespace AWSGameLift
{
request.SetGameSessionName(createSessionOnQueueRequest.m_sessionName.c_str());
}
for (auto iter = createSessionOnQueueRequest.m_sessionProperties.begin();
iter != createSessionOnQueueRequest.m_sessionProperties.end(); iter++)
AZStd::string propertiesOutput = "";
Aws::Vector<Aws::GameLift::Model::GameProperty> properties;
AWSGameLiftActivityUtils::GetGameProperties(createSessionOnQueueRequest.m_sessionProperties, properties, propertiesOutput);
if (!properties.empty())
{
Aws::GameLift::Model::GameProperty sessionProperty;
sessionProperty.SetKey(iter->first.c_str());
sessionProperty.SetValue(iter->second.c_str());
request.AddGameProperties(sessionProperty);
request.SetGameProperties(properties);
}
// Required attributes
@ -35,6 +35,14 @@ namespace AWSGameLift
request.SetMaximumPlayerSessionCount(createSessionOnQueueRequest.m_maxPlayer);
request.SetPlacementId(createSessionOnQueueRequest.m_placementId.c_str());
AZ_TracePrintf(AWSGameLiftCreateSessionOnQueueActivityName,
"Built StartGameSessionPlacementRequest with GameSessionName=%s, GameProperties=%s, GameSessionQueueName=%s, MaximumPlayerSessionCount=%d and PlacementId=%s",
request.GetGameSessionName().c_str(),
AZStd::string::format("[%s]", propertiesOutput.c_str()).c_str(),
request.GetGameSessionQueueName().c_str(),
request.GetMaximumPlayerSessionCount(),
request.GetPlacementId().c_str());
return request;
}
@ -49,6 +57,8 @@ namespace AWSGameLift
Aws::GameLift::Model::StartGameSessionPlacementRequest request =
BuildAWSGameLiftStartGameSessionPlacementRequest(createSessionOnQueueRequest);
auto createSessionOnQueueOutcome = gameliftClient.StartGameSessionPlacement(request);
AZ_TracePrintf(AWSGameLiftCreateSessionOnQueueActivityName,
"StartGameSessionPlacement request against Amazon GameLift service is complete.");
if (createSessionOnQueueOutcome.IsSuccess())
{

@ -27,6 +27,13 @@ namespace AWSGameLift
// Required attributes
request.SetPlayerId(joinSessionRequest.m_playerId.c_str());
request.SetGameSessionId(joinSessionRequest.m_sessionId.c_str());
AZ_TracePrintf(AWSGameLiftJoinSessionActivityName,
"Built CreatePlayerSessionRequest with PlayerData=%s, PlayerId=%s and GameSessionId=%s",
request.GetPlayerData().c_str(),
request.GetPlayerId().c_str(),
request.GetGameSessionId().c_str());
return request;
}
@ -40,6 +47,13 @@ namespace AWSGameLift
sessionConnectionConfig.m_ipAddress = createPlayerSessionResult.GetPlayerSession().GetIpAddress().c_str();
sessionConnectionConfig.m_playerSessionId = createPlayerSessionResult.GetPlayerSession().GetPlayerSessionId().c_str();
sessionConnectionConfig.m_port = createPlayerSessionResult.GetPlayerSession().GetPort();
AZ_TracePrintf(AWSGameLiftJoinSessionActivityName,
"Built SessionConnectionConfig with IpAddress=%s, PlayerSessionId=%s and Port=%d",
sessionConnectionConfig.m_ipAddress.c_str(),
sessionConnectionConfig.m_playerSessionId.c_str(),
sessionConnectionConfig.m_port);
return sessionConnectionConfig;
}
@ -54,6 +68,8 @@ namespace AWSGameLift
Aws::GameLift::Model::CreatePlayerSessionRequest request =
BuildAWSGameLiftCreatePlayerSessionRequest(joinSessionRequest);
auto createPlayerSessionOutcome = gameliftClient.CreatePlayerSession(request);
AZ_TracePrintf(AWSGameLiftJoinSessionActivityName,
"CreatePlayerSession request for player %s against Amazon GameLift service is complete", joinSessionRequest.m_playerId.c_str());
if (!createPlayerSessionOutcome.IsSuccess())
{
@ -72,11 +88,13 @@ namespace AWSGameLift
auto clientRequestHandler = AZ::Interface<AzFramework::ISessionHandlingClientRequests>::Get();
if (clientRequestHandler)
{
AZ_TracePrintf(AWSGameLiftJoinSessionActivityName, "Requesting player to connect to game session ...");
AzFramework::SessionConnectionConfig sessionConnectionConfig =
BuildSessionConnectionConfig(createPlayerSessionOutcome);
AZ_TracePrintf(AWSGameLiftJoinSessionActivityName,
"Requesting and validating player session %s to connect to game session ...", sessionConnectionConfig.m_playerSessionId.c_str());
result = clientRequestHandler->RequestPlayerJoinSession(sessionConnectionConfig);
AZ_TracePrintf(AWSGameLiftJoinSessionActivityName, "Started connection process, and connection validation is in process.");
}
else
{

@ -19,9 +19,9 @@ namespace AWSGameLift
auto clientRequestHandler = AZ::Interface<AzFramework::ISessionHandlingClientRequests>::Get();
if (clientRequestHandler)
{
AZ_TracePrintf(AWSGameLiftLeaveSessionActivityName, "Requesting to leave the current session...");
AZ_TracePrintf(AWSGameLiftLeaveSessionActivityName, "Requesting player to leave the current session ...");
clientRequestHandler->RequestPlayerLeaveSession();
AZ_TracePrintf(AWSGameLiftLeaveSessionActivityName, "Started disconnect process, and player clean up is in process.");
}
else
{

@ -35,6 +35,7 @@ namespace AWSGameLift
{
request.SetNextToken(searchSessionsRequest.m_nextToken.c_str());
}
// Required attributes
if (!searchSessionsRequest.m_aliasId.empty())
{
@ -46,6 +47,16 @@ namespace AWSGameLift
}
// TODO: Update the AWS Native SDK to accept the new request parameter.
//request.SetLocation(searchSessionsRequest.m_location.c_str());
AZ_TracePrintf(AWSGameLiftSearchSessionsActivityName,
"Built SearchGameSessionsRequest with FilterExpression=%s, SortExpression=%s, Limit=%d, NextToken=%s, AliasId=%s and FleetId=%s",
request.GetFilterExpression().c_str(),
request.GetSortExpression().c_str(),
request.GetLimit(),
request.GetNextToken().c_str(),
request.GetAliasId().c_str(),
request.GetFleetId().c_str());
return request;
}
@ -58,6 +69,7 @@ namespace AWSGameLift
AzFramework::SearchSessionsResponse response;
Aws::GameLift::Model::SearchGameSessionsRequest request = BuildAWSGameLiftSearchGameSessionsRequest(searchSessionsRequest);
Aws::GameLift::Model::SearchGameSessionsOutcome outcome = gameliftClient.SearchGameSessions(request);
AZ_TracePrintf(AWSGameLiftSearchSessionsActivityName, "SearchGameSessions request against Amazon GameLift service is complete");
if (outcome.IsSuccess())
{

@ -11,6 +11,8 @@ set(FILES
Include/Request/AWSGameLiftJoinSessionRequest.h
Include/Request/AWSGameLiftSearchSessionsRequest.h
Include/Request/IAWSGameLiftRequests.h
Source/Activity/AWSGameLiftActivityUtils.cpp
Source/Activity/AWSGameLiftActivityUtils.h
Source/Activity/AWSGameLiftCreateSessionActivity.cpp
Source/Activity/AWSGameLiftCreateSessionActivity.h
Source/Activity/AWSGameLiftCreateSessionOnQueueActivity.cpp

@ -106,8 +106,10 @@ namespace AWSGameLift
return false;
}
AZ_TracePrintf(AWSGameLiftServerManagerName, "Initiating Amazon GameLift Server SDK...");
AZ_TracePrintf(AWSGameLiftServerManagerName, "Initiating Amazon GameLift Server SDK ...");
Aws::GameLift::Server::InitSDKOutcome initOutcome = m_gameLiftServerSDKWrapper->InitSDK();
AZ_TracePrintf(AWSGameLiftServerManagerName, "InitSDK request against Amazon GameLift service is complete.");
m_serverSDKInitialized = initOutcome.IsSuccess();
AZ_Error(AWSGameLiftServerManagerName, m_serverSDKInitialized,
@ -138,8 +140,10 @@ namespace AWSGameLift
return;
}
AZ_TracePrintf(AWSGameLiftServerManagerName, "Notifying GameLift server process is ending...");
AZ_TracePrintf(AWSGameLiftServerManagerName, "Notifying GameLift server process is ending ...");
Aws::GameLift::GenericOutcome processEndingOutcome = m_gameLiftServerSDKWrapper->ProcessEnding();
AZ_TracePrintf(AWSGameLiftServerManagerName, "ProcessEnding request against Amazon GameLift service is complete.");
bool processEndingIsSuccess = processEndingOutcome.IsSuccess();
AZ_Error(AWSGameLiftServerManagerName, processEndingIsSuccess, AWSGameLiftServerProcessEndingErrorMessage,
@ -155,7 +159,12 @@ namespace AWSGameLift
return;
}
AZ_TracePrintf(AWSGameLiftServerManagerName,
"Removing player session %s from Amazon GameLift service ...", playerSessionId.c_str());
Aws::GameLift::GenericOutcome disconnectOutcome = m_gameLiftServerSDKWrapper->RemovePlayerSession(playerSessionId);
AZ_TracePrintf(AWSGameLiftServerManagerName,
"RemovePlayerSession request for player session %s against Amazon GameLift service is complete.", playerSessionId.c_str());
AZ_Error(AWSGameLiftServerManagerName, disconnectOutcome.IsSuccess(), AWSGameLiftServerRemovePlayerSessionErrorMessage,
playerSessionId.c_str(), disconnectOutcome.GetError().GetErrorMessage().c_str());
}
@ -188,8 +197,9 @@ namespace AWSGameLift
AZStd::bind(&AWSGameLiftServerManager::OnHealthCheck, this), desc.m_port,
Aws::GameLift::Server::LogParameters(logPaths));
AZ_TracePrintf(AWSGameLiftServerManagerName, "Notifying GameLift server process is ready...");
AZ_TracePrintf(AWSGameLiftServerManagerName, "Notifying GameLift server process is ready ...");
auto processReadyOutcome = m_gameLiftServerSDKWrapper->ProcessReady(processReadyParameter);
AZ_TracePrintf(AWSGameLiftServerManagerName, "ProcessReady request against Amazon GameLift service is complete.");
if (!processReadyOutcome.IsSuccess())
{
@ -213,8 +223,9 @@ namespace AWSGameLift
if (createSessionResult)
{
AZ_TracePrintf(AWSGameLiftServerManagerName, "Activating GameLift game session...");
AZ_TracePrintf(AWSGameLiftServerManagerName, "Activating GameLift game session ...");
Aws::GameLift::GenericOutcome activationOutcome = m_gameLiftServerSDKWrapper->ActivateGameSession();
AZ_TracePrintf(AWSGameLiftServerManagerName, "ActivateGameSession request against Amazon GameLift service is complete.");
if (activationOutcome.IsSuccess())
{
@ -240,7 +251,7 @@ namespace AWSGameLift
void AWSGameLiftServerManager::OnProcessTerminate()
{
AZ_TracePrintf(AWSGameLiftServerManagerName, "GameLift is shutting down server process...");
AZ_TracePrintf(AWSGameLiftServerManagerName, "GameLift is shutting down server process ...");
HandleDestroySession();
}
@ -299,8 +310,11 @@ namespace AWSGameLift
return false;
}
AZ_TracePrintf(AWSGameLiftServerManagerName, "Attempting to accept player session connection with Amazon GameLift service...");
AZ_TracePrintf(AWSGameLiftServerManagerName,
"Attempting to accept player session %s connection with Amazon GameLift service ...", playerSessionId.c_str());
auto acceptPlayerSessionOutcome = m_gameLiftServerSDKWrapper->AcceptPlayerSession(playerSessionId.c_str());
AZ_TracePrintf(AWSGameLiftServerManagerName,
"AcceptPlayerSession request for player session %s against Amazon GameLift service is complete.", playerSessionId.c_str());
if (!acceptPlayerSessionOutcome.IsSuccess())
{

Loading…
Cancel
Save