Commit bae6511936f8d428dcd34790b0189e3731c81424
1 parent
43f54d96
Fix not upgrading QoS of existing subscription
Showing
1 changed file
with
7 additions
and
1 deletions
subscriptionstore.cpp
| ... | ... | @@ -46,10 +46,16 @@ void SubscriptionNode::addSubscriber(const std::shared_ptr<Session> &subscriber, |
| 46 | 46 | |
| 47 | 47 | // I'll have to decide whether to keep the subscriber as a vector. Vectors are |
| 48 | 48 | // fast, and relatively, you don't often add subscribers. |
| 49 | - if (std::find(subscribers.begin(), subscribers.end(), sub) == subscribers.end()) | |
| 49 | + auto subscriber_it = std::find(subscribers.begin(), subscribers.end(), sub); | |
| 50 | + if (subscriber_it == subscribers.end()) | |
| 50 | 51 | { |
| 51 | 52 | subscribers.push_back(sub); |
| 52 | 53 | } |
| 54 | + else | |
| 55 | + { | |
| 56 | + Subscription &existingSub = *subscriber_it; | |
| 57 | + existingSub = sub; | |
| 58 | + } | |
| 53 | 59 | } |
| 54 | 60 | |
| 55 | 61 | void SubscriptionNode::removeSubscriber(const std::shared_ptr<Session> &subscriber) | ... | ... |