/// <summary> /// Start downloading a search result /// ,also adds a queue entry /// </summary> /// <param name="result">the search result you want to download</param> public void StartDownload(SearchResults.SearchResult result) { if (result.IsHubResolved) {//TODO put this into queue class download_queue.AddSearchResult(result); result.Hub.SendConnectToMe(result.UserName); //signal download to hub to start it } else Console.WriteLine("Hub was not resolved from result hub address: " + result.HubAddress); }
/// <summary> /// Interpret a received search result /// (active and passive results can be handled with this method) /// this will automatically add sources to already existing download /// queue entries, these will not be shown in the search results /// TODO make this an option /// </summary> /// <param name="result">the result to be interpreted</param> private void InterpretReceivedSearchResult(SearchResults.SearchResult result) { //Console.WriteLine("Adding Result to SearchResults"); result.Hub = ResolveHub(result.HubAddress); if (result.Hub != null) //only add results for hubs still connected { if (result.HasTTH) {//only if a result has a tth it is considered a source for some queue entry Queue.QueueEntry entry = download_queue.FindQueueEntryByTTH(result.TTH); if (entry != null) {//this searchresult is also a source for a queue entry //,instead using of giving it back as result we add it to the source pool of the queue entry entry.AddSource(new Queue.QueueEntry.Source(result.UserName, result.Filename, result.Hub)); } //no queue entry found for this one just hand it over to SearchResults else search_results.AddResult(result); } else search_results.AddResult(result); } /* //Console.WriteLine("Adding Result to SearchResults"); result.Hub = ResolveHub(result.HubAddress); search_results.AddResult(result); */ }