Skip to content

Commit 684df09

Browse files
committed
Merge branch 'develop'
2 parents e4306dc + a14996d commit 684df09

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<modelVersion>4.0.0</modelVersion>
1717
<artifactId>mqtt-client</artifactId>
18-
<version>0.1.10</version>
18+
<version>0.1.11</version>
1919
<name>MqttClient</name>
2020
<packaging>jar</packaging>
2121

src/main/java/info/unterrainer/commons/mqttclient/MqttSubscriptionManager.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,19 @@ public void updateDifferentialSubscriptionsOnClient() {
1919
Map<U, T> oldMap = getOldMap();
2020
Map<U, T> newMap = getCurrentMap();
2121
SetIntersection<U> intersection = SetIntersection.of(oldMap.keySet(), newMap.keySet());
22+
// Deleted subscriptions.
2223
for (U id : intersection.getDelete())
2324
client.unsubscribe(oldMap.get(id).getTopic());
25+
// Changes in existing subscriptions.
26+
for (U id : intersection.getLeave()) {
27+
T oldSub = oldMap.get(id);
28+
T newSub = newMap.get(id);
29+
if (!oldSub.getTopic().equals(newSub.getTopic()) || oldSub.getType() != newSub.getType()) {
30+
client.unsubscribe(oldSub.getTopic());
31+
client.subscribe(newSub.getTopic(), newSub.getType(), newSub.getSetter());
32+
}
33+
}
34+
// New subscriptions.
2435
for (U id : intersection.getCreate()) {
2536
T subscription = newMap.get(id);
2637
client.subscribe(subscription.getTopic(), subscription.getType(), subscription.getSetter());

0 commit comments

Comments
 (0)