diff --git a/examples/universal/z_pub.cxx b/examples/universal/z_pub.cxx index 872353b9..c7e715ec 100644 --- a/examples/universal/z_pub.cxx +++ b/examples/universal/z_pub.cxx @@ -88,7 +88,8 @@ int _main(int argc, char **argv) { PublisherPutOptions options; options.set_encoding(Z_ENCODING_PREFIX_TEXT_PLAIN); - for (int idx = 0; std::numeric_limits::max(); ++idx) { + std::cout << "Press CTRL-C to quit..." << std::endl; + for (int idx = 0; idx < std::numeric_limits::max(); ++idx) { sleep(1); std::ostringstream ss; ss << "[" << idx << "] " << value; diff --git a/examples/universal/z_pub_attachment.cxx b/examples/universal/z_pub_attachment.cxx index 38728a8f..72fe74a9 100644 --- a/examples/universal/z_pub_attachment.cxx +++ b/examples/universal/z_pub_attachment.cxx @@ -79,7 +79,8 @@ int _main(int argc, char **argv) { // add some value amap.insert(std::pair("source", "C++")); #endif - for (int idx = 0; std::numeric_limits::max(); ++idx) { + std::cout << "Press CTRL-C to quit..." << std::endl; + for (int idx = 0; idx < std::numeric_limits::max(); ++idx) { sleep(1); std::ostringstream ss; ss << "[" << idx << "] " << value; diff --git a/examples/universal/z_pub_thr.cxx b/examples/universal/z_pub_thr.cxx index da783c43..e1b27a26 100644 --- a/examples/universal/z_pub_thr.cxx +++ b/examples/universal/z_pub_thr.cxx @@ -37,6 +37,11 @@ int _main(int argc, char **argv) { std::vector payload(len, 1); Config config; +#ifdef ZENOHCXX_ZENOHC + if (configfile) { + config = expect(config_from_file(configfile)); + } +#endif if (locator) { #ifdef ZENOHCXX_ZENOHC auto locator_json_str_list = std::string("[\"") + locator + "\"]"; @@ -62,6 +67,7 @@ int _main(int argc, char **argv) { printf("Declaring Publisher on '%s'...\n", keyexpr); auto pub = expect(session.declare_publisher(keyexpr, options)); + printf("Press CTRL-C to quit...\n"); while (1) pub.put(payload); } diff --git a/examples/universal/z_pull.cxx b/examples/universal/z_pull.cxx index da2f8406..3d21f1b4 100644 --- a/examples/universal/z_pull.cxx +++ b/examples/universal/z_pull.cxx @@ -19,6 +19,7 @@ #include #endif #include +#include #include "../getargs.h" #include "zenoh.hxx" @@ -75,15 +76,11 @@ int _main(int argc, char **argv) { printf("Declaring Subscriber on '%s'...\n", expr); auto subscriber = expect(session.declare_pull_subscriber(keyexpr, data_handler)); - printf("Press to pull data...\n"); - int c = 0; - while (c != 'q') { - c = getchar(); - if (c == -1) { - sleep(1); - } else { - subscriber.pull(); - } + printf("Press CTRL-C to quit...\n"); + for (int idx = 0; idx < std::numeric_limits::max(); ++idx) { + sleep(1); + printf("[%4d] Pulling...\n", idx); + subscriber.pull(); } return 0; diff --git a/examples/universal/z_queryable.cxx b/examples/universal/z_queryable.cxx index a9d144ca..10190f42 100644 --- a/examples/universal/z_queryable.cxx +++ b/examples/universal/z_queryable.cxx @@ -95,13 +95,9 @@ int _main(int argc, char **argv) { auto queryable = expect(session.declare_queryable(keyexpr, {on_query, on_drop_queryable})); - printf("Enter 'q' to quit...\n"); - int c = 0; - while (c != 'q') { - c = getchar(); - if (c == -1) { - sleep(1); - } + printf("Press CTRL-C to quit...\n"); + while (1) { + sleep(1); } return 0; diff --git a/examples/universal/z_queryable_attachment.cxx b/examples/universal/z_queryable_attachment.cxx index 20bdc842..a95f0427 100644 --- a/examples/universal/z_queryable_attachment.cxx +++ b/examples/universal/z_queryable_attachment.cxx @@ -102,13 +102,9 @@ int _main(int argc, char **argv) { auto queryable = expect(session.declare_queryable(keyexpr, {on_query, on_drop_queryable})); - printf("Enter 'q' to quit...\n"); - int c = 0; - while (c != 'q') { - c = getchar(); - if (c == -1) { - sleep(1); - } + printf("Press CTRL-C to quit...\n"); + while (1) { + sleep(1); } return 0; diff --git a/examples/universal/z_sub.cxx b/examples/universal/z_sub.cxx index ff457d22..a244d7f0 100644 --- a/examples/universal/z_sub.cxx +++ b/examples/universal/z_sub.cxx @@ -77,13 +77,9 @@ int _main(int argc, char **argv) { std::cout << "Subscriber on '" << subscriber.get_keyexpr().as_string_view() << "' declared" << std::endl; #endif - printf("Enter 'q' to quit...\n"); - int c = 0; - while (c != 'q') { - c = getchar(); - if (c == -1) { - sleep(1); - } + printf("Press CTRL-C to quit...\n"); + while (1) { + sleep(1); } return 0; diff --git a/examples/universal/z_sub_attachment.cxx b/examples/universal/z_sub_attachment.cxx index 26c3e8a4..28770eff 100644 --- a/examples/universal/z_sub_attachment.cxx +++ b/examples/universal/z_sub_attachment.cxx @@ -76,13 +76,9 @@ int _main(int argc, char **argv) { std::cout << "Subscriber on '" << subscriber.get_keyexpr().as_string_view() << "' declared" << std::endl; #endif - printf("Enter 'q' to quit...\n"); - int c = 0; - while (c != 'q') { - c = getchar(); - if (c == -1) { - sleep(1); - } + printf("Press CTRL-C to quit...\n"); + while (1) { + sleep(1); } return 0; diff --git a/examples/universal/z_sub_thr.cxx b/examples/universal/z_sub_thr.cxx index 7a62492c..4ad95413 100644 --- a/examples/universal/z_sub_thr.cxx +++ b/examples/universal/z_sub_thr.cxx @@ -13,6 +13,12 @@ // #include #include +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) +#include +#define sleep(x) Sleep(x * 1000) +#else +#include +#endif #include "../getargs.h" #include "zenoh.hxx" @@ -98,10 +104,12 @@ int _main(int argc, char **argv) { Stats stats; auto subscriber = expect(session.declare_subscriber(keyexpr, {stats, stats})); - char c = 0; - while (c != 'q') { - c = fgetc(stdin); + + printf("Press CTRL-C to quit...\n"); + while (1) { + sleep(1); } + subscriber.drop(); stats.print();