Skip to content

Commit

Permalink
Fix ZGet example
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIMP committed Dec 27, 2024
1 parent 9f9ddae commit 6634e50
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions examples/src/main/java/io/zenoh/ZGet.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,20 @@ public Integer call() throws ZError, InterruptedException {
Config config = loadConfig(emptyArgs, configFile, connect, listen, noMulticastScouting, mode);
Selector selector = Selector.tryFrom(this.selectorOpt);

ZBytes payload = Optional.ofNullable(this.payload)
.map(ZBytes::from)
.orElse(null);
ZBytes attachment = Optional.ofNullable(this.attachment)
.map(ZBytes::from)
.orElse(null);

// Load GET options
GetOptions options = new GetOptions();
options.setPayload(ZBytes.from(this.payload));

options.setPayload(payload);
options.setTarget(QueryTarget.valueOf(this.target));
options.setTimeout(Duration.ofMillis(this.timeout));
options.setAttachment(ZBytes.from(this.attachment));
options.setAttachment(attachment);


// A GET query can be performed in different ways, by default (using a blocking queue), using a callback
Expand Down Expand Up @@ -146,7 +154,8 @@ private void handleReply(Reply reply) {
@CommandLine.Option(
names = {"-t", "--target"},
description = "The target queryables of the query. Default: BEST_MATCHING. " +
"[possible values: BEST_MATCHING, ALL, ALL_COMPLETE]"
"[possible values: BEST_MATCHING, ALL, ALL_COMPLETE]",
defaultValue = "BEST_MATCHING"
)
private String target;

Expand Down

0 comments on commit 6634e50

Please sign in to comment.