Add very simple Queue mode support to Leshan Server Demo. #1645
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Queue Mode
LWM2M define "Queue Mode" to handle some specific scenario (sleeping device or device behind NAT). This mode is used when device could be sometime unreachable and so requests could only be sent when device initiates a communication with the server. IMHO it should be named "Device Initiated mode"...
Current Leshan Behavior
Leshan library doesn't provide an out of the box way to store requests and send it later when "device is awake".
But there is API to help user to implement it using
PresenceService
to know when the device is awake.Until now, Leshan Server Demo just show an error message if you try to send a request to a "sleeping device" :
Warning
Invalid request: The destination client is sleeping, request cannot be sent.
Some users express the need to have a simple queue mode in Leshan Server Demo to better understand the feature.
Community request
Following discussion at #1598, some users wanted a simple In Memorry implementation for Leshan Server Demo where request should be stored when device is sleeping and automatically send next time it is awake.
In this PR
So this PR aims to provide this.
The backend part written in java and based on Leshan Library is pretty easy to code.
But the javascript web UI is not really adapted to do that so the feature is here but not so user friendly.
The mains issue is when you click on a button to execute a LWM2M operation, this trigger syncronouly :
an http request which lead to a lwm2m request which lead to lwm2m response which lead to http response.
Ideally with queue mode we would like a more async mode.
Anyway with this PR when you try to send a request to a sleeping device.
LWM2M operation button state will be reset (there is no indicator on the button)
Then you get this kind of message :
At server side we store the last request for a given device.
When device is awake we execute, the stored request.
In the UI if this is a Read / ReadComposite request you will see the value updated :