score-back/src/server_main.cpp
amukhamadiev ece26e7b1f [jsonrpccxx] moved to external rpc impl
Detailed:
      As base used jsonrpccxx implementation paired with TCP socket
      TCP socket updated to handle dynamic sized buffers
      TCP communication protocol changed to serialized packet size after
      which json string is presented
2026-02-20 17:51:14 +03:00

58 lines
1.7 KiB
C++

#include "cloud_point_rpc/config.hpp"
#include "cloud_point_rpc/rpc_server.hpp"
#include "cloud_point_rpc/service.hpp"
#include "cloud_point_rpc/tcp_server.hpp"
#include <glog/logging.h>
#include <string>
using json = nlohmann::json;
int main(int argc, char *argv[]) {
google::InitGoogleLogging(argv[0]);
google::InstallFailureSignalHandler();
FLAGS_alsologtostderr = 1;
std::string config_path = "config.yaml";
if (argc > 1) {
config_path = argv[1];
}
LOG(INFO) << "Starting Cloud Point RPC Server (Test Mock)...";
try {
auto config = cloud_point_rpc::ConfigLoader::load(config_path);
LOG(INFO) << "Loaded config from " << config_path;
// Inject test data into service
cloud_point_rpc::Service service(config.test_data);
cloud_point_rpc::RpcServer rpc_server;
rpc_server.register_method("get-intrinsic-params", [&](const json &) {
return service.get_intrinsic_params();
});
rpc_server.register_method("get-extrinsic-params", [&](const json &) {
return service.get_extrinsic_params();
});
rpc_server.register_method("get-cloud-point", [&](const json &) {
return service.get_cloud_point();
});
cloud_point_rpc::TcpServer server(config.server.ip, config.server.port,
[&](const std::string &request) {
return rpc_server.process(
request);
});
server.start();
server.join();
} catch (const std::exception &e) {
LOG(ERROR) << "Fatal error: " << e.what();
return 1;
}
return 0;
}