Skip to content

Commit

Permalink
Resolve issue with QOS downgrades.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
butlermatt committed Aug 12, 2020
1 parent 0b0e2ba commit a7298a5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
22 changes: 6 additions & 16 deletions lib/src/requester/request/subscribe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions lib/src/responder/response/subscribe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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/"
Expand Down

0 comments on commit a7298a5

Please sign in to comment.