mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-17 05:39:53 +00:00
update dlhttp, make / work
This commit is contained in:
@@ -9,16 +9,20 @@ project(BeamMP-Server
|
|||||||
HOMEPAGE_URL https://beammp.com
|
HOMEPAGE_URL https://beammp.com
|
||||||
LANGUAGES CXX C)
|
LANGUAGES CXX C)
|
||||||
|
|
||||||
find_package(Git REQUIRED)
|
option(BEAMMP_RUN_GIT "Run git to make sure submodules are updated (leave this on unless you know what you're doing)" ON)
|
||||||
# Update submodules as needed
|
|
||||||
option(GIT_SUBMODULE "Check submodules during build" ON)
|
if (BEAMMP_RUN_GIT)
|
||||||
if(GIT_SUBMODULE)
|
find_package(Git REQUIRED)
|
||||||
message(STATUS "Submodule update")
|
# Update submodules as needed
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
|
option(GIT_SUBMODULE "Check submodules during build" ON)
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
if(GIT_SUBMODULE)
|
||||||
RESULT_VARIABLE GIT_SUBMOD_RESULT)
|
message(STATUS "Submodule update")
|
||||||
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
|
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
|
||||||
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
RESULT_VARIABLE GIT_SUBMOD_RESULT)
|
||||||
|
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
|
||||||
|
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -145,6 +149,7 @@ set(BeamMP_Libraries
|
|||||||
${LUA_LIBRARIES}
|
${LUA_LIBRARIES}
|
||||||
commandline
|
commandline
|
||||||
sentry
|
sentry
|
||||||
|
dlhttp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
|||||||
2
deps/dlhttp
vendored
2
deps/dlhttp
vendored
Submodule deps/dlhttp updated: 6368e3e236...5229149298
@@ -6,6 +6,7 @@
|
|||||||
#include <Http.h>
|
#include <Http.h>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <dlhttp/dlhttp.h>
|
||||||
|
|
||||||
TNetwork::TNetwork(TServer& Server, TPPSMonitor& PPSMonitor, TResourceManager& ResourceManager)
|
TNetwork::TNetwork(TServer& Server, TPPSMonitor& PPSMonitor, TResourceManager& ResourceManager)
|
||||||
: mServer(Server)
|
: mServer(Server)
|
||||||
@@ -148,6 +149,11 @@ void TNetwork::TCPServerMain() {
|
|||||||
}
|
}
|
||||||
Application::SetSubsystemStatus("TCPNetwork", Application::Status::Good);
|
Application::SetSubsystemStatus("TCPNetwork", Application::Status::Good);
|
||||||
beammp_info("Vehicle event network online");
|
beammp_info("Vehicle event network online");
|
||||||
|
dlhttp::AsyncContext Ctx(4);
|
||||||
|
dlhttp::EndpointHandlerMap Map {
|
||||||
|
{ "/", []() -> dlhttp::Response { return { 200, "Hello! :)" }; } },
|
||||||
|
{ "/fuck", []() -> dlhttp::Response { return { 200, "fuck lol" }; } },
|
||||||
|
};
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
if (Application::IsShuttingDown()) {
|
if (Application::IsShuttingDown()) {
|
||||||
@@ -173,6 +179,15 @@ void TNetwork::TCPServerMain() {
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
throw std::runtime_error("setsockopt recv timeout: " + GetPlatformAgnosticErrorString());
|
throw std::runtime_error("setsockopt recv timeout: " + GetPlatformAgnosticErrorString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for http
|
||||||
|
if (dlhttp::is_http(client.Socket)) {
|
||||||
|
beammp_info("IS HTTP!");
|
||||||
|
dlhttp::handle_http(client.Socket, Ctx, Map);
|
||||||
|
} else {
|
||||||
|
beammp_info("IS NOT HTTP!");
|
||||||
|
}
|
||||||
|
|
||||||
std::thread ID(&TNetwork::Identify, this, client);
|
std::thread ID(&TNetwork::Identify, this, client);
|
||||||
ID.detach(); // TODO: Add to a queue and attempt to join periodically
|
ID.detach(); // TODO: Add to a queue and attempt to join periodically
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user