mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Modify discord library to be able to customize request session.
This commit is contained in:
parent
0605e98723
commit
cc6778d245
4
module/Vendor/SleepyDiscord/CMakeLists.txt
vendored
4
module/Vendor/SleepyDiscord/CMakeLists.txt
vendored
@ -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 "")
|
||||
|
@ -367,6 +367,10 @@ namespace SleepyDiscord {
|
||||
void setIntents(IntentsRaw newIntents) { intentsIsSet = true; intents = static_cast<Intent>(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<class Container, typename T = typename Container::value_type>
|
||||
|
@ -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>(a)...); }
|
||||
// End workaround...
|
||||
private:
|
||||
Response perform(RequestMethod method);
|
||||
cpr::Session session;
|
||||
|
@ -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)
|
||||
|
@ -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<HeaderPair> 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
|
||||
|
Loading…
Reference in New Issue
Block a user