Browse Source

delete useless timer codes

melon 2 years ago
parent
commit
719696c7e2
1 changed files with 3 additions and 23 deletions
  1. 3 23
      lib/data_channel/channel.dart

+ 3 - 23
lib/data_channel/channel.dart

@@ -45,29 +45,9 @@ abstract class VidDataChannel {
     if (_initialized) return true;
 
     try {
-      final completer = Completer<bool>();
-      final timer = Timer(
-        Duration(milliseconds: timeout),
-        () {
-          if (!completer.isCompleted) {
-            completer.complete(_initialized);
-          }
-          if (!_initialized) {
-            source?.close();
-          }
-        },
-      );
-      _innerLoad(timeout).then((value) {
-        _initialized = true;
-        if (timer.isActive) {
-          timer.cancel();
-        }
-        completer.complete(true);
-      });
-      return completer.future;
-    } catch (e) {
-      return false;
-    }
+      _initialized = await _innerLoad(timeout);
+    } catch (e) {}
+    return _initialized;
   }
 
   /// 分发下载进度回调