From 47b9329c67ce35524b819e192454d0dee8d01d86 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Sun, 6 Mar 2022 14:10:18 +0900 Subject: [PATCH] remove unused code --- lib/src/core/engine.dart | 7 ------ lib/src/core/room.dart | 2 +- lib/src/managers/delay.dart | 45 ------------------------------------- 3 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 lib/src/managers/delay.dart diff --git a/lib/src/core/engine.dart b/lib/src/core/engine.dart index 8d2eaa4..9d305ea 100644 --- a/lib/src/core/engine.dart +++ b/lib/src/core/engine.dart @@ -13,7 +13,6 @@ import '../extensions.dart'; import '../internal/events.dart'; import '../internal/types.dart'; import '../logger.dart'; -import '../managers/delay.dart'; import '../managers/event.dart'; import '../options.dart'; import '../proto/livekit_models.pb.dart' as lk_models; @@ -71,8 +70,6 @@ class Engine extends Disposable with EventsEmittable { late final _signalListener = signalClient.createListener(synchronized: true); - final delays = CancelableDelayManager(); - Engine({ SignalClient? signalClient, PeerConnectionCreate? peerConnectionCreate, @@ -90,7 +87,6 @@ class Engine extends Disposable with EventsEmittable { onDispose(() async { await cleanUp(); await events.dispose(); - await delays.dispose(); await _signalListener.dispose(); }); } @@ -141,9 +137,6 @@ class Engine extends Disposable with EventsEmittable { Future cleanUp() async { logger.fine('[${objectId}] cleanUp()'); - // cancel all ongoing delays - await delays.cancelAll(); - await publisher?.dispose(); publisher = null; diff --git a/lib/src/core/room.dart b/lib/src/core/room.dart index 65957ed..b592683 100644 --- a/lib/src/core/room.dart +++ b/lib/src/core/room.dart @@ -517,4 +517,4 @@ extension RoomDebugMethods on Room { serverLeave: serverLeave, ); } -} \ No newline at end of file +} diff --git a/lib/src/managers/delay.dart b/lib/src/managers/delay.dart deleted file mode 100644 index f5026d8..0000000 --- a/lib/src/managers/delay.dart +++ /dev/null @@ -1,45 +0,0 @@ -import 'package:async/async.dart'; - -import '../support/disposable.dart'; - -class CancelableDelayManager extends Disposable { - // - final _delays = >[]; - - CancelableDelayManager() { - onDispose(() async => await cancelAll()); - } - // delay but cancelable - Future waitFor( - Duration wait, { - Function? ifNotCancelled, - }) async { - final op = CancelableOperation.fromFuture( - Future.delayed(wait), - ); - _delays.add(op); - await op.valueOrCancellation(); - _delays.remove(op); - // if it was cancelled we probably don't want to execute it - if (!op.isCanceled) ifNotCancelled?.call(); - } - - // @override - // Future dispose() async { - // final didDispose = await super.dispose(); - // if (didDispose) { - // await cancelAll(); - // } - // return didDispose; - // } - - Future cancelAll() async { - // cancel all delays - if (_delays.isEmpty) return; - // make a copy so we don't mutate while iterating - final snapshot = List>.from(_delays); - for (final op in snapshot) { - await op.cancel(); - } - } -}