mesytec-mnode/src/mnode_proto_rpc_ping_server.cc

54 lines
1.4 KiB
C++
Raw Normal View History

#include <memory>
#include <mesytec-mvlc/mesytec-mvlc.h>
#include <mesytec-mvlc/util/signal_handling.h>
#include "proto/service.pb.h"
#include "proto/mvlc.pb.h"
#include <mesytec-mnode/mnode_nng_async.h>
#include "internal/argh.h"
using namespace mesytec;
using namespace std::literals;
void print_service_descriptors(google::protobuf::Service &service)
{
auto sd = service.GetDescriptor();
spdlog::info("service: full_name={}, index={}, method_count={}",
sd->full_name(), sd->index(), sd->method_count());
for (int i = 0; i < sd->method_count(); ++i)
{
auto md = sd->method(i);
auto it = md->input_type();
auto ot = md->output_type();
spdlog::info(" method: full_name={}, index={}, input_type={}, output_type={}",
md->full_name(), md->index(), it->full_name(), ot->full_name());
}
}
int main()
{
namespace nng = mnode::nng;
spdlog::set_level(spdlog::level::debug);
mnode::PingService_Stub pingService(nullptr);
print_service_descriptors(pingService);
mnode::vme::VmeAccess_Stub vmeService(nullptr);
print_service_descriptors(vmeService);
mnode::mvlc::MVLC_Stub mvlcService(nullptr);
print_service_descriptors(mvlcService);
auto socket = nng::make_rep_socket();
if (int res = nng_listen(socket, "tcp://localhost:5555", nullptr, 0))
{
nng::mnode_nng_error("nng_listen", res);
return res;
}
return 0;
}