From ff9fdebe5b316878b2822dc18dcea426629e03fe Mon Sep 17 00:00:00 2001 From: Michael <4115205+MelamudMichael@users.noreply.github.com> Date: Thu, 29 Feb 2024 21:14:50 +0200 Subject: [PATCH] Update main_rpc_client.cpp --- rpc/src/main_rpc_client.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rpc/src/main_rpc_client.cpp b/rpc/src/main_rpc_client.cpp index bd2ebd8..a7f7910 100644 --- a/rpc/src/main_rpc_client.cpp +++ b/rpc/src/main_rpc_client.cpp @@ -54,19 +54,21 @@ UPayload sendRPC(UUri& uri) { uint8_t buffer[BUFFER_SIZE] = {0}; UPayload payload(buffer, sizeof(buffer), UPayloadType::VALUE); - + /* send the RPC request , a future is returned from invokeMethod */ std::future result = ZenohRpcClient::instance().invokeMethod(uri, payload, attributes); if (!result.valid()) { spdlog::error("Future is invalid"); return UPayload(nullptr, 0, UPayloadType::UNDEFINED); } - + /* wait for the future to be fullfieled - it is possible also to specify a timeout for the future */ result.wait(); return result.get(); } +/* The sample RPC client applications demonstrates how to send RPC requests and wait for the response - + * The response in this example will be the current time */ int main(int argc, char** argv) { signal(SIGINT, signalHandler); @@ -74,6 +76,7 @@ int main(int argc, char** argv) { UStatus status; ZenohRpcClient *rpcClient = &ZenohRpcClient::instance(); + /* init RPC client */ status = rpcClient->init(); if (UCode::OK != status.code()) { spdlog::error("init failed"); @@ -96,6 +99,7 @@ int main(int argc, char** argv) { sleep(1); } + /* term RPC client */ status = rpcClient->term(); if (UCode::OK != status.code()) { spdlog::error("term failed");