aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/masterserver.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-12-29 05:11:59 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-12-29 05:11:59 +0000
commitdce1bfc7446ceb2591bee4d4ebdce4a2c5f64bda (patch)
treeea7cc03cd904073b75603de1bfb9edc3c8dc3114 /NorthstarDedicatedTest/masterserver.cpp
parent3b07ecab0467770ceec7b2d27cd66dadf481754c (diff)
downloadNorthstarLauncher-dce1bfc7446ceb2591bee4d4ebdce4a2c5f64bda.tar.gz
NorthstarLauncher-dce1bfc7446ceb2591bee4d4ebdce4a2c5f64bda.zip
fix a typo and move to new ssl
Diffstat (limited to 'NorthstarDedicatedTest/masterserver.cpp')
-rw-r--r--NorthstarDedicatedTest/masterserver.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp
index 07428274..caa2877b 100644
--- a/NorthstarDedicatedTest/masterserver.cpp
+++ b/NorthstarDedicatedTest/masterserver.cpp
@@ -624,7 +624,7 @@ void MasterServerManager::AddSelfToServerList(int port, int authPort, char* name
std::string strName(name);
std::string strDescription(description);
std::string strMap(map);
- std::string strPlaylist(map);
+ std::string strPlaylist(playlist);
std::string strPassword(password);
std::thread requestThread([this, port, authPort, strName, strDescription, strMap, strPlaylist, maxPlayers, strPassword]
@@ -739,18 +739,25 @@ void MasterServerManager::AddSelfToServerList(int port, int authPort, char* name
// heartbeat thread
// ideally this should actually be done in main thread, rather than on it's own thread, so it'd stop if server freezes
std::thread heartbeatThread([this] {
- CURL* curl = curl_easy_init();
-
- while (*m_ownServerId)
- {
- Sleep(10000);
- curl_easy_setopt(curl, CURLOPT_URL, fmt::format("{}/server/heartbeat?id={}&playerCount={}", Cvar_ns_masterserver_hostname->m_pszString, m_ownServerId, g_ServerAuthenticationManager->m_additionalPlayerData.size()).c_str());
- curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
+ Sleep(5000);
- curl_easy_perform(curl);
- }
+ do
+ {
+ CURL* curl = curl_easy_init();
- curl_easy_cleanup(curl);
+ std::string readBuffer;
+ curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
+ curl_easy_setopt(curl, CURLOPT_URL, fmt::format("{}/server/heartbeat?id={}&playerCount={}", Cvar_ns_masterserver_hostname->m_pszString, m_ownServerId, g_ServerAuthenticationManager->m_additionalPlayerData.size()).c_str());
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteToStringBufferCallback);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
+
+ CURLcode result = curl_easy_perform(curl);
+ if (result != CURLcode::CURLE_OK)
+ spdlog::warn("Heartbeat failed with error {}", curl_easy_strerror(result));
+
+ curl_easy_cleanup(curl);
+ Sleep(10000);
+ } while (*m_ownServerId);
});
heartbeatThread.detach();