Remove unused function and restrict access to members

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8118 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 5fa0c1b3a0c31f3ce1effc1914153590eeaf5be6
Former-commit-id: 5275ca45a35ae5f6a36cb5bfb64a58564d4f7d22
This commit is contained in:
beaglejoe 2022-04-25 02:25:39 +00:00
parent 6e93a2deeb
commit a74d4c63aa
2 changed files with 12 additions and 89 deletions

View file

@ -641,85 +641,6 @@ int WebServer::addOrderedAsyncRequest(const std::string &data)
return 0;
}
int WebServer::sendGenericRequest (std::string data, std::string& serverReply)
{
//read the webserver configuration
this->readConfiguration();
CURL *curl;
CURLcode res;
GfLogInfo("WebServer: Performing SYNC request:\n%s\n", data.c_str());
webserverState=WEBSERVER_SENDING;
//insert "data=" before the actual data
data.insert(0,"data=");
const char *postthis=data.c_str();
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl, CURLOPT_URL, this->url);
// send all data to this function
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteStringCallback);
//pass our std::string to the WriteStringCallback functions so it can write into it
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &this->curlServerReply);
// some servers don't like requests that are made without a user-agent
// field, so we provide one
curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis);
// if we don't provide POSTFIELDSIZE, libcurl will strlen() by
// itself
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(postthis));
// Perform the request, res will get the return code
res = curl_easy_perform(curl);
// Check for errors
if(res != CURLE_OK)
{
notifications.msglist.push_back("Failed to connect to the WebServer!");
GfLogInfo("WebServer: Unable to perform SYNC request some error occured: %s\n", data.c_str());
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
}
else
{
//
// Now, our this->curlServerReply
// contains the remote file (aka serverReply).
//
// Do something nice with it!
//
GfLogInfo("WebServer: Receiving data from the WebServer:\n%s\n", this->curlServerReply.c_str());
webserverState=WEBSERVER_RECEIVING;
serverReply = this->curlServerReply;
//empty the string
this->curlServerReply.clear();
}
// always cleanup
curl_easy_cleanup(curl);
// we're done with libcurl, so clean it up
curl_global_cleanup();
}
return 0;
}
void WebServer::readConfiguration ()
{
//read the preferencies file

View file

@ -96,13 +96,20 @@ class TGFCLIENT_API WebServer {
//local data
bool raceEndSent;
int previousLaps;
int raceId;
private:
const char* username;
const char* password;
const char* url;
bool isWebServerEnabled;
//curl
CURLM* multi_handle;
int handle_count;
std::string curlServerReply;
//dynamic data retrieved with some request to the webserver
int raceId;
int userId;
const char* sessionId;
@ -110,16 +117,16 @@ class TGFCLIENT_API WebServer {
void readConfiguration();
int readUserConfig(int userId);
//sync request
int sendGenericRequest (std::string data, std::string& serverReply);
//async requests
int updateAsyncStatus();
int addAsyncRequest(const std::string &data);
int addOrderedAsyncRequest(const std::string &data);
int pendingAsyncRequestId;
std::vector<webRequest_t> orderedAsyncRequestQueque;
public:
int updateAsyncStatus();
//specific requests
int sendLogin (int userId);
int sendLogin (const char* username, const char* password);
@ -127,11 +134,6 @@ class TGFCLIENT_API WebServer {
int sendRaceEnd (int race_id, int endposition);
int sendLap (int race_id, double laptime, double fuel, int position, int wettness);
//curl
CURLM* multi_handle;
int handle_count;
std::string curlServerReply;
//constructor
WebServer();