Skip to content

Commit

Permalink
GH-1650: Fix demo-server about unexpected "Device is not awake" message
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Sep 12, 2024
1 parent baa124f commit 7a52fbf
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,12 @@ public CompletableFuture<LwM2mResponse> send(Registration destination, DownlinkD
long timeoutInMs) throws InterruptedException {

// is client awake ?
boolean useQueueMode = destination.usesQueueMode();
boolean clientAwake = server.getPresenceService().isClientAwake(destination);

// client is awake we try to send request now
CompletableFuture<LwM2mResponse> future = new CompletableFuture<>();
if (clientAwake) {
if (clientAwake || !useQueueMode) {
try {
// TODO ideally we should use async way to send request
LwM2mResponse response = server.send(destination, request, timeoutInMs);
Expand All @@ -116,7 +117,7 @@ public CompletableFuture<LwM2mResponse> send(Registration destination, DownlinkD
}

// client is not awake we queue the request for later.
if (!clientAwake) {
if (useQueueMode && !clientAwake) {
QueueRequestData data = new QueueRequestData();
data.request = request;
data.responseFuture = future;
Expand Down

0 comments on commit 7a52fbf

Please # to comment.