/// <summary>
    /// Constructs DhtTracker using the given DhtSerivceProxy instance.
    /// </summary>
    /// <param name="dhtProxy"></param>
    public DictionaryServiceTracker(DictionaryServiceProxy dhtProxy, string listeningPrefix) {
      _dictListener = new DictionaryServiceTrackerListener(dhtProxy);
      ListeningPrefix = listeningPrefix;
      _httpListener = new HttpListener(ListeningPrefix);
      Logger.WriteLineIf(LogLevel.Info, _log_props, string.Format(
        "DictionaryServiceTracker starting at: {0}", ListeningPrefix));
      // Subscribe the HttpListener events to do our nifty stuff.
      _httpListener.AnnounceReceived += this.OnAnnounceReceived;
      _httpListener.ScrapeReceived += this.OnScrapeReceived;

      _tracker = new Tracker();

      // This also subscribes the same above 2 events but does this AFTER them, 
      // so HttpListener invokes DHT operations first.
      _tracker.RegisterListener(_httpListener);
      // And... the events from DHT
      _tracker.RegisterListener(_dictListener);
    }
Exemplo n.º 2
0
        /// <summary>
        /// Constructs DhtTracker using the given DhtSerivceProxy instance.
        /// </summary>
        /// <param name="dhtProxy"></param>
        public DictionaryServiceTracker(DictionaryServiceProxy dhtProxy, string listeningPrefix)
        {
            _dictListener = new DictionaryServiceTrackerListener(dhtProxy);
              ListeningPrefix = listeningPrefix;
              _httpListener = new HttpListener(ListeningPrefix);
              Logger.WriteLineIf(LogLevel.Info, _log_props, string.Format(
            "DictionaryServiceTracker starting at: {0}", ListeningPrefix));
              // Subscribe the HttpListener events to do our nifty stuff.
              _httpListener.AnnounceReceived += this.OnAnnounceReceived;
              _httpListener.ScrapeReceived += this.OnScrapeReceived;

              _tracker = new Tracker();

              // This also subscribes the same above 2 events but does this AFTER them,
              // so HttpListener invokes DHT operations first.
              _tracker.RegisterListener(_httpListener);
              // And... the events from DHT
              _tracker.RegisterListener(_dictListener);
        }