ws и основные объекты

This commit is contained in:
rassomakhin 2025-10-08 08:52:27 +04:00
parent 170c59caae
commit d370752c40
28 changed files with 1224 additions and 186 deletions

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -22,3 +22,5 @@ postgresql
sudo apt-get install postgresql-all
ixwebsocket
curl

View File

@ -19,14 +19,28 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_executable(SoftController main.cpp
wsHandler/wsSessionHandler.cpp
wsHandler/wsSessionHandler.h)
messaging/messageHandler/messageHandler.cpp
messaging/messageHandler/messageHandler.h
nodes/ormConfigurator/ormConfigurator.h
nodes/ormConfigurator/ormConfigurator.cpp
nodes/reConfigurator/reConfigurator.h
nodes/reConfigurator/reConfigurator.cpp
messaging/messageCounter/messageCounter.cpp
messaging/messageCounter/messageCounter.h
messaging/messageWriter/messageWriter.cpp
messaging/messageWriter/messageWriter.h
nodes/reConfigurator/reHttpPoller/reHttpPoller.h
nodes/reConfigurator/reHttpPoller/reHttpPoller.cpp)
#======================= Либы =======================
find_package(Drogon CONFIG REQUIRED)
target_link_libraries(SoftController PRIVATE Drogon::Drogon)
find_package(ixwebsocket CONFIG REQUIRED)
target_link_libraries(SoftController PRIVATE ixwebsocket::ixwebsocket)
find_package(CURL REQUIRED)
target_link_libraries(SoftController PRIVATE CURL::libcurl)
# ##############################################################################
if (CMAKE_CXX_STANDARD LESS 17)

View File

@ -1089,6 +1089,70 @@
"type" : "BOOL",
"value" : "FALSE"
},
{
"name" : "CURL_DIR",
"properties" :
[
{
"name" : "ADVANCED",
"value" : "1"
},
{
"name" : "HELPSTRING",
"value" : "The directory containing a CMake configuration file for CURL."
}
],
"type" : "PATH",
"value" : "CURL_DIR-NOTFOUND"
},
{
"name" : "CURL_INCLUDE_DIR",
"properties" :
[
{
"name" : "ADVANCED",
"value" : "1"
},
{
"name" : "HELPSTRING",
"value" : "Path to a file."
}
],
"type" : "PATH",
"value" : "/usr/include/x86_64-linux-gnu"
},
{
"name" : "CURL_LIBRARY_DEBUG",
"properties" :
[
{
"name" : "ADVANCED",
"value" : "1"
},
{
"name" : "HELPSTRING",
"value" : "Path to a library."
}
],
"type" : "FILEPATH",
"value" : "CURL_LIBRARY_DEBUG-NOTFOUND"
},
{
"name" : "CURL_LIBRARY_RELEASE",
"properties" :
[
{
"name" : "ADVANCED",
"value" : "1"
},
{
"name" : "HELPSTRING",
"value" : "Path to a library."
}
],
"type" : "FILEPATH",
"value" : "/usr/lib/x86_64-linux-gnu/libcurl.so"
},
{
"name" : "CXX_FILESYSTEM_HAVE_FS",
"properties" :
@ -1197,6 +1261,18 @@
"type" : "INTERNAL",
"value" : "[/usr/lib/x86_64-linux-gnu/libbrotlidec.so][/usr/lib/x86_64-linux-gnu/libbrotlienc.so][/usr/lib/x86_64-linux-gnu/libbrotlicommon.so][/usr/include][v()]"
},
{
"name" : "FIND_PACKAGE_MESSAGE_DETAILS_CURL",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : "Details about finding CURL"
}
],
"type" : "INTERNAL",
"value" : "[/usr/lib/x86_64-linux-gnu/libcurl.so][/usr/include/x86_64-linux-gnu][c ][v8.5.0()]"
},
{
"name" : "FIND_PACKAGE_MESSAGE_DETAILS_Hiredis",
"properties" :
@ -1453,6 +1529,426 @@
"type" : "FILEPATH",
"value" : "/usr/lib/x86_64-linux-gnu/libssl.so"
},
{
"name" : "PC_CURL_CFLAGS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "-I/usr/include/x86_64-linux-gnu"
},
{
"name" : "PC_CURL_CFLAGS_I",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_CFLAGS_OTHER",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_FOUND",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "1"
},
{
"name" : "PC_CURL_INCLUDEDIR",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "/usr/include/x86_64-linux-gnu"
},
{
"name" : "PC_CURL_INCLUDE_DIRS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "/usr/include/x86_64-linux-gnu"
},
{
"name" : "PC_CURL_LDFLAGS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "-L/usr/lib/x86_64-linux-gnu;-lcurl"
},
{
"name" : "PC_CURL_LDFLAGS_OTHER",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_LIBDIR",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "/usr/lib/x86_64-linux-gnu"
},
{
"name" : "PC_CURL_LIBRARIES",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "curl"
},
{
"name" : "PC_CURL_LIBRARY_DIRS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "/usr/lib/x86_64-linux-gnu"
},
{
"name" : "PC_CURL_LIBS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_LIBS_L",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_LIBS_OTHER",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_LIBS_PATHS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_MODULE_NAME",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "libcurl"
},
{
"name" : "PC_CURL_PREFIX",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "/usr"
},
{
"name" : "PC_CURL_STATIC_CFLAGS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "-I/usr/include/x86_64-linux-gnu"
},
{
"name" : "PC_CURL_STATIC_CFLAGS_I",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_STATIC_CFLAGS_OTHER",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_STATIC_INCLUDE_DIRS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "/usr/include/x86_64-linux-gnu"
},
{
"name" : "PC_CURL_STATIC_LDFLAGS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "-L/usr/lib/x86_64-linux-gnu;-lcurl;-lnghttp2;-lidn2;-lrtmp;-lssh;-lssh;-lpsl;-lssl;-lcrypto;-lssl;-lcrypto;-lgssapi_krb5;-llber;-lldap;-llber;-lzstd;-lbrotlidec;-lz"
},
{
"name" : "PC_CURL_STATIC_LDFLAGS_OTHER",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_STATIC_LIBDIR",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_STATIC_LIBRARIES",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "curl;nghttp2;idn2;rtmp;ssh;ssh;psl;ssl;crypto;ssl;crypto;gssapi_krb5;lber;ldap;lber;zstd;brotlidec;z"
},
{
"name" : "PC_CURL_STATIC_LIBRARY_DIRS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "/usr/lib/x86_64-linux-gnu"
},
{
"name" : "PC_CURL_STATIC_LIBS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_STATIC_LIBS_L",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_STATIC_LIBS_OTHER",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_STATIC_LIBS_PATHS",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_VERSION",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "8.5.0"
},
{
"name" : "PC_CURL_libcurl_INCLUDEDIR",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_libcurl_LIBDIR",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_libcurl_PREFIX",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PC_CURL_libcurl_VERSION",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "PG_INCLUDE_DIRS",
"properties" :
@ -2273,6 +2769,18 @@
"type" : "INTERNAL",
"value" : ""
},
{
"name" : "__pkg_config_arguments_PC_CURL",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "QUIET;libcurl"
},
{
"name" : "__pkg_config_arguments__OPENSSL",
"properties" :
@ -2285,6 +2793,18 @@
"type" : "INTERNAL",
"value" : "QUIET;openssl"
},
{
"name" : "__pkg_config_checked_PC_CURL",
"properties" :
[
{
"name" : "HELPSTRING",
"value" : ""
}
],
"type" : "INTERNAL",
"value" : "1"
},
{
"name" : "__pkg_config_checked__OPENSSL",
"properties" :
@ -2309,6 +2829,22 @@
"type" : "PATH",
"value" : "/usr/local/lib/cmake/ixwebsocket"
},
{
"name" : "pkgcfg_lib_PC_CURL_curl",
"properties" :
[
{
"name" : "ADVANCED",
"value" : "1"
},
{
"name" : "HELPSTRING",
"value" : "Path to a library."
}
],
"type" : "FILEPATH",
"value" : "/usr/lib/x86_64-linux-gnu/libcurl.so"
},
{
"name" : "pkgcfg_lib__OPENSSL_crypto",
"properties" :
@ -2351,7 +2887,7 @@
}
],
"type" : "INTERNAL",
"value" : "/usr/lib/x86_64-linux-gnu"
"value" : "AsynchDNS;GSS-API;HSTS;HTTP2;HTTPS-proxy;IDN;IPv6;Kerberos;Largefile;NTLM;PSL;SPNEGO;SSL;TLS-SRP;UnixSockets;alt-svc;brotli;libz;threadsafe;zstd"
},
{
"name" : "yaml-cpp_DIR",

View File

@ -432,6 +432,41 @@
"isExternal" : true,
"path" : "/usr/local/lib/cmake/ixwebsocket/ixwebsocket-targets-noconfig.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/user/\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b/Utils/clion-2025.1.4/bin/cmake/linux/x64/share/cmake-3.31/Modules/FindCURL.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/user/\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b/Utils/clion-2025.1.4/bin/cmake/linux/x64/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/user/\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b/Utils/clion-2025.1.4/bin/cmake/linux/x64/share/cmake-3.31/Modules/FindPackageMessage.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/user/\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b/Utils/clion-2025.1.4/bin/cmake/linux/x64/share/cmake-3.31/Modules/FindPkgConfig.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/user/\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b/Utils/clion-2025.1.4/bin/cmake/linux/x64/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/user/\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b/Utils/clion-2025.1.4/bin/cmake/linux/x64/share/cmake-3.31/Modules/FindPackageMessage.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/home/user/\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b/Utils/clion-2025.1.4/bin/cmake/linux/x64/share/cmake-3.31/Modules/SelectLibraryConfigurations.cmake"
},
{
"path" : "test/CMakeLists.txt"
}

View File

@ -74,14 +74,14 @@
{
"directoryIndex" : 0,
"id" : "SoftController::@6890427a1f51a3e7e1df",
"jsonFile" : "target-SoftController-Debug-c93ed6fd48ac61a06cf3.json",
"jsonFile" : "target-SoftController-Debug-ccacc1369e18ebff1ed0.json",
"name" : "SoftController",
"projectIndex" : 0
},
{
"directoryIndex" : 1,
"id" : "SoftController_test::@36f028580bb02cc8272a",
"jsonFile" : "target-SoftController_test-Debug-c13917e8267ae522df69.json",
"jsonFile" : "target-SoftController_test-Debug-2998bf60419a4a577a31.json",
"name" : "SoftController_test",
"projectIndex" : 1
}

View File

@ -26,7 +26,7 @@
"objects" :
[
{
"jsonFile" : "codemodel-v2-1210f20026b3713e2321.json",
"jsonFile" : "codemodel-v2-1d93002835d84ae78cc7.json",
"kind" : "codemodel",
"version" :
{
@ -35,7 +35,7 @@
}
},
{
"jsonFile" : "cache-v2-3ddaebc9e370345634d3.json",
"jsonFile" : "cache-v2-35649771a3a3bffac09f.json",
"kind" : "cache",
"version" :
{
@ -44,7 +44,7 @@
}
},
{
"jsonFile" : "cmakeFiles-v1-adb70d0cbbec256052fa.json",
"jsonFile" : "cmakeFiles-v1-37617ff7e31aba615d16.json",
"kind" : "cmakeFiles",
"version" :
{
@ -66,7 +66,7 @@
{
"cache-v2" :
{
"jsonFile" : "cache-v2-3ddaebc9e370345634d3.json",
"jsonFile" : "cache-v2-35649771a3a3bffac09f.json",
"kind" : "cache",
"version" :
{
@ -76,7 +76,7 @@
},
"cmakeFiles-v1" :
{
"jsonFile" : "cmakeFiles-v1-adb70d0cbbec256052fa.json",
"jsonFile" : "cmakeFiles-v1-37617ff7e31aba615d16.json",
"kind" : "cmakeFiles",
"version" :
{
@ -86,7 +86,7 @@
},
"codemodel-v2" :
{
"jsonFile" : "codemodel-v2-1210f20026b3713e2321.json",
"jsonFile" : "codemodel-v2-1d93002835d84ae78cc7.json",
"kind" : "codemodel",
"version" :
{

View File

@ -49,235 +49,241 @@
{
"command" : 1,
"file" : 0,
"line" : 26,
"line" : 37,
"parent" : 0
},
{
"command" : 1,
"file" : 0,
"line" : 29,
"line" : 40,
"parent" : 0
},
{
"command" : 1,
"file" : 0,
"line" : 43,
"parent" : 0
},
{
"command" : 4,
"file" : 0,
"line" : 25,
"line" : 36,
"parent" : 0
},
{
"file" : 2,
"parent" : 4
"parent" : 5
},
{
"command" : 3,
"file" : 2,
"line" : 79,
"parent" : 5
"parent" : 6
},
{
"file" : 1,
"parent" : 6
"parent" : 7
},
{
"command" : 2,
"file" : 1,
"line" : 61,
"parent" : 7
"parent" : 8
},
{
"command" : 5,
"file" : 2,
"line" : 40,
"parent" : 5
"parent" : 6
},
{
"command" : 4,
"file" : 5,
"line" : 76,
"parent" : 9
"parent" : 10
},
{
"file" : 4,
"parent" : 10
"parent" : 11
},
{
"command" : 3,
"file" : 4,
"line" : 57,
"parent" : 11
"parent" : 12
},
{
"file" : 3,
"parent" : 12
"parent" : 13
},
{
"command" : 2,
"file" : 3,
"line" : 61,
"parent" : 13
"parent" : 14
},
{
"command" : 5,
"file" : 2,
"line" : 39,
"parent" : 5
"parent" : 6
},
{
"command" : 4,
"file" : 5,
"line" : 76,
"parent" : 15
"parent" : 16
},
{
"file" : 6,
"parent" : 16
"parent" : 17
},
{
"command" : 2,
"file" : 6,
"line" : 67,
"parent" : 17
"parent" : 18
},
{
"command" : 5,
"file" : 2,
"line" : 42,
"parent" : 5
"parent" : 6
},
{
"command" : 4,
"file" : 5,
"line" : 76,
"parent" : 19
"parent" : 20
},
{
"file" : 7,
"parent" : 20
"parent" : 21
},
{
"command" : 2,
"file" : 7,
"line" : 110,
"parent" : 21
"parent" : 22
},
{
"command" : 5,
"file" : 2,
"line" : 55,
"parent" : 5
"parent" : 6
},
{
"command" : 4,
"file" : 5,
"line" : 76,
"parent" : 23
"parent" : 24
},
{
"file" : 8,
"parent" : 24
"parent" : 25
},
{
"command" : 2,
"file" : 8,
"line" : 45,
"parent" : 25
"parent" : 26
},
{
"command" : 5,
"file" : 2,
"line" : 46,
"parent" : 5
"parent" : 6
},
{
"command" : 4,
"file" : 5,
"line" : 76,
"parent" : 27
"parent" : 28
},
{
"file" : 9,
"parent" : 28
"parent" : 29
},
{
"command" : 2,
"file" : 9,
"line" : 16,
"parent" : 29
"parent" : 30
},
{
"command" : 5,
"file" : 2,
"line" : 49,
"parent" : 5
"parent" : 6
},
{
"command" : 4,
"file" : 5,
"line" : 76,
"parent" : 31
"parent" : 32
},
{
"file" : 10,
"parent" : 32
"parent" : 33
},
{
"command" : 2,
"file" : 10,
"line" : 33,
"parent" : 33
"parent" : 34
},
{
"command" : 5,
"file" : 2,
"line" : 61,
"parent" : 5
"parent" : 6
},
{
"command" : 4,
"file" : 5,
"line" : 76,
"parent" : 35
"parent" : 36
},
{
"file" : 11,
"parent" : 36
"parent" : 37
},
{
"command" : 2,
"file" : 11,
"line" : 36,
"parent" : 37
"parent" : 38
},
{
"command" : 4,
"file" : 0,
"line" : 28,
"line" : 39,
"parent" : 0
},
{
"file" : 13,
"parent" : 39
"parent" : 40
},
{
"command" : 3,
"file" : 13,
"line" : 9,
"parent" : 40
"parent" : 41
},
{
"file" : 12,
"parent" : 41
"parent" : 42
},
{
"command" : 2,
"file" : 12,
"line" : 61,
"parent" : 42
"parent" : 43
},
{
"command" : 6,
"file" : 0,
"line" : 48,
"line" : 62,
"parent" : 0
}
]
@ -313,11 +319,11 @@
"includes" :
[
{
"backtrace" : 44,
"backtrace" : 45,
"path" : "/home/user/\u0420\u0430\u0431\u043e\u0447\u0438\u0439 \u0441\u0442\u043e\u043b/SC/SoftController"
},
{
"backtrace" : 44,
"backtrace" : 45,
"path" : "/home/user/\u0420\u0430\u0431\u043e\u0447\u0438\u0439 \u0441\u0442\u043e\u043b/SC/SoftController/models"
},
{
@ -343,7 +349,12 @@
"sourceIndexes" :
[
0,
1
1,
4,
6,
7,
9,
12
]
}
],
@ -375,87 +386,92 @@
"role" : "libraries"
},
{
"backtrace" : 8,
"backtrace" : 4,
"fragment" : "/usr/lib/x86_64-linux-gnu/libcurl.so",
"role" : "libraries"
},
{
"backtrace" : 9,
"fragment" : "/usr/local/lib/libtrantor.a",
"role" : "libraries"
},
{
"backtrace" : 14,
"backtrace" : 15,
"fragment" : "/usr/lib/x86_64-linux-gnu/libssl.so",
"role" : "libraries"
},
{
"backtrace" : 14,
"backtrace" : 15,
"fragment" : "/usr/lib/x86_64-linux-gnu/libcrypto.so",
"role" : "libraries"
},
{
"backtrace" : 14,
"backtrace" : 15,
"fragment" : "-lpthread",
"role" : "libraries"
},
{
"backtrace" : 8,
"backtrace" : 9,
"fragment" : "-ldl",
"role" : "libraries"
},
{
"backtrace" : 18,
"backtrace" : 19,
"fragment" : "/usr/lib/x86_64-linux-gnu/libjsoncpp.so",
"role" : "libraries"
},
{
"backtrace" : 8,
"backtrace" : 9,
"fragment" : "-lyaml-cpp",
"role" : "libraries"
},
{
"backtrace" : 22,
"backtrace" : 23,
"fragment" : "/usr/lib/x86_64-linux-gnu/libuuid.so",
"role" : "libraries"
},
{
"backtrace" : 26,
"backtrace" : 27,
"fragment" : "/usr/lib/x86_64-linux-gnu/libbrotlidec.so",
"role" : "libraries"
},
{
"backtrace" : 26,
"backtrace" : 27,
"fragment" : "/usr/lib/x86_64-linux-gnu/libbrotlienc.so",
"role" : "libraries"
},
{
"backtrace" : 26,
"backtrace" : 27,
"fragment" : "/usr/lib/x86_64-linux-gnu/libbrotlicommon.so",
"role" : "libraries"
},
{
"backtrace" : 30,
"backtrace" : 31,
"fragment" : "/usr/lib/x86_64-linux-gnu/libpq.so",
"role" : "libraries"
},
{
"backtrace" : 34,
"backtrace" : 35,
"fragment" : "/usr/lib/x86_64-linux-gnu/libsqlite3.so",
"role" : "libraries"
},
{
"backtrace" : 38,
"backtrace" : 39,
"fragment" : "/usr/local/lib/libhiredis.so",
"role" : "libraries"
},
{
"backtrace" : 8,
"backtrace" : 9,
"fragment" : "/usr/local/lib/libz.so",
"role" : "libraries"
},
{
"backtrace" : 43,
"backtrace" : 44,
"fragment" : "/usr/lib/x86_64-linux-gnu/libssl.so",
"role" : "libraries"
},
{
"backtrace" : 43,
"backtrace" : 44,
"fragment" : "/usr/lib/x86_64-linux-gnu/libcrypto.so",
"role" : "libraries"
}
@ -476,14 +492,24 @@
"sourceIndexes" :
[
0,
1
1,
4,
6,
7,
9,
12
]
},
{
"name" : "Header Files",
"sourceIndexes" :
[
2
2,
3,
5,
8,
10,
11
]
}
],
@ -498,13 +524,68 @@
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "wsHandler/wsSessionHandler.cpp",
"path" : "messaging/messageHandler/messageHandler.cpp",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"path" : "wsHandler/wsSessionHandler.h",
"path" : "messaging/messageHandler/messageHandler.h",
"sourceGroupIndex" : 1
},
{
"backtrace" : 1,
"path" : "nodes/ormConfigurator/ormConfigurator.h",
"sourceGroupIndex" : 1
},
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "nodes/ormConfigurator/ormConfigurator.cpp",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"path" : "nodes/reConfigurator/reConfigurator.h",
"sourceGroupIndex" : 1
},
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "nodes/reConfigurator/reConfigurator.cpp",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "messaging/messageCounter/messageCounter.cpp",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"path" : "messaging/messageCounter/messageCounter.h",
"sourceGroupIndex" : 1
},
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "messaging/messageWriter/messageWriter.cpp",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"path" : "messaging/messageWriter/messageWriter.h",
"sourceGroupIndex" : 1
},
{
"backtrace" : 1,
"path" : "nodes/reConfigurator/reHttpPoller/reHttpPoller.h",
"sourceGroupIndex" : 1
},
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "nodes/reConfigurator/reHttpPoller/reHttpPoller.cpp",
"sourceGroupIndex" : 0
}
],
"type" : "EXECUTABLE"

Binary file not shown.

View File

@ -1,45 +1,15 @@
# ninja log v6
4213 5132 1759226397914410500 SoftController affda4e9945cadbd
3 4213 1759226393704418173 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
1 99 1759228574288447609 build.ninja 4dfc72edd662679e
2 248 1759228574299447589 CMakeFiles/SoftController.dir/wsHandler/wsSessionHandler.cpp.o 3cdbae51b5aeaa59
2 4396 1759228574299447589 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4396 5304 1759228578693439588 SoftController edcd736a81ccf156
2 256 1759231650587255717 CMakeFiles/SoftController.dir/wsHandler/wsSessionHandler.cpp.o 3cdbae51b5aeaa59
2 4580 1759231650587255717 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4580 5555 1759231655165220847 SoftController edcd736a81ccf156
3 1700 1759751112595947388 CMakeFiles/SoftController.dir/ormConfigurator/ormConfigurator.cpp.o 17ba08f25bcbcbca
3 2079 1759829448072262082 CMakeFiles/SoftController.dir/messaging/messageHandler/messageHandler.cpp.o 54b2951ccff31f4d
10 231 1759834357792447435 CMakeFiles/SoftController.dir/messaging/messageCounter/messageCounter.cpp.o 9422cf8879d7867b
4 2897 1759837534999937391 CMakeFiles/SoftController.dir/nodes/reConfigurator/reHttpPoller/reHttpPoller.cpp.o 314156c49da43057
3 1660 1759826059294622495 CMakeFiles/SoftController.dir/nodes/ormConfigurator/ormConfigurator.cpp.o c29b0016436307f1
3 1821 1759827849304869885 CMakeFiles/SoftController.dir/messageHandler/messageHandler.cpp.o 38b304ce8478b160
3 4962 1759837576064751988 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4 258 1759827849305869869 CMakeFiles/SoftController.dir/nodes/reConfigurator/reConfigurator.cpp.o 9ccf90a3dcb6ec3a
4962 6072 1759837581024613096 SoftController a39e9431c4a4fd1b
3 310 1759481875602893682 CMakeFiles/SoftController.dir/wsClient/wsClient.cpp.o a70e7edaed30f74b
4 100 1759827849305869869 CMakeFiles/SoftController.dir/messageHandler/messageCounter/messageCounter.cpp.o cc810d45e85d2698
10 1984 1759834357792447435 CMakeFiles/SoftController.dir/messaging/messageWriter/messageWriter.cpp.o f3dca86d77ad93e4
1 114 1759897950907026257 build.ninja 4dfc72edd662679e
3 327 1759232483879749841 CMakeFiles/SoftController.dir/wsHandler/wsSessionHandler.cpp.o 3cdbae51b5aeaa59
2 5208 1759232483879749841 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
5208 6175 1759232489084710975 SoftController edcd736a81ccf156
3 5283 1759232817357296938 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
5283 6472 1759232822638258582 SoftController edcd736a81ccf156
3 4192 1759232976309147353 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4192 5114 1759232980498117179 SoftController edcd736a81ccf156
6 4832 1759233332290599207 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4832 6042 1759233337116564839 SoftController edcd736a81ccf156
2 4205 1759233756176591485 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4205 5195 1759233760378561754 SoftController edcd736a81ccf156
3 4799 1759233811443200534 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4799 5824 1759233816239166617 SoftController edcd736a81ccf156
2 4796 1759233844692965435 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4796 5887 1759233849486931542 SoftController edcd736a81ccf156
2 4781 1759233923486629674 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4781 6264 1759233928265623024 SoftController edcd736a81ccf156
2 5347 1759234052522378176 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
5347 6480 1759234057867364796 SoftController edcd736a81ccf156
3 4535 1759234117623201077 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4535 5533 1759234122155187651 SoftController edcd736a81ccf156
2 4427 1759234200177936139 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4427 5355 1759234204602920784 SoftController edcd736a81ccf156
3 4429 1759234279209646008 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4429 5351 1759234283634628818 SoftController edcd736a81ccf156
7 4852 1759234387225201013 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4852 5808 1759234392070179897 SoftController edcd736a81ccf156
4 4341 1759234426643026596 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4341 5331 1759234430980007052 SoftController edcd736a81ccf156
2 4248 1759234433697994769 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4248 5292 1759234437943975527 SoftController edcd736a81ccf156
2 4867 1759234469361831180 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4867 6185 1759234474226808527 SoftController edcd736a81ccf156
3 4741 1759234510933635105 CMakeFiles/SoftController.dir/main.cpp.o 38fabe9f46373cc7
4741 5771 1759234515671612410 SoftController edcd736a81ccf156

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -3,44 +3,57 @@
#include <iostream>
#include <thread>
#include <string>
#include <vector>
#include <utility>
#include <nlohmann/json.hpp>
#include <future>
#include "wsHandler/wsSessionHandler.h"
#include "messaging/messageHandler/messageHandler.h"
#include "nodes/ormConfigurator/ormConfigurator.h"
#include "nodes/reConfigurator/reConfigurator.h"
#include "messaging/messageCounter/messageCounter.h"
#include "nodes/reConfigurator/reHttpPoller/reHttpPoller.h"
bool RunWsClient(const std::string& url, const std::string& inti_message)
bool RunWS_init(std::string& url, const std::string& inti_message, ormNode *orm, GlobalCounter *msgCounter)
{
bool result;
bool result = false;
std::promise<void> finishPromise;
auto finishFuture = finishPromise.get_future();
// подключаемся как ws клиент к orm
// настраиваем webSocket
ix::WebSocket webSocket;
webSocket.setUrl(url);
std::string endpoint = getEndpointFromUrl(url);
// настройка callback
webSocket.setOnMessageCallback([&webSocket, &inti_message, &url, &finishPromise, &result](const ix::WebSocketMessagePtr &msg) {
webSocket.setOnMessageCallback([&](const ix::WebSocketMessagePtr &msg) {
if (msg->type == ix::WebSocketMessageType::Open) {
std::cout << "Соединение c " + url + " установлено\n";
webSocket.send(inti_message);
std::cout << "Отправлено сообщение: " + inti_message << std::endl;
try{
std::cout << "Соединение c " + url + " установлено\n";
webSocket.send(inti_message);
std::cout << "Отправлено сообщение: " + inti_message << std::endl;
}
catch (...){
std::cerr << "Неизвестное исключение!" << std::endl;
finishPromise.set_value();
result = false;
}
}
else if (msg->type == ix::WebSocketMessageType::Message) {
std::cout << "Получено сообщение: " << msg->str << std::endl;
try{
std::cout << "Получено сообщение: " << msg->str << std::endl;
msgCounter->increment_and_get();
// разбиваем строку на пары ключ- значение
auto json_msg = nlohmann::json::parse(msg->str);
std::vector<std::pair<std::string, std::string>> vector_msg;
for (auto& [key, value] : json_msg.items()) {
vector_msg.emplace_back(key, value.dump());
auto message_json = nlohmann::json::parse(msg->str);
msgHandler handler(message_json, url);
handler.msgHandle(orm);
finishPromise.set_value();
result = true;
}
catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
finishPromise.set_value();
result = true;
}
wsAnswerHandler(vector_msg, url);
finishPromise.set_value();
result = true;
}
else if (msg->type == ix::WebSocketMessageType::Error) {
std::cerr << "Ошибка: " << msg->errorInfo.reason << std::endl;
@ -55,35 +68,120 @@ bool RunWsClient(const std::string& url, const std::string& inti_message)
return result;
}
int main() {
// соединение с БД re
// получаем данные о RE из БД
// re_peer =
// re_version =
// re_opc_server_peer =
// status =
std::string inti_messages[] = {"{ \"re_peer\": \"re.promuc.local\", \"re_version\": \"1.0.1\", \"re_opc_server_peer\": \"re.opc.promuc.local\", \"count_message\": 1, \"count_attempts\": 3, \"count_tags_conc\": 0, \"timeout_waiting_response\": 1000, \"status\": \"init_OK_AAA\" }",
"{ \"re_peer\": \"re.promuc.local\", \"re_version\": \"1.0.1\", \"re_opc_server_peer\": \"re.opc.promuc.local\", \"count_message\": 3, \"count_attempts\": 3, \"count_tags_conc\": 0, \"timeout_waiting_response\": 1000, \"status\": \"init_OK_AAA\" }",
"{ \"re_peer\": \"re.promuc.local\", \"re_version\": \"1.0.1\", \"re_opc_server_peer\": \"re.opc.promuc.local\", \"count_message\": 7, \"count_attempts\": 3, \"count_tags_conc\": 0, \"timeout_waiting_response\": 1000, \"status\": \"init_OK_AAA\" }"};
bool RunWS(std::string& url, const std::string& inti_message, ormNode *orm, GlobalCounter *msgCounter){
bool result = false;
std::promise<void> finishPromise;
auto finishFuture = finishPromise.get_future();
std::string SD_endpoints[] = {"ws://localhost:8080/SC_SD_F1",
"ws://localhost:8080/SC_SD_F2",
"ws://localhost:8080/SC_SD_F3"};
ix::WebSocket webSocket;
webSocket.setUrl(url);
std::string endpoint = getEndpointFromUrl(url);
webSocket.setPingInterval(1);
webSocket.enableAutomaticReconnection();
webSocket.setOnMessageCallback([&](const ix::WebSocketMessagePtr& msg) {
if (msg->type == ix::WebSocketMessageType::Open)
{
std::cout << "Соединение c " + url + " установлено\n";
webSocket.send(inti_message);
std::cout << "Отправлено сообщение: " + inti_message << std::endl;
msgCounter->increment_and_get();
for(int i = 0; i < 3; i ++)
{
bool ws_conn_result = RunWsClient(SD_endpoints[i], inti_messages[i]);
while(!ws_conn_result){
std::this_thread::sleep_for(std::chrono::seconds(1));
ws_conn_result = RunWsClient(SD_endpoints[i], inti_messages[i]);
}
else if (msg->type == ix::WebSocketMessageType::Message)
{
std::cout << "Получено сообщение: " << msg->str << std::endl;
auto message_json = nlohmann::json::parse(msg->str);
msgHandler handler(message_json, url);
handler.msgHandle(orm);
result = true;
}
else if (msg->type == ix::WebSocketMessageType::Error)
{
std::cerr << "Ошибка websocket на " + endpoint + ": " << msg->errorInfo.reason << std::endl;
result = false;
}
});
webSocket.start();
finishFuture.wait();
webSocket.stop();
return result;
}
int main() {
// формируем основные сущности
ormNode orm;
reNode re;
GlobalCounter msgCounter;
reHttpPoller reHttpPoller("http://re.test.promuc.local/api/version", 60000);
// запускаем
reHttpPoller.start();
//////////////////////////////////////////
// соединение с БД re в reHttpPoller, заполняем поля reNode//
// получаем данные о RE //
re._params.re_peer = "re.local";
re._params.re_version = "1.2.1";
re._params.re_opc_server_peer = "opc.re.local";
re._params.re_location = "default";
///////////////////////////////////////////
std::string inti_messages[] = {
"{ \"re_peer\": \"re.promuc.local\", \"re_version\": \"1.0.1\", \"re_opc_server_peer\": \"re.opc.promuc.local\", \"count_message\": 1, \"count_attempts\": 3, \"count_tags_conc\": 0, \"timeout_waiting_response\": 1000, \"status\": \"init_INIT_AAA\" }",
"{ \"re_peer\": \"re.promuc.local\", \"re_version\": \"1.0.1\", \"re_opc_server_peer\": \"re.opc.promuc.local\", \"count_message\": 3, \"count_attempts\": 3, \"count_tags_conc\": 0, \"timeout_waiting_response\": 1000, \"status\": \"init_INIT_LOCATION\" }",
"{ \"re_peer\": \"re.promuc.local\", \"re_version\": \"1.0.1\", \"re_opc_server_peer\": \"re.opc.promuc.local\", \"count_message\": 7, \"count_attempts\": 3, \"count_tags_conc\": 0, \"timeout_waiting_response\": 1000, \"status\": \"init_INIT_CHAIN\" }"};
std::string fake_re_data[] = {
};
std::string SD_endpoints[] = {"ws://localhost:8080/SC_SD_F1",
"ws://localhost:8080/SC_SD_F2",
"ws://localhost:8080/SC_SD_F3"};
////////////////////////////////////////////
bool ws_conn_result = RunWS_init(SD_endpoints[0], inti_messages[0], &orm, &msgCounter);
while (!ws_conn_result) {
std::this_thread::sleep_for(std::chrono::seconds(3));
ws_conn_result = RunWS_init(SD_endpoints[0], inti_messages[0], &orm, &msgCounter);
}
// запускаем SC как веб- сервер
std::thread locations_thread([&]() {
if (orm._params.init_status == "init_OK_AAA") {
bool ws_conn_result = RunWS(SD_endpoints[1], inti_messages[1], &orm, &msgCounter);
while (!ws_conn_result) {
std::this_thread::sleep_for(std::chrono::seconds(3));
ws_conn_result = RunWS(SD_endpoints[1], inti_messages[1], &orm, &msgCounter);
}
}
else std::cout << "BAD: orm.init_status is not OK" << std::endl;
});
std::thread chains_thread([&]() {
std::unique_lock<std::mutex> lock(orm.status_mutex);
orm.status_cv.wait(lock, [&] {
return orm.status_ready;
});
bool ready_to_start_F3_ws = (orm._params.location_status == "init_OK_LOCATION");
lock.unlock();
if (ready_to_start_F3_ws) {
bool ws_conn_result = RunWS(SD_endpoints[2], inti_messages[2], &orm, &msgCounter);
while (!ws_conn_result) {
std::this_thread::sleep_for(std::chrono::seconds(3));
ws_conn_result = RunWS(SD_endpoints[2], inti_messages[2], &orm, &msgCounter);
}
}
else std::cout << "BAD: orm.location_status is not OK" << std::endl;
});
drogon::app().addListener("0.0.0.0", 4343);
drogon::app().run();
locations_thread.join();
chains_thread.join();
return 0;
}

View File

@ -0,0 +1,12 @@
#include "messageCounter.h"
GlobalCounter::GlobalCounter(){
}
uint64_t GlobalCounter::get_value(){
return value.load(std::memory_order_relaxed);
}
uint64_t GlobalCounter::increment_and_get(){
return value.fetch_add(1, std::memory_order_relaxed) + 1;
}

View File

@ -0,0 +1,17 @@
#pragma once
#include <atomic>
#include <cstdint>
#include <curl/curl.h>
class GlobalCounter{
public:
explicit GlobalCounter();
uint64_t get_value();
uint64_t increment_and_get();
protected:
std::atomic<uint64_t> value = 0;
};

View File

@ -0,0 +1,23 @@
#include "messageHandler.h"
msgHandler::msgHandler(const nlohmann::json &msg, const std::string &url) : message(msg), source(url){
//nlohmann::json message_json = nlohmann::json::parse(this->message);
//std::cout << message_json.dump(4) << std::endl; // для отладки
}
void msgHandler::msgHandle(ormNode *orm){
orm->setParams(message, source);
}
void F1StageProcessing(){
}
void F2StageProcessing(){
}
void F3StageProcessing(){
}

View File

@ -0,0 +1,25 @@
#pragma once
#include <mutex>
#include <condition_variable>
#include <iostream>
#include <string>
#include <vector>
#include <ixwebsocket/IXWebSocket.h>
#include <memory>
#include <nlohmann/json.hpp>
#include "nodes/ormConfigurator/ormConfigurator.h"
class msgHandler {
public:
explicit msgHandler(const nlohmann::json &msg, const std::string &url);
void msgHandle(ormNode *orm);
protected:
const nlohmann::json message;
const std::string source;
void F1StageProcessing();
void F2StageProcessing();
void F3StageProcessing();
};

View File

@ -0,0 +1,5 @@
#include "messageWriter.h"
msgWriter::msgWriter(const nlohmann::json &msg, const std::string &url) : message(msg), source(url) {
}

View File

@ -0,0 +1,21 @@
#pragma once
#include <mutex>
#include <condition_variable>
#include <iostream>
#include <string>
#include <vector>
#include <ixwebsocket/IXWebSocket.h>
#include <memory>
#include <nlohmann/json.hpp>
#include "nodes/reConfigurator/reConfigurator.h"
class msgWriter {
public:
explicit msgWriter(const nlohmann::json &msg, const std::string &url);
void msgWrite(reNode *re);
protected:
const nlohmann::json message;
const std::string source;
};

View File

@ -0,0 +1,34 @@
#include "ormConfigurator.h"
ormNode::ormNode() {}
void ormNode::setParams(const nlohmann::json &msg, const std::string &url) {
std::string endpoint = getEndpointFromUrl(url);
if (endpoint == "SC_SD_F1") {
this->_params.orm_peer = msg.value("orm_peer", "");
this->_params.orm_version = msg.value("orm_version", "");
this->_params.orm_opc_client_peer = msg.value("orm_opc_client_peer", "");
this->_params.init_status = msg.value("status", "");
} else if (endpoint == "SC_SD_F2") {
this->_params.location_status = msg.value("status", "");
if (this->_params.location_status == "init_OK_LOCATION") {
{
std::lock_guard<std::mutex> lock(this->status_mutex);
this->status_ready = true;
}
this->status_cv.notify_one();
}
} else if (endpoint == "SC_SD_F3") {
this->_params.chain_status = msg.value("status", "");
}
}
std::string getEndpointFromUrl(std::string url){
size_t pos = url.find_last_of('/');
std::string endpoint;
if (pos != std::string::npos) {
endpoint = url.substr(pos + 1);
}
return endpoint;
}

View File

@ -0,0 +1,29 @@
#pragma once
#include <string>
#include <nlohmann/json.hpp>
#include <mutex>
#include <condition_variable>
class ormNode {
protected:
struct params {
std::string orm_peer;
std::string orm_version;
std::string orm_opc_client_peer;
std::string init_status;
std::string location_status;
std::string chain_status;
};
public:
ormNode();
void setParams(const nlohmann::json &msg, const std::string &url);
params _params;
std::mutex status_mutex;
std::condition_variable status_cv;
bool status_ready = false;
};
std::string getEndpointFromUrl(std::string url);

View File

@ -0,0 +1,9 @@
#include "reConfigurator.h"
reNode::reNode() {}
void reNode::getParamsFromRE(reNode *re){
//curl запрос на RE /api/version
}

View File

@ -0,0 +1,19 @@
#pragma once
#include <string>
#include <curl/curl.h>
class reNode {
protected:
struct params {
std::string re_peer;
std::string re_version;
std::string re_opc_server_peer;
std::string re_location;
};
public:
reNode();
void getParamsFromRE(reNode *re);
params _params;
};

View File

@ -0,0 +1,47 @@
#include "reHttpPoller.h"
reHttpPoller::reHttpPoller(const std::string& url, long interval_ms) :
url_(url),
interval_(interval_ms){
}
void reHttpPoller::start() {
is_running_ = true;
worker_ = std::thread(&reHttpPoller::SendRequests, this);
}
void reHttpPoller::stop() {
is_running_ = false;
if (worker_.joinable()) worker_.join();
}
void reHttpPoller::setEndpoint(const std::string &url) {
this->url_ = url;
}
void reHttpPoller::SendRequests(){
CURL* curl = curl_easy_init();
while(is_running_) {
std::string readBuffer;
curl_easy_setopt(curl, CURLOPT_URL, url_.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); // отключил проверку ssl сертификата
CURLcode res = curl_easy_perform(curl);
if (res != CURLE_OK) {
std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
} else {
data_ = nlohmann::json::parse(readBuffer);
}
std::this_thread::sleep_for(std::chrono::milliseconds(interval_));
}
curl_easy_cleanup(curl);
}
size_t reHttpPoller::WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}

View File

@ -0,0 +1,30 @@
#pragma once
#include <string>
#include <thread>
#include <atomic>
#include <cstdint>
#include <curl/curl.h>
#include <iostream>
#include <nlohmann/json.hpp>
class reHttpPoller {
public:
reHttpPoller(const std::string& host, long interval_s);
void setEndpoint(const std::string& endpoint);
void start();
void stop();
~reHttpPoller() {
stop();
}
protected:
void SendRequests();
static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp);
std::atomic<bool> is_running_ = false;
std::thread worker_;
std::string url_;
int interval_;
nlohmann::json data_;
};

View File

@ -1,6 +0,0 @@
#include "wsSessionHandler.h"
void wsAnswerHandler(std::vector<std::pair<std::string, std::string>> msg, std::string url)
{
}

View File

@ -1,9 +0,0 @@
#pragma once
#ifndef SOFTCONTROLLER_WSSESSIONHANDLER_H
#define SOFTCONTROLLER_WSSESSIONHANDLER_H
#endif //SOFTCONTROLLER_WSSESSIONHANDLER_H
#include <string>
#include <vector>
void wsAnswerHandler(std::vector<std::pair<std::string, std::string>> msg, std::string url);