From 968ab27476ca434f23493a0f7fa5b7a0d577c418 Mon Sep 17 00:00:00 2001 From: Oussama Teffahi Date: Fri, 23 Feb 2024 17:02:34 +0100 Subject: [PATCH 1/3] Remove reading from stdin --- examples/src/main/kotlin/io.zenoh/ZPub.kt | 1 + examples/src/main/kotlin/io.zenoh/ZPubThr.kt | 3 +-- examples/src/main/kotlin/io.zenoh/ZQueryable.kt | 1 + examples/src/main/kotlin/io.zenoh/ZSub.kt | 1 + examples/src/main/kotlin/io.zenoh/ZSubThr.kt | 2 ++ 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/src/main/kotlin/io.zenoh/ZPub.kt b/examples/src/main/kotlin/io.zenoh/ZPub.kt index 69e8144f..e0c7cb71 100644 --- a/examples/src/main/kotlin/io.zenoh/ZPub.kt +++ b/examples/src/main/kotlin/io.zenoh/ZPub.kt @@ -62,6 +62,7 @@ class ZPub(private val emptyArgs: Boolean) : CliktCommand( println("Declaring publisher on '$keyExpr'...") session.declarePublisher(keyExpr).res().onSuccess { pub -> pub.use { + println("Press CTRL-C to quit...") val attachment = attachment?.let { decodeAttachment(it) } var idx = 0 while (true) { diff --git a/examples/src/main/kotlin/io.zenoh/ZPubThr.kt b/examples/src/main/kotlin/io.zenoh/ZPubThr.kt index 6e28947d..f031b7ad 100644 --- a/examples/src/main/kotlin/io.zenoh/ZPubThr.kt +++ b/examples/src/main/kotlin/io.zenoh/ZPubThr.kt @@ -87,9 +87,9 @@ class ZPubThr(private val emptyArgs: Boolean) : CliktCommand( var count: Long = 0 var start = System.currentTimeMillis() val number = number.toLong() + println("Press CTRL-C to quit...") while (true) { pub.put(value).res().getOrThrow() - if (statsPrint) { if (count < number) { count++ @@ -100,7 +100,6 @@ class ZPubThr(private val emptyArgs: Boolean) : CliktCommand( start = System.currentTimeMillis() } } - } } } diff --git a/examples/src/main/kotlin/io.zenoh/ZQueryable.kt b/examples/src/main/kotlin/io.zenoh/ZQueryable.kt index dc6a4964..d780c16e 100644 --- a/examples/src/main/kotlin/io.zenoh/ZQueryable.kt +++ b/examples/src/main/kotlin/io.zenoh/ZQueryable.kt @@ -64,6 +64,7 @@ class ZQueryable(private val emptyArgs: Boolean) : CliktCommand( println("Declaring Queryable") session.declareQueryable(keyExpr).res().onSuccess { queryable -> queryable.use { + println("Press CTRL-C to quit...") queryable.receiver?.let { receiverChannel -> // The default receiver is a Channel we can process on a coroutine. runBlocking { handleRequests(receiverChannel, keyExpr) diff --git a/examples/src/main/kotlin/io.zenoh/ZSub.kt b/examples/src/main/kotlin/io.zenoh/ZSub.kt index e29eb764..46f724b8 100644 --- a/examples/src/main/kotlin/io.zenoh/ZSub.kt +++ b/examples/src/main/kotlin/io.zenoh/ZSub.kt @@ -54,6 +54,7 @@ class ZSub(private val emptyArgs: Boolean) : CliktCommand( println("Declaring Subscriber on '$keyExpr'...") session.declareSubscriber(keyExpr).bestEffort().res().onSuccess { subscriber -> subscriber.use { + println("Press CTRL-C to quit...") runBlocking { val receiver = subscriber.receiver!! val iterator = receiver.iterator() diff --git a/examples/src/main/kotlin/io.zenoh/ZSubThr.kt b/examples/src/main/kotlin/io.zenoh/ZSubThr.kt index 4e42be48..e1fea119 100644 --- a/examples/src/main/kotlin/io.zenoh/ZSubThr.kt +++ b/examples/src/main/kotlin/io.zenoh/ZSubThr.kt @@ -104,9 +104,11 @@ class ZSubThr(private val emptyArgs: Boolean) : CliktCommand( println("Opening Session") Session.open(config).onSuccess { it.use { session -> + println("Press CTRL-C to quit...") subscriber = session.declareSubscriber(keyExpr).reliable().with { listener(number) }.res().getOrThrow() while (subscriber.isValid()) {/* Keep alive the subscriber until the test is done. */ + Thread.sleep(1000) } } } From 92095453768730ea19d2b528780cc701b31838ac Mon Sep 17 00:00:00 2001 From: Oussama Teffahi Date: Wed, 28 Feb 2024 18:27:34 +0100 Subject: [PATCH 2/3] Add queryable keyexpr to stdout --- examples/src/main/kotlin/io.zenoh/ZQueryable.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/main/kotlin/io.zenoh/ZQueryable.kt b/examples/src/main/kotlin/io.zenoh/ZQueryable.kt index d780c16e..a11967a7 100644 --- a/examples/src/main/kotlin/io.zenoh/ZQueryable.kt +++ b/examples/src/main/kotlin/io.zenoh/ZQueryable.kt @@ -61,7 +61,7 @@ class ZQueryable(private val emptyArgs: Boolean) : CliktCommand( session.use { key.intoKeyExpr().onSuccess { keyExpr -> keyExpr.use { - println("Declaring Queryable") + println("Declaring Queryable on " + key + "...") session.declareQueryable(keyExpr).res().onSuccess { queryable -> queryable.use { println("Press CTRL-C to quit...") From ed182bcd1aa40ebe9ffcdce62d769813d295b68d Mon Sep 17 00:00:00 2001 From: Oussama Teffahi Date: Thu, 18 Apr 2024 16:18:50 +0200 Subject: [PATCH 3/3] Add index to ZPub payload --- examples/src/main/kotlin/io.zenoh/ZPub.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/src/main/kotlin/io.zenoh/ZPub.kt b/examples/src/main/kotlin/io.zenoh/ZPub.kt index e0c7cb71..ac0dc009 100644 --- a/examples/src/main/kotlin/io.zenoh/ZPub.kt +++ b/examples/src/main/kotlin/io.zenoh/ZPub.kt @@ -67,14 +67,15 @@ class ZPub(private val emptyArgs: Boolean) : CliktCommand( var idx = 0 while (true) { Thread.sleep(1000) - println( - "Putting Data ('$keyExpr': '[${ + val payload = "[${ idx.toString().padStart(4, ' ') - }] $value')..." + }] $value" + println( + "Putting Data ('$keyExpr': '$payload')..." ) attachment?.let { - pub.put(value).withAttachment(attachment).res() - } ?: let { pub.put(value).res() } + pub.put(payload).withAttachment(attachment).res() + } ?: let { pub.put(payload).res() } idx++ } }