From a7298a56a6e07ac005a6208e31507497a4b5c771 Mon Sep 17 00:00:00 2001 From: Matthew Butler Date: Wed, 12 Aug 2020 16:30:06 -0300 Subject: [PATCH] Resolve issue with QOS downgrades. Ensure QOS downgrade requests are forwarded properly. Always verify the max QOS value after a QOS update. This should ensure that dataflow and other requesters will update their subscriptions when changed. --- CHANGELOG.md | 4 ++++ lib/src/requester/request/subscribe.dart | 22 ++++++---------------- lib/src/responder/response/subscribe.dart | 5 ++--- pubspec.yaml | 2 +- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbbe7dca..cacd6c64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # ChangeLog +* v1.0.5 - Ensure that QOS downgrades are propagated. +* v1.0.4+1 - Map logger names to match DSA log levels. +* v1.0.4 - Forward any errors generated by a `list` request to the requester. +* v1.0.3 - Update packages to use hosted rather than repository sources. * v1.0.2 - Properly forward QOS level changes to nodes when changing an existing subscription QOS level. * v1.0.1 - Fix bug in list subscriptions for nodes which have been removed and recreated throughout subscription's life. This may have prevented list subscriptions from updating full entries. diff --git a/lib/src/requester/request/subscribe.dart b/lib/src/requester/request/subscribe.dart index 49732744..3049ee87 100644 --- a/lib/src/requester/request/subscribe.dart +++ b/lib/src/requester/request/subscribe.dart @@ -265,23 +265,13 @@ class ReqSubscribeController { } void listen(callback(ValueUpdate update), int qos) { - if (qos < 0 || qos > 3) { - qos = 0; - } - bool qosChanged = false; + qos = qos.clamp(0, 3); - if (callbacks.containsKey(callback)) { - callbacks[callback] = qos; - qosChanged = updateQos(); - } else { - callbacks[callback] = qos; - if (qos > currentQos) { - qosChanged = true; - currentQos = qos; - } - if (_lastUpdate != null) { - callback(_lastUpdate); - } + callbacks[callback] = qos; + bool qosChanged = updateQos(); + + if (_lastUpdate != null) { + callback(_lastUpdate); } if (qosChanged) { diff --git a/lib/src/responder/response/subscribe.dart b/lib/src/responder/response/subscribe.dart index 9a1cc057..54b6eb15 100644 --- a/lib/src/responder/response/subscribe.dart +++ b/lib/src/responder/response/subscribe.dart @@ -207,9 +207,8 @@ class RespSubscribeController { ISubscriptionNodeStorage _storage; void set qosLevel(int v) { - if (v < 0 || v > 3) v = 0; - if (_qosLevel == v) - return; + v = v.clamp(0, 3); + if (_qosLevel == v) return; _qosLevel = v; if (waitingValues == null && _qosLevel > 0) { diff --git a/pubspec.yaml b/pubspec.yaml index 0ba19752..721cb34f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: dslink -version: 1.0.4+1 +version: 1.0.5 description: "DSA IoT Platform - DSLink SDK for Dart" homepage: "http://iot-dsa.org" documentation: "https://iot-dsa.github.io/docs/sdks/dart/"