fix master server communication

This commit is contained in:
IntelOrca committed 2015-11-08 04:02:23 +00:00
1 parent 0b9882b96f
commit d2aa736492
3 files changed
+23 -13

No files matched your search

+3 -4
View File
@@ -615,7 +615,7 @@ void Network::UpdateServer()
switch (advertise_status) {
case ADVERTISE_STATUS_UNREGISTERED:
if (SDL_TICKS_PASSED(SDL_GetTicks(), last_advertise_time + MASTER_SERVER_REGISTER_TIME)) {
if (last_advertise_time == 0 || SDL_TICKS_PASSED(SDL_GetTicks(), last_advertise_time + MASTER_SERVER_REGISTER_TIME)) {
AdvertiseRegister();
}
break;
@@ -856,7 +856,7 @@ void Network::AdvertiseRegister()
// Send the registration request
std::string url = GetMasterServerUrl()
+ std::string("?command=register&port=") + std::to_string(listening_port)
+ std::string("key=") + advertise_key;
+ std::string("&key=") + advertise_key;
http_request_json_async(url.c_str(), [](http_json_response *response) -> void {
if (response == NULL) {
log_warning("Unable to connect to master server");
@@ -892,8 +892,7 @@ void Network::AdvertiseHeartbeat()
// Send the heartbeat request
std::string url = GetMasterServerUrl()
+ std::string("?command=heartbeat&token=") + advertise_token
+ std::string("key=") + advertise_key
+ std::string("players=") + std::to_string(network_get_num_players());
+ std::string("&players=") + std::to_string(network_get_num_players());
// TODO send status data (e.g. players) via JSON body