// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 /** @file * @brief The C interface for the Authentication library. * * The Authentication library contains one class: GameKitSessionManager * * ## GameKitSessionManager * GameKitSessionManager provides APIs for loading and querying the "awsGameKitClientConfig.yml" file, also known as "the config file". * * The config file is loaded by calling GameKitSessionManagerInstanceCreate(), GameKitSessionManagerReloadConfigFile(), or GameKitSessionManagerReloadConfigContents(). * * The config file contains settings that are needed at runtime in order to call any of the GameKit feature APIs. * The config file's settings are specific to the currently selected environment code (i.e. "dev", "qa", "prd", etc.). * * The config file is automatically created/updated each time a GameKit feature is created or redeployed, or when the environment changes (i.e. "dev", "qa", "prd", etc.). * Each game engine implementation of AWS GameKit is responsible for automating this. * * The config file must be bundled with the compiled/built version of any game that uses AWS GameKit, so that the config file can be loaded at runtime. * Many game engines have a special folder where files can be placed that need to be bundled with the built game. */ #pragma once #include #include #include /** * @brief GameKitSessionManager instance handle created by calling #GameKitSessionManagerInstanceCreate() */ typedef void* GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE; extern "C" { /** * @brief Create a GameKitSessionManager instance, which can be used to access the SessionManager API. * * @details Make sure to call GameKitSessionManagerInstanceRelease() to destroy the returned object when finished with it. * * @param clientConfigFile Relative filepath to the generated file "awsGameKitClientConfig.yml" or an empty string or nullptr. If empty or nullptr, then no settings will be loaded. * The config file is generated by GAMEKIT each time a feature is deployed or re-deployed, and has settings for each GAMEKIT feature you've deployed. * @param logCb Callback function for logging information and errors. * @return Pointer to the new GameKitSessionManager instance. */ GAMEKIT_API GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE GameKitSessionManagerInstanceCreate(const char* clientConfigFile, FuncLogCallback logCb); /** * @brief Check if the settings are loaded for the feature. * * @details These settings are found in file "awsGameKitClientConfig.yml" which is generated by GAMEKIT each time you deploy or re-deploy a feature. * The file is loaded by calling either GameKitSessionManagerInstanceCreate(), GameKitSessionManagerReloadConfigFile(), or GameKitSessionManagerReloadConfigContents(). * * @param sessionManagerInstance Pointer to GameKitSessionManager instance created with GameKitSessionManagerInstanceCreate(). * @param featureType The feature to check. * @return True if the settings for the feature are loaded, false otherwise. */ GAMEKIT_API bool GameKitSessionManagerAreSettingsLoaded(GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, GameKit::FeatureType featureType); /** * @brief Replace any loaded client settings with new settings loaded from the provided file path. * * @param sessionManagerInstance Pointer to GameKitSessionManager instance created with GameKitSessionManagerInstanceCreate(). * @param clientConfigFile Relative filepath to the generated file "awsGameKitClientConfig.yml" or an empty string. If empty, the loaded settings will be cleared. * The config file is generated by GAMEKIT each time a feature is deployed or re-deployed, and has settings for each GAMEKIT feature you've deployed. */ GAMEKIT_API void GameKitSessionManagerReloadConfigFile(GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, const char* clientConfigFile); /** * @brief Replace any loaded client settings with new settings from the provided file contents. * * @param sessionManagerInstance Pointer to GameKitSessionManager instance created with GameKitSessionManagerInstanceCreate(). * @param clientConfigFileContents Contents of "awsGameKitClientConfig.yml" or an empty string. If empty, the loaded settings will be cleared. * The config file is generated by GAMEKIT each time a feature is deployed or re-deployed, and has settings for each GAMEKIT feature you've deployed. */ GAMEKIT_API void GameKitSessionManagerReloadConfigContents(GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, const char* clientConfigFileContents); /** * @brief Sets a token's value. * @param sessionManagerInstance Pointer to GameKitSessionManager instance created with GameKitSessionManagerInstanceCreate(). * @param tokenType The type of token to set. * @param value The value of the token. */ GAMEKIT_API void GameKitSessionManagerSetToken(GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, GameKit::TokenType tokenType, const char* value); /** * @brief Destroy the provided GameKitSessionManager instance. * * @param sessionManagerInstance Pointer to GameKitSessionManager instance created with GameKitSessionManagerInstanceCreate(). */ GAMEKIT_API void GameKitSessionManagerInstanceRelease(GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance); }