mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +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 ""
|
TEST_COMMAND ""
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
if(USE_CPR)
|
if(USE_CPR)
|
||||||
#set(cpr_SOURCE_DIR ${PROJECT_SOURCE_DIR}/deps/cpr)
|
#set(cpr_SOURCE_DIR ${PROJECT_SOURCE_DIR}/deps/cpr)
|
||||||
@ -163,7 +164,8 @@ if(USE_CPR)
|
|||||||
#this fixes
|
#this fixes
|
||||||
if(NOT DEFINED CMAKE_USE_OPENSSL)
|
if(NOT DEFINED CMAKE_USE_OPENSSL)
|
||||||
if(WIN32)
|
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 "")
|
set(CMAKE_USE_OPENSSL OFF CACHE BOOL "")
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
set(CMAKE_USE_DARWINSSL ON CACHE BOOL "")
|
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 setIntents(IntentsRaw newIntents) { intentsIsSet = true; intents = static_cast<Intent>(newIntents); }
|
||||||
void quit() { quit(false); } //public function for diconnecting
|
void quit() { quit(false); } //public function for diconnecting
|
||||||
virtual void run();
|
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
|
//array of intents
|
||||||
template<class Container, typename T = typename Container::value_type>
|
template<class Container, typename T = typename Container::value_type>
|
||||||
|
@ -28,6 +28,9 @@ namespace SleepyDiscord {
|
|||||||
responseCallback = callback;
|
responseCallback = callback;
|
||||||
}
|
}
|
||||||
Response request(RequestMethod method);
|
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:
|
private:
|
||||||
Response perform(RequestMethod method);
|
Response perform(RequestMethod method);
|
||||||
cpr::Session session;
|
cpr::Session session;
|
||||||
|
@ -24,6 +24,16 @@ add_library(sleepy-discord
|
|||||||
websocketpp_websocket.cpp
|
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
|
target_include_directories(sleepy-discord
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${PROJECT_SOURCE_DIR}/include
|
${PROJECT_SOURCE_DIR}/include
|
||||||
@ -89,11 +99,12 @@ if (NOT ONLY_SLEEPY_DISCORD)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_UWEBSOCKETS)
|
if(USE_UWEBSOCKETS)
|
||||||
find_library(LIB_UWS uWS
|
#find_library(LIB_UWS uWS
|
||||||
PATHS ${uwebsockets_SOURCE_DIR}/lib
|
# PATHS ${uwebsockets_SOURCE_DIR}/lib
|
||||||
)
|
#)
|
||||||
target_include_directories(sleepy-discord PUBLIC ${uwebsockets_SOURCE_DIR}/include)
|
target_include_directories(sleepy-discord PUBLIC ${uwebsockets_SOURCE_DIR}/src)
|
||||||
list(APPEND LIBRARIES_TO_LINK "${LIB_UWS}")
|
list(APPEND LIBRARIES_TO_LINK "uSockets")
|
||||||
|
list(APPEND LIBRARIES_TO_LINK "uWebSockets")
|
||||||
target_compile_definitions(sleepy-discord PUBLIC EXISTENT_UWEBSOCKETS)
|
target_compile_definitions(sleepy-discord PUBLIC EXISTENT_UWEBSOCKETS)
|
||||||
else()
|
else()
|
||||||
target_compile_definitions(sleepy-discord PUBLIC NONEXISTENT_UWEBSOCKETS)
|
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
|
{ //the { is used so that onResponse is called after session is removed to make debugging performance issues easier
|
||||||
//request starts here
|
//request starts here
|
||||||
Session session;
|
Session session;
|
||||||
|
// Workaround to CURL issues with SSL (see Session::setupCallback)
|
||||||
|
setupGatewaySession(session);
|
||||||
|
// End workaround...
|
||||||
session.setUrl("https://discord.com/api/v6/" + path.url());
|
session.setUrl("https://discord.com/api/v6/" + path.url());
|
||||||
std::vector<HeaderPair> header = {
|
std::vector<HeaderPair> header = {
|
||||||
{ "Authorization", bot ? "Bot " + getToken() : getToken() },
|
{ "Authorization", bot ? "Bot " + getToken() : getToken() },
|
||||||
@ -264,6 +267,9 @@ namespace SleepyDiscord {
|
|||||||
theGateway = SLEEPY_HARD_CODED_GATEWAY; //This is needed for when session is disabled
|
theGateway = SLEEPY_HARD_CODED_GATEWAY; //This is needed for when session is disabled
|
||||||
#else
|
#else
|
||||||
Session session;
|
Session session;
|
||||||
|
// Workaround to CURL issues with SSL (see Session::setupCallback)
|
||||||
|
setupSession(session);
|
||||||
|
// End workaround...
|
||||||
session.setUrl("https://discord.com/api/gateway");
|
session.setUrl("https://discord.com/api/gateway");
|
||||||
Response a = session.request(Get); //todo change this back to a post
|
Response a = session.request(Get); //todo change this back to a post
|
||||||
if (!a.text.length()) { //error check
|
if (!a.text.length()) { //error check
|
||||||
|
Loading…
Reference in New Issue
Block a user