@@ -5,50 +5,50 @@ import 'package:torrent_task/src/task.dart';
55import 'package:torrent_task/src/utils.dart' ;
66
77Future <void > main () async {
8- var model = await Torrent .parse ('example/test8.torrent' );
9- // 不去获取peers
10- model.announces.clear ();
11- var task = TorrentTask .newTask (model, 'g:/bttest5/' );
12- Timer timer;
13- Timer timer1;
14- // task.addPeer(Uri(host:'127.0.0.1'));
15- task.onFileComplete ((filepath) {
16- print ('$filepath downloaded complete' );
17- });
18-
19- task.onTaskComplete (() {
20- print ('Complete!' );
21- timer? .cancel ();
22- timer1? .cancel ();
23- task.stop ();
24- });
25- task.onStop (() async {
26- print ('Task Stopped' );
27- });
28- await task.start ();
8+ // var model = await Torrent.parse('example/test8.torrent');
9+ // // 不去获取peers
10+ // model.announces.clear();
11+ // var task = TorrentTask.newTask(model, 'g:/bttest5/');
12+ // Timer timer;
13+ // Timer timer1;
14+ // // task.addPeer(Uri(host:'127.0.0.1'));
15+ // task.onFileComplete((filepath) {
16+ // print('$filepath downloaded complete');
17+ // });
2918
30- timer = Timer .periodic (Duration (seconds: 2 ), (timer) {
31- try {
32- print (
33- 'Downloaed: ${task .downloaded / (1024 * 1024 )} mb , ${((task .downloaded / model .length ) * 100 ).toStringAsFixed (2 )}%' );
34- } finally {}
35- });
19+ // task.onTaskComplete(() {
20+ // print('Complete!');
21+ // timer?.cancel();
22+ // timer1?.cancel();
23+ // task.stop();
24+ // });
25+ // task.onStop(() async {
26+ // print('Task Stopped');
27+ // });
28+ // await task.start();
3629
37- timer = Timer .periodic (Duration (seconds: 10 ), (timer) async {
38- print (
39- 'download speed : ${(await task .downloadSpeed ) * 1000 / 1024 } , upload speed : ${task .uploadSpeed * 1000 / 1024 }' );
40- });
41- timer1 = Timer .periodic (Duration (seconds: randomInt (21 )), (timer) async {
42- task.pause ();
43- await Future .delayed (Duration (seconds: randomInt (121 )));
44- task.resume ();
45- });
30+ // timer = Timer.periodic(Duration(seconds: 2), (timer) {
31+ // try {
32+ // print(
33+ // 'Downloaed: ${task.downloaded / (1024 * 1024)} mb , ${((task.downloaded / model.length) * 100).toStringAsFixed(2)}%');
34+ // } finally {}
35+ // });
4636
47- // Timer(Duration(seconds: 20), () async {
37+ // timer = Timer.periodic(Duration(seconds: 10), (timer) async {
38+ // print(
39+ // 'download speed : ${(await task.downloadSpeed) * 1000 / 1024} , upload speed : ${task.uploadSpeed * 1000 / 1024}');
40+ // });
41+ // timer1 = Timer.periodic(Duration(seconds: randomInt(21)), (timer) async {
4842 // task.pause();
49- // await Future.delayed(Duration(seconds: 120 ));
43+ // await Future.delayed(Duration(seconds: randomInt(121) ));
5044 // task.resume();
5145 // });
52- // 自己下载自己
53- task.addPeer (Uri (host: '127.0.0.1' , port: 53191 ));
46+
47+ // // Timer(Duration(seconds: 20), () async {
48+ // // task.pause();
49+ // // await Future.delayed(Duration(seconds: 120));
50+ // // task.resume();
51+ // // });
52+ // // 自己下载自己
53+ // task.addPeer(Uri(host: '127.0.0.1', port: 53191));
5454}
0 commit comments