From 63c169ecdcfd59dec8b66dddf9d26ca1c93832ee Mon Sep 17 00:00:00 2001 From: Simon Bernard Date: Thu, 27 May 2021 18:17:00 +0200 Subject: [PATCH] Server-demo-v2: Add Queue mode usage or sleeping info. --- .../servlet/json/RegistrationSerializer.java | 1 + .../webapp2/src/components/ClientInfo.vue | 22 +++++++++++++------ .../webapp2/src/views/Client.vue | 3 +++ .../webapp2/src/views/Clients.vue | 9 +++++++- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/json/RegistrationSerializer.java b/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/json/RegistrationSerializer.java index deca7ed0c3..1171e51d04 100644 --- a/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/json/RegistrationSerializer.java +++ b/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/json/RegistrationSerializer.java @@ -51,6 +51,7 @@ public JsonElement serialize(Registration src, Type typeOfSrc, JsonSerialization element.add("objectLinks", context.serialize(src.getSortedObjectLinks())); element.add("secure", context.serialize(src.getIdentity().isSecure())); element.add("additionalRegistrationAttributes", context.serialize(src.getAdditionalRegistrationAttributes())); + element.add("queuemode", context.serialize(src.usesQueueMode())); if (src.usesQueueMode()) { element.add("sleeping", context.serialize(!presenceService.isClientAwake(src))); diff --git a/leshan-server-demo/webapp2/src/components/ClientInfo.vue b/leshan-server-demo/webapp2/src/components/ClientInfo.vue index 4d8c88233b..42c4c7574b 100644 --- a/leshan-server-demo/webapp2/src/components/ClientInfo.vue +++ b/leshan-server-demo/webapp2/src/components/ClientInfo.vue @@ -7,9 +7,13 @@ mdi-information - lifetime : {{ registration.lifetime }}s + Lifetime : {{ registration.lifetime }}s
- Binding mode : {{ registration.bindingMode }} + Binding mode : {{ registration.bindingMode }} + +
+ Using QueueMode +

Protocole version : {{ registration.lwM2mVersion }}
@@ -31,6 +35,15 @@ Communication over DTLS + + + + Device using Queue mode is absent + diff --git a/leshan-server-demo/webapp2/src/views/Client.vue b/leshan-server-demo/webapp2/src/views/Client.vue index 234444a608..7843df68d4 100644 --- a/leshan-server-demo/webapp2/src/views/Client.vue +++ b/leshan-server-demo/webapp2/src/views/Client.vue @@ -122,6 +122,9 @@ export default { .on("DEREGISTRATION", () => { this.registration = null; }) + .on("SLEEPING", () => { + this.registration.sleeping = true; + }) .on("NOTIFICATION", (msg) => { if (msg.val.resources) { this.$store.newInstanceValue( diff --git a/leshan-server-demo/webapp2/src/views/Clients.vue b/leshan-server-demo/webapp2/src/views/Clients.vue index f873852823..a5dbf47ace 100644 --- a/leshan-server-demo/webapp2/src/views/Clients.vue +++ b/leshan-server-demo/webapp2/src/views/Clients.vue @@ -17,7 +17,7 @@ {{ new Date(item.lastUpdate) | moment("MMM D, h:mm:ss A") }} @@ -64,6 +64,13 @@ export default { (r) => reg.registrationId !== r.registrationId ); }) + .on("SLEEPING", (reg) => { + for (var i = 0; i < this.registrations.length; i++) { + if (this.registrations[i].endpoint === reg.ep) { + this.registrations[i].sleeping = true; + } + } + }) .on("error", (err) => { console.error("sse unexpected error", err); });