Skip to content

Commit

Permalink
Remove reading from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
oteffahi committed Apr 18, 2024
1 parent ffd6072 commit 968ab27
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/src/main/kotlin/io.zenoh/ZPub.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions examples/src/main/kotlin/io.zenoh/ZPubThr.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand All @@ -100,7 +100,6 @@ class ZPubThr(private val emptyArgs: Boolean) : CliktCommand(
start = System.currentTimeMillis()
}
}

}
}
}
Expand Down
1 change: 1 addition & 0 deletions examples/src/main/kotlin/io.zenoh/ZQueryable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions examples/src/main/kotlin/io.zenoh/ZSub.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions examples/src/main/kotlin/io.zenoh/ZSubThr.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit 968ab27

Please sign in to comment.