Skip to content

Commit

Permalink
Add CentrifugeClientSubscriptionQueueMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
PlugFox committed Jul 25, 2023
1 parent 0950146 commit dd86a6b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
3 changes: 3 additions & 0 deletions lib/src/client/centrifuge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,13 @@ base mixin CentrifugeClientSubscriptionMixin
/// Mixin responsible for queue.
/// SHOULD BE LAST MIXIN.
/// {@nodoc}
@internal
base mixin CentrifugeQueueMixin on CentrifugeBase {
/// {@nodoc}
final CentrifugeEventQueue _eventQueue = CentrifugeEventQueue();

// TODO(plugfox): add all methods

@override
Future<void> connect(String url) =>
_eventQueue.push<void>('connect', () => super.connect(url));
Expand Down
32 changes: 26 additions & 6 deletions lib/src/subscription/client_subscription_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:async';
import 'package:centrifuge_dart/centrifuge.dart';
import 'package:centrifuge_dart/src/model/subscription_states_stream.dart';
import 'package:centrifuge_dart/src/transport/transport_interface.dart';
import 'package:centrifuge_dart/src/util/event_queue.dart';
import 'package:centrifuge_dart/src/util/logger.dart' as logger;
import 'package:meta/meta.dart';
import 'package:stack_trace/stack_trace.dart' as st;
Expand All @@ -14,19 +15,21 @@ final class CentrifugeClientSubscriptionImpl
extends CentrifugeClientSubscriptionBase
with
CentrifugeClientSubscriptionErrorsMixin,
CentrifugeClientSubscriptionSubscribeMixin {
CentrifugeClientSubscriptionSubscribeMixin,
CentrifugeClientSubscriptionQueueMixin {
/// {@nodoc}
CentrifugeClientSubscriptionImpl({
required super.channel,
required super.transportWeakRef,
CentrifugeSubscriptionConfig? config,
}) : super(config: config ?? const CentrifugeSubscriptionConfig.byDefault());

/* publish(data) - publish data to Subscription channel
history(options) - request Subscription channel history
presence() - request Subscription channel online presence information
presenceStats() - request Subscription channel online presence stats information (number of client connections and unique users in a channel).
*/
/*
publish(data) - publish data to Subscription channel
history(options) - request Subscription channel history
presence() - request Subscription channel online presence information
presenceStats() - request Subscription channel online presence stats information (number of client connections and unique users in a channel).
*/
}

/// {@nodoc}
Expand Down Expand Up @@ -231,3 +234,20 @@ base mixin CentrifugeClientSubscriptionSubscribeMixin
await _transport.close();
}
}

/// Mixin responsible for queue.
/// SHOULD BE LAST MIXIN.
/// {@nodoc}
@internal
base mixin CentrifugeClientSubscriptionQueueMixin
on CentrifugeClientSubscriptionBase {
/// {@nodoc}
final CentrifugeEventQueue _eventQueue = CentrifugeEventQueue();

// TODO(plugfox): add all methods

@override
Future<void> close() => _eventQueue
.push<void>('close', super.close)
.whenComplete(_eventQueue.close);
}

0 comments on commit dd86a6b

Please sign in to comment.