public TrackerTestRig() { Tracker = new MonoTorrent.Tracker.Tracker(); Listener = new CustomListener(); Tracker.RegisterListener(Listener); GenerateTrackables(); GeneratePeers(); }
public void Setup() { listener = new MonoTorrent.Tracker.Listeners.HttpListener(uri.OriginalString); listener.Start(); server = new MonoTorrent.Tracker.Tracker(); server.RegisterListener(listener); listener.Start(); //tracker = new MonoTorrent.Client.Tracker.HTTPTracker(uri); }
public Tracker(string hostIpAddress, int port, string torrentFolder) { torrentTrackables = new Dictionary <string, ITrackable>(); realTracker = new MonoTorrent.Tracker.Tracker { AllowUnregisteredTorrents = true, AnnounceInterval = TimeSpan.FromHours(1), MinAnnounceInterval = TimeSpan.FromMinutes(10) }; //var listenPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse(hostIpAddress), port); //listener = new HttpListener(listenPoint); var endPoint = string.Format("http://{0}:{1}/announce/", hostIpAddress, port); listener = new HttpListener(endPoint); realTracker.RegisterListener(listener); this.watcher = new TorrentFolderWatcher(Path.GetFullPath(torrentFolder), "*.torrent"); this.watcher.TorrentFound += delegate(object sender, TorrentWatcherEventArgs e) { try { // hack System.Threading.Thread.Sleep(500); this.AddATorrent(e.TorrentPath); } catch (Exception ex) { if (ex.InnerException != null) { _log.Error("Error loading torrent from disk: " + ex.ToString() + " \n InnerException: " + ex.InnerException.ToString()); } else { _log.Error("Error loading torrent from disk: " + ex.ToString()); } Debug.WriteLine("Error loading torrent from disk: {0}", ex.Message); Debug.WriteLine("Stacktrace: {0}", ex.ToString()); } }; }