| 110 | } |
| 111 | |
| 112 | Microsoft::Azure::Gaming::JsonFileConfiguration::JsonFileConfiguration(const std::string &file_name) : Microsoft::Azure::Gaming::ConfigurationBase::ConfigurationBase() |
| 113 | { |
| 114 | std::ifstream is(file_name, std::ifstream::in); |
| 115 | |
| 116 | if (!is.fail()) |
| 117 | { |
| 118 | Json::CharReaderBuilder jsonReaderFactory; |
| 119 | Json::Value configFile; |
| 120 | |
| 121 | JSONCPP_STRING jsonParseErrors; |
| 122 | bool parsedSuccessfully = Json::parseFromStream(jsonReaderFactory, is, &configFile, &jsonParseErrors); |
| 123 | |
| 124 | if (parsedSuccessfully) |
| 125 | { |
| 126 | m_heartbeatEndpoint = configFile["heartbeatEndpoint"].asString(); |
| 127 | m_serverId = configFile["sessionHostId"].asString(); |
| 128 | m_logFolder = configFile["logFolder"].asString(); |
| 129 | m_sharedContentFolder = configFile["sharedContentFolder"].asString(); |
| 130 | |
| 131 | if (configFile.isMember("certificateFolder")) |
| 132 | { |
| 133 | m_certFolder = configFile["certificateFolder"].asString(); |
| 134 | } |
| 135 | else |
| 136 | { |
| 137 | m_certFolder = std::string(); |
| 138 | } |
| 139 | |
| 140 | if (configFile.isMember("gameCertificates")) |
| 141 | { |
| 142 | Json::Value gameCerts = configFile["gameCertificates"]; |
| 143 | for (Json::ValueIterator i = gameCerts.begin(); i != gameCerts.end(); ++i) |
| 144 | { |
| 145 | m_gameCerts[i.key().asCString()] = (*i).asCString(); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | if (configFile.isMember("buildMetadata")) |
| 150 | { |
| 151 | Json::Value metadata = configFile["buildMetadata"]; |
| 152 | for (Json::ValueIterator i = metadata.begin(); i != metadata.end(); ++i) |
| 153 | { |
| 154 | m_metadata[i.key().asCString()] = (*i).asCString(); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | if (configFile.isMember("gamePorts")) |
| 159 | { |
| 160 | Json::Value ports = configFile["gamePorts"]; |
| 161 | for (Json::ValueIterator i = ports.begin(); i != ports.end(); ++i) |
| 162 | { |
| 163 | m_ports[i.key().asCString()] = (*i).asCString(); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | if (configFile.isMember("publicIpV4Address")) |
| 168 | { |
| 169 | m_ipv4Address = configFile["publicIpV4Address"].asString(); |
nothing calls this directly
no test coverage detected