diff --git a/lib/src/spinify_impl.dart b/lib/src/spinify_impl.dart index ac5e6ce..fc835b2 100644 --- a/lib/src/spinify_impl.dart +++ b/lib/src/spinify_impl.dart @@ -387,8 +387,6 @@ base mixin SpinifySubscriptionMixin on SpinifyBase, SpinifyCommandMixin { ), stackTrace, ); - } finally { - subFromRegistry?.close().ignore(); } } diff --git a/lib/src/subscription_impl.dart b/lib/src/subscription_impl.dart index db76db4..e177063 100644 --- a/lib/src/subscription_impl.dart +++ b/lib/src/subscription_impl.dart @@ -41,12 +41,15 @@ final class SpinifyClientSubscriptionImpl implements SpinifyClientSubscription { return target; } + // TODO(plugfox): set from client @override SpinifyStreamPosition? get since => throw UnimplementedError(); + // TODO(plugfox): set from client @override SpinifySubscriptionState get state => throw UnimplementedError(); + // TODO(plugfox): get from client @override SpinifySubscriptionStateStream get states => throw UnimplementedError(); @@ -95,6 +98,73 @@ final class SpinifyClientSubscriptionImpl implements SpinifyClientSubscription { ]) { throw UnimplementedError(); } +} + +@internal +final class SpinifyServerSubscriptionImpl implements SpinifyServerSubscription { + SpinifyServerSubscriptionImpl({ + required ISpinify client, + required this.channel, + }) : _clientWR = WeakReference(client); + + @override + final String channel; + + /// Spinify client weak reference. + final WeakReference _clientWR; + ISpinify get _client { + final target = _clientWR.target; + if (target == null) { + throw SpinifySubscriptionException( + channel: channel, + message: 'Client is closed', + ); + } + return target; + } + + // TODO(plugfox): set from client + @override + SpinifyStreamPosition? get since => throw UnimplementedError(); + + // TODO(plugfox): set from client + @override + SpinifySubscriptionState get state => throw UnimplementedError(); - Future close() async {} + // TODO(plugfox): get from client + @override + SpinifySubscriptionStateStream get states => throw UnimplementedError(); + + @override + ChannelEvents get stream => + _client.stream.filter(channel: channel); + + @override + Future history({ + int? limit, + SpinifyStreamPosition? since, + bool? reverse, + }) { + throw UnimplementedError(); + } + + @override + Future presence() { + throw UnimplementedError(); + } + + @override + Future presenceStats() { + throw UnimplementedError(); + } + + @override + Future publish(List data) { + throw UnimplementedError(); + } + + @override + FutureOr ready() { + throw UnimplementedError(); + } }