Skip to content

Commit

Permalink
fix queryable examples (eclipse-zenoh#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 authored Dec 11, 2024
1 parent 0b42e29 commit 282a045
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/universal/z_queryable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int _main(int argc, char **argv) {
auto on_query = [payload, keyexpr](const Query &query) {
auto params = query.get_parameters();
auto query_payload = query.get_payload();
std::cout << ">> [Queryable ] Received Query '" << keyexpr << "?" << params;
std::cout << ">> [Queryable ] Received Query '" << query.get_keyexpr().as_string_view() << "?" << params;
if (query_payload.has_value()) {
std::cout << "' with value = '" << query_payload->get().as_string();
}
Expand Down
8 changes: 4 additions & 4 deletions examples/zenohc/z_queryable_shm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int _main(int argc, char **argv) {
std::cout << "Preparing SHM Provider...\n";
PosixShmProvider provider(MemoryLayout(65536, AllocAlignment({0})));

auto on_query = [provider = std::move(provider), payload](const Query &query) {
auto on_query = [provider = std::move(provider), payload, keyexpr](const Query &query) {
auto query_payload = query.get_payload();

const char *payload_type = "";
Expand All @@ -63,10 +63,9 @@ int _main(int argc, char **argv) {
}
}

const KeyExpr &keyexpr = query.get_keyexpr();
auto params = query.get_parameters();
std::cout << ">> [Queryable ] Received Query [" << payload_type << "] '" << keyexpr.as_string_view() << "?"
<< params;
std::cout << ">> [Queryable ] Received Query [" << payload_type << "] '" << query.get_keyexpr().as_string_view()
<< "?" << params;
if (query_payload.has_value()) {
std::cout << "' value = '" << query_payload->get().as_string();
}
Expand All @@ -77,6 +76,7 @@ int _main(int argc, char **argv) {
ZShmMut &&buf = std::get<ZShmMut>(std::move(alloc_result));
memcpy(buf.data(), payload.data(), len);

std::cout << "[Queryable ] Responding ('" << keyexpr << "': '" << payload << "')\n";
query.reply(keyexpr, std::move(buf));
};

Expand Down

0 comments on commit 282a045

Please sign in to comment.