| 50 | } |
| 51 | |
| 52 | aimrt::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 | |
| 80 | void RpcClientModule::Shutdown() { |
| 81 | try { |
nothing calls this directly
no test coverage detected