public virtual BEncodedDictionary Handle(NameValueCollection collection, IPAddress remoteAddress, bool isScrape) { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } if (remoteAddress == null) { throw new ArgumentNullException(nameof(remoteAddress)); } TrackerRequest request; if (isScrape) { request = new TrackerScrapeRequest(collection, remoteAddress); } else { request = new AnnounceRequest(collection, remoteAddress); } // If the parameters are invalid, the failure reason will be added to the response dictionary if (!request.IsValid) { return(request.Response); } // Fire the necessary event so the request will be handled and response filled in if (isScrape) { RaiseScrapeReceived((TrackerScrapeRequest)request); } else { RaiseAnnounceReceived((AnnounceRequest)request); } // Return the response now that the connection has been handled correctly. return(request.Response); }
protected void RaiseScrapeReceived(TrackerScrapeRequest e) { ScrapeReceived?.Invoke(this, e); }