| 236 | } |
| 237 | |
| 238 | std::string GSDKInternal::encodeHeartbeatRequest() |
| 239 | { |
| 240 | Json::Value jsonHeartbeatRequest; |
| 241 | |
| 242 | jsonHeartbeatRequest["CurrentGameState"] = GameStateNames[static_cast<int>(m_heartbeatRequest.m_currentGameState)]; |
| 243 | |
| 244 | auto healthCallback = m_healthCallback; |
| 245 | if (healthCallback != nullptr) |
| 246 | { |
| 247 | m_heartbeatRequest.m_isGameHealthy = healthCallback(); |
| 248 | } |
| 249 | jsonHeartbeatRequest["CurrentGameHealth"] = m_heartbeatRequest.m_isGameHealthy ? "Healthy" : "Unhealthy"; |
| 250 | |
| 251 | Json::Value jsonConnectedPlayerInfo; |
| 252 | for (ConnectedPlayer connectedPlayer : m_heartbeatRequest.m_connectedPlayers) |
| 253 | { |
| 254 | Json::Value playerInfo; |
| 255 | playerInfo["PlayerId"] = connectedPlayer.m_playerId; |
| 256 | jsonConnectedPlayerInfo.append(playerInfo); |
| 257 | } |
| 258 | jsonHeartbeatRequest["CurrentPlayers"] = jsonConnectedPlayerInfo; |
| 259 | |
| 260 | return jsonHeartbeatRequest.toStyledString(); |
| 261 | } |
| 262 | |
| 263 | std::tm GSDKInternal::parseDate(const std::string& dateStr) // note: this code only supports ISO 8601 UTC date-times in the format yyyy-mm-ddThh:mm:ssZ |
| 264 | { |