MCPcopy Create free account
hub / github.com/AimRT/AimRT / RpcTask

Method RpcTask

src/examples/cpp/context/module/rpc_client_module/rpc_client_module.cc:52–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52aimrt::co::Task<void> RpcClientModule::RpcTask() {
53 ctx_ptr_->LetMe();
54
55 try {
56 AIMRT_INFO("Start RPC loop.");
57
58 while (ctx_ptr_->Running()) {
59 aimrt::protocols::example::GetFooDataReq req;
60 aimrt::protocols::example::GetFooDataRsp rsp;
61 req.set_msg("hello world");
62 auto status = co_await client_.GetFooData(req, rsp);
63 if (status.OK()) {
64 AIMRT_INFO("RPC call succeeded, response: {}", rsp.msg());
65 } else {
66 AIMRT_WARN("RPC call failed, status: {}", status.ToString());
67 }
68
69 co_await aimrt::co::ScheduleAfter(aimrt::co::AimRTScheduler(time_executor_), std::chrono::milliseconds(static_cast<uint32_t>(1000 / rpc_frq_)));
70 }
71
72 AIMRT_INFO("Exit RPC loop.");
73 } catch (const std::exception& e) {
74 AIMRT_ERROR("RpcTask failed: {}", e.what());
75 }
76
77 co_return;
78}
79
80void RpcClientModule::Shutdown() {
81 try {

Callers

nothing calls this directly

Calls 7

AimRTSchedulerClass · 0.85
LetMeMethod · 0.80
RunningMethod · 0.80
OKMethod · 0.80
whatMethod · 0.80
GetFooDataMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected