Skip to content

Commit

Permalink
Refactor imports to use 'channel_event.dart' instead of 'channel_push…
Browse files Browse the repository at this point in the history
….dart'
  • Loading branch information
PlugFox committed Jun 11, 2024
1 parent e0cfde5 commit 53ae274
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
2 changes: 0 additions & 2 deletions lib/src/spinify_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,6 @@ base mixin SpinifySubscriptionMixin on SpinifyBase, SpinifyCommandMixin {
),
stackTrace,
);
} finally {
subFromRegistry?.close().ignore();
}
}

Expand Down
72 changes: 71 additions & 1 deletion lib/src/subscription_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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<ISpinify>(client);

@override
final String channel;

/// Spinify client weak reference.
final WeakReference<ISpinify> _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<void> close() async {}
// TODO(plugfox): get from client
@override
SpinifySubscriptionStateStream get states => throw UnimplementedError();

@override
ChannelEvents<SpinifyChannelEvent> get stream =>
_client.stream.filter(channel: channel);

@override
Future<SpinifyHistory> history({
int? limit,
SpinifyStreamPosition? since,
bool? reverse,
}) {
throw UnimplementedError();
}

@override
Future<SpinifyPresence> presence() {
throw UnimplementedError();
}

@override
Future<SpinifyPresenceStats> presenceStats() {
throw UnimplementedError();
}

@override
Future<void> publish(List<int> data) {
throw UnimplementedError();
}

@override
FutureOr<void> ready() {
throw UnimplementedError();
}
}

0 comments on commit 53ae274

Please sign in to comment.