Fixed socket.io TLS

This commit is contained in:
Anonymous275 2021-02-26 15:55:13 +02:00 committed by Anonymous275
parent 6aed93fbf1
commit 7e6d5ce359
4 changed files with 16 additions and 9 deletions

3
.gitignore vendored
View File

@ -474,3 +474,6 @@ cmake-build-release/include/commandline/Makefile
*.internal
*.xml
cmake-build-debug/include/commandline/Makefile
*.manifest
*.rc
*.res

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.10)
project(Server)
set(CMAKE_CXX_STANDARD 17)
@ -43,7 +43,7 @@ add_executable(BeamMP-Server
include/TResourceManager.h src/TResourceManager.cpp
include/THeartbeatThread.h src/THeartbeatThread.cpp
include/Http.h src/Http.cpp
# include/SocketIO.h src/SocketIO.cpp
include/SocketIO.h src/SocketIO.cpp
include/TPPSMonitor.h src/TPPSMonitor.cpp
include/TUDPServer.h src/TUDPServer.cpp
include/TTCPServer.h src/TTCPServer.cpp)
@ -56,11 +56,11 @@ target_include_directories(BeamMP-Server PUBLIC ${Boost_INCLUDE_DIRS} ${LUA_INCL
find_package(OpenSSL REQUIRED)
if (UNIX)
target_link_libraries(BeamMP-Server z pthread stdc++fs ${Boost_LINK_DIRS} ${LUA_LIBRARIES} dl crypto ${OPENSSL_LIBRARIES} ${Boost_LIBRARIES} commandline sioclient)
target_link_libraries(BeamMP-Server z pthread stdc++fs ${Boost_LINK_DIRS} ${LUA_LIBRARIES} dl crypto ${OPENSSL_LIBRARIES} ${Boost_LIBRARIES} commandline sioclient_tls)
elseif (WIN32)
include(FindLua)
find_package(ZLIB REQUIRED)
find_package(RapidJSON CONFIG REQUIRED)
target_include_directories(BeamMP-Server PRIVATE ${RAPIDJSON_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
target_link_libraries(BeamMP-Server PRIVATE ws2_32 ZLIB::ZLIB ${LUA_LIBRARIES} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} commandline sioclient)
target_link_libraries(BeamMP-Server PRIVATE ws2_32 ZLIB::ZLIB ${LUA_LIBRARIES} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} commandline sioclient_tls)
endif ()

View File

@ -1,6 +1,5 @@
#include "SocketIO.h"
#include "Common.h"
#include <iostream>
static std::unique_ptr<SocketIO> SocketIOInstance = std::make_unique<SocketIO>();
@ -11,11 +10,16 @@ SocketIO& SocketIO::Get() {
SocketIO::SocketIO() noexcept
: mThread([this] { ThreadMain(); }) {
mClient.socket("/")->on("Hello", [&](sio::event&) {
mClient.socket("/" + Application::TSettings().Key)->on("Hello", [&](sio::event&) {
info("Got 'Hello' from backend socket-io!");
});
mClient.connect("https://backend.beammp.com");
mClient.set_logs_quiet();
mClient.set_reconnect_delay(10000);
mClient.connect("https://backend.beammp.com");
//mClient.socket()->emit("initConnection", Application::TSettings().Key);
}
SocketIO::~SocketIO() {
@ -95,7 +99,7 @@ void SocketIO::ThreadMain() {
} // end queue lock scope
debug("sending \"" + TheEvent.Name + "\" event");
auto Room = "/" + TheEvent.Room;
mClient.socket("/")->emit(TheEvent.Name, TheEvent.Data);
mClient.socket()->emit(TheEvent.Name, TheEvent.Data);
debug("sent \"" + TheEvent.Name + "\" event");
}
}
@ -104,5 +108,6 @@ void SocketIO::ThreadMain() {
mClient.sync_close();
mClient.clear_con_listeners();
std::cout << "closed" << std::endl;
}

View File

@ -87,7 +87,6 @@ void TLuaEngine::RegisterFiles(const std::string& Path, bool HotSwap) {
auto& Script = *ScriptToInsert;
mLuaFiles.insert(std::move(ScriptToInsert));
Script.Init(Name, FileName, fs::last_write_time(FileName));
//Script.Load();
if (HotSwap)
info(("[HOTSWAP] Added : ") + Script.GetFileName().substr(Script.GetFileName().find('\\')));
}