Skip to content

Commit

Permalink
Fix a concurrent modification error during reconnection (#44) (#45)
Browse files Browse the repository at this point in the history
Co-authored-by: Tameem Rafay <[email protected]>
  • Loading branch information
Yoann-Abbes and rafay-tariq authored Oct 22, 2020
1 parent f89ba57 commit 9a48406
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/src/controllers/realtime.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ class RealTimeController extends KuzzleController {
_currentSubscriptions[channel] = item;
_subscriptionsCache[channel] = item;
} else {
_currentSubscriptions[channel].add(subscription);
_subscriptionsCache[channel].add(subscription);
if (!_currentSubscriptions[channel].contains(subscription)) {
_currentSubscriptions[channel].add(subscription);
}
if (!_subscriptionsCache[channel].contains(subscription)) {
_subscriptionsCache[channel].add(subscription);
}
}
_rooms[roomId] = channel;

Expand All @@ -156,7 +160,9 @@ class RealTimeController extends KuzzleController {

void _renewSubscribe() async {
for (final subs in _subscriptionsCache.values) {
for (final sub in subs) {
final List<Subscription> _localSubs = List<Subscription>.from(subs);
subs.clear();
for (final sub in _localSubs) {
await subscribe(
sub.index,
sub.collection,
Expand Down

0 comments on commit 9a48406

Please sign in to comment.