2013-10-17 4 views
0

을 사용하여 새로 만든 토렌트에서 파일을 다운로드 할 수 없습니다. 다음 코드를 사용하여 monotorrent 솔루션으로 토런트를 작성했습니다. 그러나 참조는 "RawTrackerTier"에 대해 빠져 있습니다. 코드 줄을 주석으로 작성했지만 토렌트에서 파일을 다운로드 할 수없는 경우 토런트를 만들 수 있습니다. 누락 된 참조 또는 솔루션의 다른 문제로 인해 발생합니까? 그렇다면 누구나 누락 된 참조를 제공 할 수 있습니까? 도와주세요!monotorrent

public void CreateTorrent(string path, string savePath) 
{ 
    // The class used for creating the torrent 
    TorrentCreator c = new TorrentCreator(); 

    // Add one tier which contains two trackers 
    RawTrackerTier tier = new RawTrackerTier(); // MISSING REFERENCE HERE 
    tier.Add("http://localhost/announce"); 

    c.Announces.Add(tier); 
    c.Comment = "This is the comment"; 
    c.CreatedBy = "Doug using " + VersionInfo.ClientVersion; 
    c.Publisher = "www.aaronsen.com"; 

    // Set the torrent as private so it will not use DHT or peer exchange 
    // Generally you will not want to set this. 
    c.Private = true; 

    // Every time a piece has been hashed, this event will fire. It is an 
    // asynchronous event, so you have to handle threading yourself. 
    c.Hashed += delegate(object o, TorrentCreatorEventArgs e) 
    { 
     Console.WriteLine("Current File is {0}% hashed", e.FileCompletion); 
     Console.WriteLine("Overall {0}% hashed", e.OverallCompletion); 
     Console.WriteLine("Total data to hash: {0}", e.OverallSize); 
    }; 

    // ITorrentFileSource can be implemented to provide the TorrentCreator 
    // with a list of files which will be added to the torrent metadata. 
    // The default implementation takes a path to a single file or a path 
    // to a directory. If the path is a directory, all files will be 
    // recursively added 

    ITorrentFileSource fileSource = new TorrentFileSource(path); 

    // Create the torrent file and save it directly to the specified path 
    // Different overloads of 'Create' can be used to save the data to a Stream 
    // or just return it as a BEncodedDictionary (its native format) so it can be 
    // processed in memory 
    c.Create(fileSource, savePath); 
} 

답변

0

nuget에 MonoTorrent의 버전 (버전 0.9.0)은 아주 오래 만 단일 계층 지원을 발표있는 것 같습니다. 해당 버전을 사용하는 경우,이 코드가 작동 할 수 있습니다 :

// The class used for creating the torrent 
TorrentCreator c = new TorrentCreator(); 

// Add tracker(s) 
c.Announces.Add("http://localhost/announce"); 

monotorrent의 최신 버전 (코드 만) github에서 확인할 수있다. 라이브러리 소스를 다운로드하여 직접 제작할 수 있습니다.