MCPcopy Create free account
hub / github.com/PlayFab/gsdk / GSDKInternal

Method GSDKInternal

cpp/cppsdk/gsdk.cpp:24–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 std::unique_ptr<Configuration> GSDKInternal::testConfiguration = nullptr;
23
24 GSDKInternal::GSDKInternal() : m_transitionToActiveEvent(), m_signalHeartbeatEvent(), m_initialPlayers()
25 {
26 // Need to setup the config first, as that tells us where to log
27 Configuration* config = nullptr;
28
29 // Creating the smart ptr outside the if/else so the object is still alive when we access it below
30 std::unique_ptr<Configuration> configSmrtPtr = nullptr;
31
32 // If they specified a particular config, use that, otherwise create our default
33 if (testConfiguration != nullptr)
34 {
35 // Using .get() instead of std::move so that the object doesn't get destroyed after this constructor
36 config = testConfiguration.get();
37 }
38 else
39 {
40 std::string file_name = cGSDKUtils::getEnvironmentVariable("GSDK_CONFIG_FILE");
41 std::ifstream is(file_name, std::ifstream::in);
42
43 // If the configuration file is not there, we'll get our config from environment variables
44 if (is.fail())
45 {
46 configSmrtPtr = std::make_unique<EnvironmentVariableConfiguration>();
47 }
48 else
49 {
50 configSmrtPtr = std::make_unique<JsonFileConfiguration>(file_name);
51 }
52 config = configSmrtPtr.get();
53 }
54
55 std::unordered_map<std::string, std::string> gameCerts = config->getGameCertificates();
56 for (auto it = gameCerts.begin(); it != gameCerts.end(); ++it)
57 {
58 m_configSettings[it->first] = it->second;
59 }
60
61 std::unordered_map<std::string, std::string> metadata = config->getBuildMetadata();
62 for (auto it = metadata.begin(); it != metadata.end(); ++it)
63 {
64 m_configSettings[it->first] = it->second;
65 }
66
67 std::unordered_map<std::string, std::string> ports = config->getGamePorts();
68 for (auto it = ports.begin(); it != ports.end(); ++it)
69 {
70 m_configSettings[it->first] = it->second;
71 }
72
73 m_configSettings[GSDK::HEARTBEAT_ENDPOINT_KEY] = config->getHeartbeatEndpoint();
74 m_configSettings[GSDK::SERVER_ID_KEY] = config->getServerId();
75 m_configSettings[GSDK::LOG_FOLDER_KEY] = config->getLogFolder();
76 m_configSettings[GSDK::SHARED_CONTENT_FOLDER_KEY] = config->getSharedContentFolder();
77 m_configSettings[GSDK::CERTIFICATE_FOLDER_KEY] = config->getCertificateFolder();
78 m_configSettings[GSDK::TITLE_ID_KEY] = config->getTitleId();
79 m_configSettings[GSDK::BUILD_ID_KEY] = config->getBuildId();
80 m_configSettings[GSDK::REGION_KEY] = config->getRegion();
81 m_configSettings[GSDK::VM_ID_KEY] = config->getVmId();

Callers

nothing calls this directly

Calls 15

getMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
emptyMethod · 0.80
ResetMethod · 0.80
whatMethod · 0.80
getBuildMetadataMethod · 0.65
getGamePortsMethod · 0.65
getHeartbeatEndpointMethod · 0.65
getServerIdMethod · 0.65
getLogFolderMethod · 0.65

Tested by

no test coverage detected