From 5f7cf7e9698172ccebf2096bec2d0b461f0d005d Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Thu, 28 Apr 2016 03:28:12 +0000 Subject: [PATCH] this is closer but still not building correctly --- .../application/LoginServer/src/CMakeLists.txt | 4 +++- .../LoginServer/src/shared/ClientConnection.cpp | 2 +- external/3rd/library/webAPI/CMakeLists.txt | 15 +++++++++------ external/3rd/library/webAPI/webAPI.cpp | 10 +++++++--- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/engine/server/application/LoginServer/src/CMakeLists.txt b/engine/server/application/LoginServer/src/CMakeLists.txt index 12cc8c7e..2ca54d51 100644 --- a/engine/server/application/LoginServer/src/CMakeLists.txt +++ b/engine/server/application/LoginServer/src/CMakeLists.txt @@ -118,8 +118,9 @@ add_executable(LoginServer ${PLATFORM_SOURCES} ) +link_directories(${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI) + target_link_libraries(LoginServer - webAPI sharedCommandParser sharedCompression sharedDatabaseInterface @@ -152,5 +153,6 @@ target_link_libraries(LoginServer CommonAPI LoginAPI MonAPI2 + webAPI ${CMAKE_DL_LIBS} ) diff --git a/engine/server/application/LoginServer/src/shared/ClientConnection.cpp b/engine/server/application/LoginServer/src/shared/ClientConnection.cpp index a2daaaad..a6af6997 100755 --- a/engine/server/application/LoginServer/src/shared/ClientConnection.cpp +++ b/engine/server/application/LoginServer/src/shared/ClientConnection.cpp @@ -23,7 +23,7 @@ #include "sharedNetworkMessages/GenericValueTypeMessage.h" #include "sharedNetworkMessages/LoginEnumCluster.h" -#include +#include "webAPI.h" #include //----------------------------------------------------------------------- diff --git a/external/3rd/library/webAPI/CMakeLists.txt b/external/3rd/library/webAPI/CMakeLists.txt index f4f8d562..7eacf57b 100644 --- a/external/3rd/library/webAPI/CMakeLists.txt +++ b/external/3rd/library/webAPI/CMakeLists.txt @@ -1,13 +1,16 @@ -set(SHARED_SOURCES - webAPI.cpp +cmake_minimum_required(VERSION 2.8) + +project(webAPI) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +add_library(webAPI webAPI.h + webAPI.cpp json.hpp + ${CURL_LIBRARIES} ) include_directories( ${CURL_INCLUDE_DIRS} ) - -#target_link_libraries( -# ${CURL_LIBRARIES} -#) diff --git a/external/3rd/library/webAPI/webAPI.cpp b/external/3rd/library/webAPI/webAPI.cpp index 0e6c3c67..de0c4fb7 100644 --- a/external/3rd/library/webAPI/webAPI.cpp +++ b/external/3rd/library/webAPI/webAPI.cpp @@ -1,6 +1,9 @@ #include "webAPI.h" +namespace webAPI +{ + // if status == success, returns "success", or slotName's contents if specified... // otherwise returns the "message" if no success std::string simplePost(std::string endpoint, std::string data, std::string slotName) @@ -21,9 +24,9 @@ std::string simplePost(std::string endpoint, std::string data, std::string slotN } else { - if (j.count("message")) + if (response.count("message")) { - output = j["message"].get(); + output = response["message"].get(); } else { @@ -59,7 +62,7 @@ nlohmann::json request(std::string endpoint, std::string data, int reqType, ...) if (res == CURLE_OK && !(readBuffer.empty())) { - response = json::parse(readBuffer); + response = nlohmann::json::parse(readBuffer); } curl_easy_cleanup(curl); } @@ -84,3 +87,4 @@ size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) ((std::string*)userp)->append((char*)contents, size * nmemb); return size * nmemb; } +};