File tree Expand file tree Collapse file tree
src/main/java/info/unterrainer/commons/mqttclient Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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 ());
You can’t perform that action at this time.
0 commit comments