Lesson 35 - Get Compute Auth Token Working
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Logging/LogVerbosity.h>
|
||||
#include "aws/gamelift/core/logging.h"
|
||||
|
||||
namespace Convertors
|
||||
{
|
||||
inline ELogVerbosity::Type FromAwsLogLevelToUe(unsigned int AwsLogLevel)
|
||||
{
|
||||
using namespace GameLift::Logger;
|
||||
|
||||
Level EnumAwsLogLevel = Level(AwsLogLevel);
|
||||
|
||||
switch (AwsLogLevel)
|
||||
{
|
||||
case Level::Verbose: return ELogVerbosity::Log;
|
||||
case Level::Info: return ELogVerbosity::Display;
|
||||
case Level::Warning: return ELogVerbosity::Warning;
|
||||
case Level::Error: return ELogVerbosity::Error;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ELogVerbosity::VeryVerbose;
|
||||
}
|
||||
} // namespace Convertors
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace Logs
|
||||
{
|
||||
class MessageStorage
|
||||
{
|
||||
public:
|
||||
void Set(const char* NewMessage)
|
||||
{
|
||||
std::lock_guard<std::mutex> Guard(Mutex);
|
||||
Message = Convertors::ASToFS(NewMessage);
|
||||
}
|
||||
|
||||
void Set(FString&& NewMessage)
|
||||
{
|
||||
std::lock_guard<std::mutex> Guard(Mutex);
|
||||
Message = std::move(NewMessage);
|
||||
}
|
||||
|
||||
void Set(const FText& NewMessage)
|
||||
{
|
||||
std::lock_guard<std::mutex> Guard(Mutex);
|
||||
Message = NewMessage.ToString();
|
||||
}
|
||||
|
||||
FString Get()
|
||||
{
|
||||
std::lock_guard<std::mutex> Guard(Mutex);
|
||||
return Message;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
std::lock_guard<std::mutex> Guard(Mutex);
|
||||
Message.Reset();
|
||||
}
|
||||
|
||||
private:
|
||||
FString Message = {};
|
||||
std::mutex Mutex = {};
|
||||
};
|
||||
} // namespace Logs
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Utils/LogLevelConvertors.h"
|
||||
|
||||
namespace Logs
|
||||
{
|
||||
template<typename TextChar>
|
||||
inline auto PrintAwsLog(unsigned int Level, const char* Message, int Size, TextChar* Tag)
|
||||
{
|
||||
#define PRINT_LOG_AND_EXIT(__x__) UE_LOG(GameLiftCoreLog, __x__, TEXT("%s %s"), Tag, *FString(Message)); return UeLogLevel
|
||||
|
||||
auto UeLogLevel = Convertors::FromAwsLogLevelToUe(Level);
|
||||
|
||||
switch (UeLogLevel)
|
||||
{
|
||||
case ELogVerbosity::Log: PRINT_LOG_AND_EXIT(Log);
|
||||
case ELogVerbosity::Display: PRINT_LOG_AND_EXIT(Display);
|
||||
case ELogVerbosity::Warning: PRINT_LOG_AND_EXIT(Warning);
|
||||
case ELogVerbosity::Error: PRINT_LOG_AND_EXIT(Error);
|
||||
}
|
||||
|
||||
PRINT_LOG_AND_EXIT(VeryVerbose);
|
||||
|
||||
#undef PRINT_LOG
|
||||
}
|
||||
} // namespace Logs
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <Containers/StringConv.h>
|
||||
|
||||
namespace Convertors
|
||||
{
|
||||
inline std::string FSToStdS(const FString & String)
|
||||
{
|
||||
if (String.IsEmpty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto CastedString = StringCast<ANSICHAR>(*String);
|
||||
auto* Chars = CastedString.Get();
|
||||
return std::string(Chars, strlen(Chars));
|
||||
}
|
||||
|
||||
inline FString ASToFS(const char* RawString)
|
||||
{
|
||||
return FString(StringCast<TCHAR>(RawString).Get());
|
||||
}
|
||||
} // namespace Convertors
|
||||
@@ -0,0 +1,61 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <Interfaces/IPluginManager.h>
|
||||
|
||||
#include "GameLiftCoreConstants.h"
|
||||
|
||||
namespace Paths
|
||||
{
|
||||
inline const auto& PluginRootPath()
|
||||
{
|
||||
static FString PluginRootPath =
|
||||
FPaths::ConvertRelativePathToFull(*IPluginManager::Get().FindPlugin(Core::sGameLiftPluginName)->GetBaseDir());
|
||||
return PluginRootPath;
|
||||
}
|
||||
|
||||
inline const auto& CloudFormationRootPath()
|
||||
{
|
||||
static FString CloudFormationRootPath = FPaths::ConvertRelativePathToFull(FPaths::Combine(
|
||||
PluginRootPath(),
|
||||
TEXT("Resources"),
|
||||
TEXT("CloudFormation")
|
||||
));
|
||||
return CloudFormationRootPath;
|
||||
}
|
||||
|
||||
inline const auto& IntermediateCloudFormationRootPath()
|
||||
{
|
||||
static FString CloudFormationRootPath = FPaths::ConvertRelativePathToFull(FPaths::Combine(
|
||||
PluginRootPath(),
|
||||
TEXT("Intermediate"),
|
||||
TEXT("CloudFormation")
|
||||
));
|
||||
return CloudFormationRootPath;
|
||||
}
|
||||
|
||||
inline const auto& ContainersTemplatePath()
|
||||
{
|
||||
static FString ContainersTemplateRootPath = FPaths::ConvertRelativePathToFull(FPaths::Combine(
|
||||
PluginRootPath(),
|
||||
TEXT("Resources"),
|
||||
TEXT("Containers"),
|
||||
TEXT("SampleDockerfile")
|
||||
));
|
||||
return ContainersTemplateRootPath;
|
||||
}
|
||||
|
||||
inline const auto ScenarioPath(const FString& Scenario)
|
||||
{
|
||||
return FPaths::Combine(CloudFormationRootPath(), Scenario);
|
||||
}
|
||||
|
||||
inline const auto ScenarioInstancePath(const FString& Scenario)
|
||||
{
|
||||
return FPaths::Combine(IntermediateCloudFormationRootPath(), TEXT("instance"), Scenario);
|
||||
}
|
||||
} // namespace Paths
|
||||
@@ -0,0 +1,104 @@
|
||||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Misc/EngineVersion.h"
|
||||
|
||||
namespace UnrealVersion
|
||||
{
|
||||
/**
|
||||
* Represents a semantic version with Major, Minor, and Patch components
|
||||
*/
|
||||
struct Version {
|
||||
int32 Major;
|
||||
int32 Minor;
|
||||
int32 Patch;
|
||||
|
||||
bool IsOlderThan(const Version& Other) const
|
||||
{
|
||||
if (Major != Other.Major) return Major < Other.Major;
|
||||
if (Minor != Other.Minor) return Minor < Other.Minor;
|
||||
return Patch < Other.Patch;
|
||||
}
|
||||
|
||||
bool IsSameAs(const Version& Other) const
|
||||
{
|
||||
return Major == Other.Major &&
|
||||
Minor == Other.Minor &&
|
||||
Patch == Other.Patch;
|
||||
}
|
||||
|
||||
bool IsNewerThan(const Version& Other) const
|
||||
{
|
||||
if (Major != Other.Major) return Major > Other.Major;
|
||||
if (Minor != Other.Minor) return Minor > Other.Minor;
|
||||
return Patch > Other.Patch;
|
||||
}
|
||||
|
||||
// Operator overloads
|
||||
bool operator<(const Version& Other) const { return IsOlderThan(Other); }
|
||||
bool operator>(const Version& Other) const { return IsNewerThan(Other); }
|
||||
bool operator==(const Version& Other) const { return IsSameAs(Other); }
|
||||
bool operator!=(const Version& Other) const { return !IsSameAs(Other); }
|
||||
bool operator<=(const Version& Other) const { return IsOlderThan(Other) || IsSameAs(Other); }
|
||||
bool operator>=(const Version& Other) const { return IsNewerThan(Other) || IsSameAs(Other); }
|
||||
};
|
||||
|
||||
// Predefine Unreal Versions
|
||||
inline const Version INVALID_VERSION{ 0, 0, 0 };
|
||||
inline const Version UE5_6_0{ 5, 6, 0 };
|
||||
|
||||
}; // namespace UnrealVersion
|
||||
|
||||
namespace UnrealVersionUtils
|
||||
{
|
||||
/**
|
||||
* Gets the current Unreal Engine version
|
||||
* @return The current engine version
|
||||
*/
|
||||
inline const FString GetCurrentEngineVersion()
|
||||
{
|
||||
FEngineVersion CurrentVersion = FEngineVersion::Current();
|
||||
FString VersionString = FString::Printf(TEXT("%d.%d.%d"),
|
||||
CurrentVersion.GetMajor(),
|
||||
CurrentVersion.GetMinor(),
|
||||
CurrentVersion.GetPatch());
|
||||
|
||||
return VersionString;
|
||||
}
|
||||
|
||||
inline UnrealVersion::Version ParseVersionString(FString& unrealStr)
|
||||
{
|
||||
TArray<FString> parts;
|
||||
unrealStr.ParseIntoArray(parts, TEXT("."), true);
|
||||
|
||||
if (parts.Num() != 3)
|
||||
{
|
||||
return UnrealVersion::INVALID_VERSION;
|
||||
}
|
||||
|
||||
// Convert strings to integers
|
||||
int32 major = FCString::Atoi(*parts[0]);
|
||||
int32 minor = FCString::Atoi(*parts[1]);
|
||||
int32 patch = FCString::Atoi(*parts[2]);
|
||||
|
||||
return UnrealVersion::Version{ major, minor, patch };
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Version to a string representation
|
||||
* @param Version The version to convert
|
||||
* @return Version as a string in format "Major.Minor.Patch"
|
||||
*/
|
||||
inline FString GetVersionString(UnrealVersion::Version& version) {
|
||||
|
||||
FString VersionString = FString::Printf(TEXT("%d.%d.%d"),
|
||||
version.Major,
|
||||
version.Minor,
|
||||
version.Patch);
|
||||
|
||||
return VersionString;
|
||||
}
|
||||
} // namespace UnrealVersionUtils
|
||||
Reference in New Issue
Block a user