aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest
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
parent3b07ecab0467770ceec7b2d27cd66dadf481754c (diff)
downloadNorthstarLauncher-dce1bfc7446ceb2591bee4d4ebdce4a2c5f64bda.tar.gz
NorthstarLauncher-dce1bfc7446ceb2591bee4d4ebdce4a2c5f64bda.zip
fix a typo and move to new ssl
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r--NorthstarDedicatedTest/masterserver.cpp29
-rw-r--r--NorthstarDedicatedTest/masterserver.h12
-rw-r--r--NorthstarDedicatedTest/pch.h2
3 files changed, 18 insertions, 25 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();
diff --git a/NorthstarDedicatedTest/masterserver.h b/NorthstarDedicatedTest/masterserver.h
index 0349a518..9b55adda 100644
--- a/NorthstarDedicatedTest/masterserver.h
+++ b/NorthstarDedicatedTest/masterserver.h
@@ -94,18 +94,6 @@ public:
bool m_bHasMainMenuPromoData = false;
MainMenuPromoData m_MainMenuPromoData;
-private:
- void LazyCreateHttpClient();
- bool RequestServerListThread();
- bool RequestMainMenuPromosThread();
- bool AuthenticateOriginWithMasterServerThread(std::string uidStr, std::string tokenStr);
- bool AuthenticateWithOwnServerThread(char* uid, char* playerToken);
- bool AuthenticateWithServerThread(char* uid, char* playerToken, char* serverId, char* password);
- bool AddSelfToServerListThread(int port, int authPort, char* name, char* description, char* map, char* playlist, int maxPlayers, char* password);
- bool UpdateServerMapAndPlaylistThread(char* map, char* playlist, int playerCount);
- bool WritePlayerPersistentDataThread(std::string playerId, char* pdata, size_t pdataSize);
- bool RemoveSelfFromServerListThread();
-
public:
MasterServerManager();
void ClearServerList();
diff --git a/NorthstarDedicatedTest/pch.h b/NorthstarDedicatedTest/pch.h
index c54fedf8..9ac5b8a9 100644
--- a/NorthstarDedicatedTest/pch.h
+++ b/NorthstarDedicatedTest/pch.h
@@ -9,8 +9,6 @@
#define RAPIDJSON_HAS_STDSTRING 1
// httplib ssl
-#define CPPHTTPLIB_OPENSSL_SUPPORT
-#define OPENSSL_API_COMPAT 0x1010100fL
// add headers that you want to pre-compile here
#include <Windows.h>