Return to site

About torrent client sample.

My English skill is poor. If I make mistakes in my English,please pardon me.
I'm coding a torrent library for dart developers which name is hetimatorrent.
Bep3 spec function is works for me now
import 'dart:html';
import 'dart:async';
import 'package:chrome/chrome_app.dart' as chrome;
import 'package:hetimatorrent/hetimatorrent.dart';
import 'package:hetimanet/hetimanet_chrome.dart';
import 'package:hetimacore/hetimacore_cl.dart';
import 'package:hetimacore/hetimacore.dart';
void main() {
Future startDownload(MouseEvent event) {
  TorrentEngine engine;
  List<File> selectedFile = (querySelector("#inputFile") as InputElement).files;
  bool isStop = false;
  return TorrentFile.createFromTorrentFile(new HetimaFileToBuilder(new HetimaDataBlob(selectedFile[0]))).then((TorrentFile torrentFile) {
    return TorrentEngine.createTorrentEngine(new HetiSocketBuilderChrome(), torrentFile, new HetimaDataFS("save.dat")).then((TorrentEngine engine) {
      engine.start(usePortMap: true);
      engine.onProgress.listen((TorrentEngineProgress progress) {
        if (progress.downloadSize >= progress.fileSize && isStop == false) {
          isStop = true;
          new Future.delayed(new Duration(minutes: 5)).then((_) {
            engine.stop().catchError((e) {});
This code could download files from torrent p2p network at 20-30 line code.
check following code.
- this sample
- library page
Sorry, now this api support only on chrome socket api and pre-Alpha version.
Thank you.
All Posts

Almost done…

We just sent you an email. Please click the link in the email to confirm your subscription!

OKSubscriptions powered by Strikingly