Update things

This commit is contained in:
Xaymar
2026-01-18 12:08:42 +01:00
parent 18709cde46
commit efa94fd1d4
12 changed files with 244 additions and 93 deletions
+15 -88
View File
@@ -15,17 +15,15 @@ cmake_minimum_required(VERSION 4.2.1)
project(archipelago)
cmake_host_system_information(RESULT _JOBS QUERY NUMBER_OF_LOGICAL_CORES)
# ExternalContent, the better FetchContent and ExternalProject. Even beats CPM because it isn't written to be fancy!
include(cmake/externalcontent/ExternalContent.cmake)
# Ensure we include ExternalContent, a much better reimplementation of FetchContent. Doesn't handle collisions though, that's on us.
include("${CMAKE_SOURCE_DIR}/cmake/externalcontent/ExternalContent.cmake")
#--------------------------------------------------------------------------------#
# Options
#--------------------------------------------------------------------------------#
set(CACHE{ENABLE_SSL} TYPE BOOL HELP "Enable SSL support via wolfSSL?" VALUE ON)
set(CACHE{ENABLE_COMPRESSION} TYPE BOOL HELP "Enable support for compression?" VALUE ON)
set(CACHE{${___}ENABLE_SSL} TYPE BOOL HELP "Enable SSL support via wolfSSL?" VALUE ON)
set(CACHE{${___}ENABLE_COMPRESSION} TYPE BOOL HELP "Enable support for compression?" VALUE ON)
#--------------------------------------------------------------------------------#
# Libraries
@@ -45,7 +43,9 @@ if(TRUE) # ASIO (Standalone)
ExternalContent(
NAME "asio"
GIT_URL "https://github.com/xaymar/asio"
GIT_REF "root"
GIT_REF "v1.36.0"
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules
GIT_CHECKOUT_OPTIONS --recurse-submodules
SKIP_BUILD
)
find_package(asio REQUIRED CONFIG
@@ -58,7 +58,7 @@ if(TRUE) # nlohmann's JSON
NAME "nlohmann_json"
GIT_URL "https://github.com/nlohmann/json.git"
GIT_REF "v3.12.0"
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules -j ${_JOBS}
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules
GIT_CHECKOUT_OPTIONS --recurse-submodules
CONFIGURE_OPTIONS -D JSON_BuildTests:BOOL=OFF -D JSON_CI:BOOL=OFF -D JSON_MultipleHeaders:BOOL=OFF
SKIP_BUILD
@@ -73,7 +73,7 @@ if(ENABLE_SSL) # wolfssl
NAME "wolfssl"
GIT_URL "https://github.com/wolfSSL/wolfssl.git"
GIT_REF "v5.8.4-stable"
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules -j ${_JOBS}
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules
GIT_CHECKOUT_OPTIONS --recurse-submodules
CONFIGURE_ARGS -D BUILD_SHARED_LIBS:BOOL=OFF -D CMAKE_BUILD_TYPE:STRING=RelWithDebInfo -D WOLFSSL_CRYPT_TESTS:BOOL=OFF -D WOLFSSL_EXAMPLES:BOOL=OFF
BUILD_ARGS --parallel --config Release --clean-first
@@ -88,14 +88,14 @@ if(TRUE) # WebSocket++
NAME "websocketpp"
GIT_URL "https://github.com/xaymar/websocketpp.git"
GIT_REF "patch-modern-cpp-and-asio"
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules -j ${_JOBS}
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules
GIT_CHECKOUT_OPTIONS --recurse-submodules
CONFIGURE_ARGS -D ENABLE_CPP11:BOOL=ON -D BUILD_EXAMPLES:BOOL=OFF -D BUILD_TESTS:BOOL=OFF -D USE_ASIO_STANDALONE:BOOL=ON
# Try and fix C++11 support.
CONFIGURE_ARGS -D "CMAKE_CPP_COMPILER_FLAGS=-D_WEBSOCKETPP_CPP11_STL_" -D "CMAKE_CPP_COMPILER_FLAGS=-D_WEBSOCKETPP_CPP11_STL_"
# Optional: SSL support.
CONFIGURE_ARGS -D OPENSSL_INCLUDE_DIR:STRING="${wolfssl_INSTALL_PATH}/include" -D OPENSSL_LIBRARIES:STRING="${wolfssl_INSTALL_PATH}/lib/wolfssl.lib" -D OPENSSL_VERSION:STRING="5.8.4" -D OPENSSL_FOUND:BOOL=ON
BUILD_ARGS --parallel --config Release
BUILD_ARGS --parallel --config Release --clean-first
)
find_package("websocketpp" REQUIRED CONFIG
PATHS "${websocketpp_INSTALL_PATH}"
@@ -108,7 +108,7 @@ if(ENABLE_COMPRESSION) # Compression support
NAME "zlib-ng"
GIT_URL "https://github.com/zlib-ng/zlib-ng.git"
GIT_REF "2.3.2"
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules -j ${_JOBS}
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules
GIT_CHECKOUT_OPTIONS --recurse-submodules
CONFIGURE_ARGS -D BUILD_SHARED_LIBS:BOOL=OFF -D CMAKE_C_STANDARD:STRING=17 -D BUILD_TESTING:BOOL=OFF -D WITH_GTEST:BOOL=OFF -D WITH_FUZZERS:BOOL=OFF -D WITH_BENCHMARKS:BOOL=OFF -D WITH_BENCHMARK_APPS:BOOL=OFF -D INSTALL_UTILS:BOOL=OFF
BUILD_ARGS --parallel --config Release --clean-first
@@ -137,7 +137,7 @@ if(TRUE) # badaix's JSONRPC++
NAME "jsonrpcpp"
GIT_URL "https://github.com/badaix/jsonrpcpp.git"
GIT_REF "v1.4.0"
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules -j ${_JOBS}
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules
GIT_CHECKOUT_OPTIONS --recurse-submodules
PATCH_FUNCTION jsonrpcpp_patch
CONFIGURE_ARGS -D BUILD_EXAMPLE:BOOL=OFF -D BUILD_TESTS:BOOL=OFF -D CATCH_INSTALL_DOCS:BOOL=OFF -D CATCH_INSTALL_EXTRAS:BOOL=ON
@@ -161,79 +161,6 @@ if(TRUE) # badaix's JSONRPC++
endif()
#--------------------------------------------------------------------------------#
# Project
# Sub-Projects
#--------------------------------------------------------------------------------#
file(GLOB_RECURSE _INCLUDE FOLLOW_SYMLINKS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/pub/*")
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/pub" PREFIX "Public" FILES ${_INCLUDE})
file(GLOB_RECURSE _SOURCE FOLLOW_SYMLINKS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/priv/*")
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/priv" PREFIX "Private" FILES ${_SOURCE})
add_executable("room-server")
target_sources("room-server"
PRIVATE
${_SOURCE}
PUBLIC
${_INCLUDE}
)
target_include_directories("room-server"
PRIVATE
"priv"
"pub/apsr"
PUBLIC
"pub"
)
target_link_libraries("room-server"
PRIVATE
wolfSSL
# I/O
asio::asio
# Transport
websocketpp::websocketpp
# Compression
zlib-ng::zlib
# Messaging
nlohmann_json::nlohmann_json
badaix::jsonrpcpp
)
set_target_properties("room-server" PROPERTIES
# Always generate position independent code.
POSITION_INDEPENDENT_CODE ON
# Set C++ Standard and Extensions
C_STANDARD 17
C_STANDARD_REQUIRED ON
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
# Remove prefix from generated files.
PREFIX ""
IMPORT_PREFIX ""
# Never treat warnings as errors.
COMPILE_WARNING_AS_ERROR OFF
)
target_compile_definitions("room-server"
PRIVATE
ASIO_STANDALONE
_WEBSOCKETPP_CPP11_STL_
)
if(WIN32)
# Disable/Enable a ton of things.
target_compile_definitions("room-server" PRIVATE
# Microsoft Visual C++
_CRT_SECURE_NO_WARNINGS
_ENABLE_EXTENDED_ALIGNED_STORAGE
# Windows version target
_WIN32_WINNT=0x0A00
)
endif()
add_subdirectory(room)
+97
View File
@@ -0,0 +1,97 @@
# Copyright 2025-2026 Narta Xaymar Dirks <info@xaymar.com>
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Require the latest CMake version.
cmake_minimum_required(VERSION 4.2.1)
project("room")
#--------------------------------------------------------------------------------#
# Project
#--------------------------------------------------------------------------------#
file(GLOB_RECURSE _INCLUDE FOLLOW_SYMLINKS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/pub/*")
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/pub" PREFIX "Public" FILES ${_INCLUDE})
file(GLOB_RECURSE _SOURCE FOLLOW_SYMLINKS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/priv/*")
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/priv" PREFIX "Private" FILES ${_SOURCE})
add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE)
set_target_properties(${PROJECT_NAME} PROPERTIES
# Always generate position independent code.
POSITION_INDEPENDENT_CODE ON
# Set C++ Standard and Extensions
C_STANDARD 17
C_STANDARD_REQUIRED ON
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
# Remove prefix from generated files.
PREFIX ""
IMPORT_PREFIX ""
# Never treat warnings as errors.
COMPILE_WARNING_AS_ERROR OFF
)
target_sources(${PROJECT_NAME}
PRIVATE
${_SOURCE}
PUBLIC
${_INCLUDE}
)
target_include_directories(${PROJECT_NAME}
PRIVATE "priv"
PUBLIC "pub"
)
target_link_libraries(${PROJECT_NAME}
PRIVATE asio::asio
PRIVATE wolfssl::wolfssl
PRIVATE zlib-ng::zlib
PRIVATE websocketpp::websocketpp
PRIVATE nlohmann_json::nlohmann_json
PRIVATE badaix::jsonrpcpp
)
target_compile_definitions(${PROJECT_NAME}
PRIVATE _WEBSOCKETPP_CPP11_STL_
)
if(ENABLE_SSL AND wolfssl_FOUND)
target_compile_definitions(${PROJECT_NAME}
PRIVATE ARCHIPELAGO_ENABLE_SSL
)
endif()
if(ENABLE_COMPRESSION AND zlib-ng_FOUND)
target_compile_definitions(${PROJECT_NAME}
PRIVATE ARCHIPELAGO_ENABLE_COMPRESSION
)
endif()
if(WIN32)
# Disable/Enable a ton of things.
target_compile_definitions(${PROJECT_NAME} PRIVATE
# Microsoft Visual C++:
#- No secure CRT warnings.
PRIVATE _CRT_SECURE_NO_WARNINGS
#- Properly align objects when std::align is used.
PRIVATE _ENABLE_EXTENDED_ALIGNED_STORAGE
# Target Windows 10 (adjust later?).
PRIVATE _WIN32_WINNT=0x0A00
)
endif()
+35
View File
@@ -0,0 +1,35 @@
# Archipelago - Room Server
The room server is meant to handle the direct user workload from Archipelago clients for each room.
## Design
There are some things we need to keep in mind for the server design:
### Performance
The only limiting factor for hosting should be the servers hardware and not our programming or chosen language. Try to minimize overhead as much as possible for every component.
### Scalability
Only run the rooms themselves instead of the whole website, api, management, etc all in one service. This allows using less expensive hardware for the room servers such as virtual servers and similar.
## Protocols
The room server implements the client protocol for the management server and the server protocol for the room server(s).
### Management (Client)
See the `Archipelago - Manager Server` project for the protocol information.
### Room (Server)
At the current time the following protocols are to be supported:
#### Official Protocol
The server currently implements the official protocol ([documented here on the official repository](https://github.com/ArchipelagoMW/Archipelago/blob/main/docs/network%20protocol.md)). This can be implemented in one of two ways:
##### 1. Individual Room Servers
This is the way the official server currently does it: Each room gets its own WebSocket server and the associated overhead. This has some drawbacks:
- The number of rooms is hard limited to 65535 per IPv4 and IPv6 address assigned to the machine.
- Opening many has some not insignificant user-space and kernel-space overhead attached to it.
- Port scanning allows people to see which rooms are running, if any.
For obvious reasons, we do not want to implement this.
##### 2. Single Overall Room Server
We can use the password field to uniquely identify which room a user actually wants to work with. This allows us to remove all the drawbacks in exchange for additional workload required to ensure that we don't stall all rooms.
+13 -4
View File
@@ -12,10 +12,19 @@
**/
#include "manager.hpp"
#include <iostream>
nlohmann::json::object default_config{
};
const std::string_view default_config =
R"({
"client-options": {
/** What should we identify as?
*
* Available variables (via ${}):
* - version: Current version of the server.
*/
"user-agent": "Archipelago Room Server v${version}"
}
})";
apsr::manager::~manager()
{
@@ -31,7 +40,7 @@ int32_t apsr::manager::run(int argc, char** argv)
// Spawn threads to handle all ASIO workload.
//!TODO: Make this a command line or environment option.
std::cout << "Hello World!" << std::endl;
return 0;
}
+14
View File
@@ -0,0 +1,14 @@
/** Copyright 2025-2026 Narta Xaymar Dirks <info@xaymar.com>
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
#include "room.hpp"
+20
View File
@@ -0,0 +1,20 @@
/** Copyright 2025-2026 Narta Xaymar Dirks <info@xaymar.com>
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
namespace archipelago {
/** Room Information
*/
class room {
};
}
+14
View File
@@ -0,0 +1,14 @@
/** Copyright 2025-2026 Narta Xaymar Dirks <info@xaymar.com>
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
#include "server.hpp"
+35
View File
@@ -0,0 +1,35 @@
/** Copyright 2025-2026 Narta Xaymar Dirks <info@xaymar.com>
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
// ASIO
#include <asio/asio.hpp>
// WebSocket Client
#include <websocketpp/config/asio.hpp>
#include <websocketpp/server.hpp>
// JSON and JSON-RPC 2.0
#include <nlohmann/json.hpp>
#include <jsonrpcpp.hpp>
namespace archipelago {
class server {
public:
~server();
server();
};
} // namespace archipelago