Skip to content

Commit

Permalink
Server-demo-v2: Add Queue mode usage or sleeping info.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Jun 1, 2021
1 parent 748e9c5 commit 63c169e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
22 changes: 15 additions & 7 deletions leshan-server-demo/webapp2/src/components/ClientInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
mdi-information
</v-icon>
</template>
lifetime : {{ registration.lifetime }}s
Lifetime : {{ registration.lifetime }}s
<br />
Binding mode : {{ registration.bindingMode }}
Binding mode : {{ registration.bindingMode }}
<span v-if="registration.queuemode">
<br />
Using QueueMode
</span>
<br />
Protocole version : {{ registration.lwM2mVersion }}
<br />
Expand All @@ -31,6 +35,15 @@
</template>
Communication over DTLS
</v-tooltip>
<!-- secure icon -->
<v-tooltip :left="tooltipleft" :bottom="tooltipbottom">
<template v-slot:activator="{ on }">
<v-icon v-on="on" class="pr-2" :small="small" v-visible="registration.sleeping">
mdi-sleep
</v-icon>
</template>
Device using Queue mode is absent
</v-tooltip>
</span>
</template>
<script>
Expand All @@ -41,10 +54,5 @@ export default {
tooltipleft: Boolean,
tooltipbottom: Boolean,
},
computed: {
unsecure() {
return !this.registration.secure;
},
},
};
</script>
3 changes: 3 additions & 0 deletions leshan-server-demo/webapp2/src/views/Client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 8 additions & 1 deletion leshan-server-demo/webapp2/src/views/Clients.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{{ new Date(item.lastUpdate) | moment("MMM D, h:mm:ss A") }}
</template>
<template v-slot:item.infos="{ item }">
<client-info :registration="item" tooltipleft/>
<client-info :registration="item" tooltipleft />
</template>
</v-data-table>
</template>
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit 63c169e

Please sign in to comment.