diff --git a/module/Vendor/SleepyDiscord/CMakeLists.txt b/module/Vendor/SleepyDiscord/CMakeLists.txt index 6561a30a..8a9df4f9 100644 --- a/module/Vendor/SleepyDiscord/CMakeLists.txt +++ b/module/Vendor/SleepyDiscord/CMakeLists.txt @@ -127,6 +127,7 @@ if(AUTO_DOWNLOAD_LIBRARY) TEST_COMMAND "" ) endif() + else() if(USE_CPR) #set(cpr_SOURCE_DIR ${PROJECT_SOURCE_DIR}/deps/cpr) @@ -163,7 +164,8 @@ if(USE_CPR) #this fixes if(NOT DEFINED CMAKE_USE_OPENSSL) if(WIN32) - set(CMAKE_USE_WINSSL ON CACHE BOOL "") + #set(CMAKE_USE_WINSSL ON CACHE BOOL "") + set(CMAKE_USE_SCHANNEL ON CACHE BOOL "") set(CMAKE_USE_OPENSSL OFF CACHE BOOL "") elseif(APPLE) set(CMAKE_USE_DARWINSSL ON CACHE BOOL "") diff --git a/module/Vendor/SleepyDiscord/include/sleepy_discord/client.h b/module/Vendor/SleepyDiscord/include/sleepy_discord/client.h index 08e5c2a5..5bfaf891 100644 --- a/module/Vendor/SleepyDiscord/include/sleepy_discord/client.h +++ b/module/Vendor/SleepyDiscord/include/sleepy_discord/client.h @@ -367,6 +367,10 @@ namespace SleepyDiscord { void setIntents(IntentsRaw newIntents) { intentsIsSet = true; intents = static_cast(newIntents); } void quit() { quit(false); } //public function for diconnecting virtual void run(); + // Workaround to CURL issues with SSL (see Session::setupCallback) + virtual void setupSession(Session & session) { /*do nothing by default*/ } + virtual void setupGatewaySession(Session & session) { /*do nothing by default*/ } + // End workaround... //array of intents template diff --git a/module/Vendor/SleepyDiscord/include/sleepy_discord/cpr_session.h b/module/Vendor/SleepyDiscord/include/sleepy_discord/cpr_session.h index 3fb7d9d1..b4980dcc 100644 --- a/module/Vendor/SleepyDiscord/include/sleepy_discord/cpr_session.h +++ b/module/Vendor/SleepyDiscord/include/sleepy_discord/cpr_session.h @@ -28,6 +28,9 @@ namespace SleepyDiscord { responseCallback = callback; } Response request(RequestMethod method); + // Workaround to CURL issues with SSL (I use this to setup my certificates and other information on the internal session) + template < class F, class... A > auto setupCallback(F cb, A &&... a) { return cb(session, std::forward(a)...); } + // End workaround... private: Response perform(RequestMethod method); cpr::Session session; diff --git a/module/Vendor/SleepyDiscord/sleepy_discord/CMakeLists.txt b/module/Vendor/SleepyDiscord/sleepy_discord/CMakeLists.txt index c6afb952..abf5a294 100644 --- a/module/Vendor/SleepyDiscord/sleepy_discord/CMakeLists.txt +++ b/module/Vendor/SleepyDiscord/sleepy_discord/CMakeLists.txt @@ -24,6 +24,16 @@ add_library(sleepy-discord websocketpp_websocket.cpp ) +#target_compile_definitions(sleepy-discord PRIVATE SLEEPY_USE_HARD_CODED_GATEWAY=1) + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + target_compile_options(sleepy-discord PRIVATE "-Wa,-mbig-obj") +endif() + +if(CMAKE_BUILD_TYPE MATCHES Release) + target_compile_options(sleepy-discord PRIVATE "-O3") +endif() + target_include_directories(sleepy-discord PUBLIC ${PROJECT_SOURCE_DIR}/include @@ -89,11 +99,12 @@ if (NOT ONLY_SLEEPY_DISCORD) endif() if(USE_UWEBSOCKETS) - find_library(LIB_UWS uWS - PATHS ${uwebsockets_SOURCE_DIR}/lib - ) - target_include_directories(sleepy-discord PUBLIC ${uwebsockets_SOURCE_DIR}/include) - list(APPEND LIBRARIES_TO_LINK "${LIB_UWS}") + #find_library(LIB_UWS uWS + # PATHS ${uwebsockets_SOURCE_DIR}/lib + #) + target_include_directories(sleepy-discord PUBLIC ${uwebsockets_SOURCE_DIR}/src) + list(APPEND LIBRARIES_TO_LINK "uSockets") + list(APPEND LIBRARIES_TO_LINK "uWebSockets") target_compile_definitions(sleepy-discord PUBLIC EXISTENT_UWEBSOCKETS) else() target_compile_definitions(sleepy-discord PUBLIC NONEXISTENT_UWEBSOCKETS) diff --git a/module/Vendor/SleepyDiscord/sleepy_discord/client.cpp b/module/Vendor/SleepyDiscord/sleepy_discord/client.cpp index eb36f5ed..a1a3e565 100644 --- a/module/Vendor/SleepyDiscord/sleepy_discord/client.cpp +++ b/module/Vendor/SleepyDiscord/sleepy_discord/client.cpp @@ -98,6 +98,9 @@ namespace SleepyDiscord { { //the { is used so that onResponse is called after session is removed to make debugging performance issues easier //request starts here Session session; + // Workaround to CURL issues with SSL (see Session::setupCallback) + setupGatewaySession(session); + // End workaround... session.setUrl("https://discord.com/api/v6/" + path.url()); std::vector header = { { "Authorization", bot ? "Bot " + getToken() : getToken() }, @@ -264,6 +267,9 @@ namespace SleepyDiscord { theGateway = SLEEPY_HARD_CODED_GATEWAY; //This is needed for when session is disabled #else Session session; + // Workaround to CURL issues with SSL (see Session::setupCallback) + setupSession(session); + // End workaround... session.setUrl("https://discord.com/api/gateway"); Response a = session.request(Get); //todo change this back to a post if (!a.text.length()) { //error check