added external rpc implementation

This commit is contained in:
Artur Mukhamadiev 2026-02-06 17:37:07 +03:00
parent 9b482ae956
commit 4ddaea91a7
4 changed files with 13 additions and 8 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "rpc"]
path = rpc
url = https://github.com/jsonrpcx/json-rpc-cxx.git

View File

@ -1,21 +1,22 @@
#pragma once #pragma once
#include <string>
#include <functional> #include <functional>
#include <jsonrpccxx/server.hpp>
#include <map> #include <map>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string>
namespace cloud_point_rpc { namespace cloud_point_rpc {
class RpcServer { class RpcServer {
public: public:
using Handler = std::function<nlohmann::json(const nlohmann::json&)>; using Handler = std::function<nlohmann::json(const nlohmann::json&)>;
void register_method(const std::string& name, Handler handler); void register_method(const std::string& name, Handler handler);
[[nodiscard]] std::string process(const std::string& request_str); [[nodiscard]] std::string process(const std::string& request_str);
private: private:
std::map<std::string, Handler> handlers_; std::map<std::string, Handler> handlers_;
}; };
} // namespace cloud_point_rpc } // namespace cloud_point_rpc

View File

@ -22,7 +22,7 @@ gtest_dep = gtest_proj.get_variable('gtest_dep')
gtest_main_dep = gtest_proj.get_variable('gtest_main_dep') gtest_main_dep = gtest_proj.get_variable('gtest_main_dep')
gmock_dep = gtest_proj.get_variable('gmock_dep') gmock_dep = gtest_proj.get_variable('gmock_dep')
inc = include_directories('include') inc = include_directories(['include', 'rpc/include'])
subdir('src') subdir('src')
subdir('tests') subdir('tests')

1
rpc Submodule

@ -0,0 +1 @@
Subproject commit a0e195b575d62cb07016321ac9cd7e1b9e048fe5