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
35 lines
1.0 KiB
C++
35 lines
1.0 KiB
C++
#include "cloud_point_rpc/cli.hpp"
|
|
#include "cloud_point_rpc/config.hpp"
|
|
#include <fstream>
|
|
#include <glog/logging.h>
|
|
#include <iostream>
|
|
|
|
int main(int argc, char *argv[]) {
|
|
google::InitGoogleLogging(argv[0]);
|
|
FLAGS_logtostderr = 1;
|
|
|
|
std::string config_path = "config.yaml";
|
|
if (argc > 1) {
|
|
config_path = argv[1];
|
|
}
|
|
|
|
// Check if config file exists
|
|
std::ifstream f(config_path.c_str());
|
|
if (!f.good()) {
|
|
std::cerr << "Config file not found: " << config_path << std::endl;
|
|
std::cerr << "Please create config.yaml or provide path as argument."
|
|
<< std::endl;
|
|
return 1;
|
|
}
|
|
f.close();
|
|
|
|
try {
|
|
auto config = cloud_point_rpc::ConfigLoader::load(config_path);
|
|
return cloud_point_rpc::run_cli(std::cin, std::cout, config.server.ip,
|
|
config.server.port);
|
|
} catch (const std::exception &e) {
|
|
std::cerr << "Failed to start CLI: " << e.what() << std::endl;
|
|
return 1;
|
|
}
|
|
}
|