|
16 | 16 | */ |
17 | 17 | package com.mbed.coap.cli; |
18 | 18 |
|
19 | | -import static java.util.concurrent.CompletableFuture.completedFuture; |
20 | 19 | import com.mbed.coap.client.RegistrationManager; |
21 | 20 | import com.mbed.coap.packet.CoapRequest; |
22 | 21 | import com.mbed.coap.packet.CoapResponse; |
@@ -77,20 +76,20 @@ public Integer call() throws Exception { |
77 | 76 | } |
78 | 77 |
|
79 | 78 | protected Service<CoapRequest, CoapResponse> createRouting() { |
80 | | - Service<CoapRequest, CoapResponse> timeResource = __ -> completedFuture(CoapResponse.ok(Instant.now().toString())); |
| 79 | + Service<CoapRequest, CoapResponse> timeResource = __ -> CoapResponse.ok(Instant.now().toString()).toFuture(); |
81 | 80 |
|
82 | 81 | scheduledExecutor.scheduleAtFixedRate(() -> |
83 | 82 | obsManager.sendObservation("/time", timeResource), |
84 | 83 | 30, 30, TimeUnit.SECONDS |
85 | 84 | ); |
86 | 85 |
|
87 | 86 | return RouterService.builder() |
88 | | - .get("/3/0/1", __ -> completedFuture(CoapResponse.ok("Acme"))) |
89 | | - .get("/3/0/2", __ -> completedFuture(CoapResponse.ok("Emulator"))) |
90 | | - .get("/3/0/3", __ -> completedFuture(CoapResponse.ok("0.0.1"))) |
| 87 | + .get("/3/0/1", __ -> CoapResponse.ok("Acme").toFuture()) |
| 88 | + .get("/3/0/2", __ -> CoapResponse.ok("Emulator").toFuture()) |
| 89 | + .get("/3/0/3", __ -> CoapResponse.ok("0.0.1").toFuture()) |
91 | 90 | .get("/delayed-10s", __ -> { |
92 | 91 | CompletableFuture<CoapResponse> promise = new CompletableFuture<>(); |
93 | | - scheduledExecutor.schedule(() -> promise.complete(CoapResponse.ok("OK")), 10, TimeUnit.SECONDS); |
| 92 | + scheduledExecutor.schedule(() -> promise.complete(CoapResponse.ok("OK").build()), 10, TimeUnit.SECONDS); |
94 | 93 | return promise; |
95 | 94 | }) |
96 | 95 | .get("/time", obsManager.then(timeResource)) |
|
0 commit comments