| 74 | } |
| 75 | |
| 76 | bool registerGame(const std::string& odVersion, const std::string& creator, int32_t port, const std::string& label, const std::string& descr, std::string& uuid) |
| 77 | { |
| 78 | // Before sending the level informations, we format the strings to avoid special meaning chars |
| 79 | // like '\n' or ';' |
| 80 | sf::Http::Request request("/announce.php", sf::Http::Request::Post); |
| 81 | std::string body = "odVersion=" + formatStringForMasterServer(odVersion) |
| 82 | + "&creator=" + formatStringForMasterServer(creator) |
| 83 | + "&port=" + Helper::toString(port) |
| 84 | + "&label=" + formatStringForMasterServer(label) |
| 85 | + "&descr=" + formatStringForMasterServer(descr); |
| 86 | request.setBody(body); |
| 87 | |
| 88 | sf::Http http(ConfigManager::getSingleton().getMasterServerUrl()); |
| 89 | sf::Http::Response response = http.sendRequest(request); |
| 90 | if (response.getStatus() != sf::Http::Response::Ok) |
| 91 | return false; |
| 92 | |
| 93 | std::string line = response.getBody(); |
| 94 | Helper::trim(line); |
| 95 | static const std::string prefix = "uuid="; |
| 96 | if(prefix.size() >= line.size()) |
| 97 | return false; |
| 98 | if(!std::equal(prefix.begin(), prefix.end(), line.begin())) |
| 99 | return false; |
| 100 | |
| 101 | uuid = line.substr(prefix.size()); |
| 102 | return true; |
| 103 | } |
| 104 | |
| 105 | bool updateGame(const std::string& uuid, int32_t status) |
| 106 | { |
no test coverage detected