Skip to content

Commit

Permalink
Check channel before subscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
PlugFox committed Aug 3, 2023
1 parent 30f7662 commit 0f8a39d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/src/client/centrifuge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,17 @@ base mixin CentrifugeClientSubscriptionMixin
CentrifugeClientSubscription newSubscription(
String channel, [
CentrifugeSubscriptionConfig? config,
]) =>
_clientSubscriptionManager.newSubscription(channel, config);
]) {
final sub = _clientSubscriptionManager[channel] ??
_serverSubscriptionManager[channel];
if (sub != null) {
throw CentrifugeSubscriptionException(
channel: channel,
message: 'Subscription already exists',
);
}
return _clientSubscriptionManager.newSubscription(channel, config);
}

@override
Map<String, CentrifugeClientSubscription> get subscriptions =>
Expand Down

0 comments on commit 0f8a39d

Please sign in to comment.