internal static IAsyncResult BeginScrape(this Tracker tracker, IScrapeRequest request, AsyncCallback callback, object state)
        {
            AsyncScrapeParameters parameters = new AsyncScrapeParameters(request, callback, state);
            ThreadPool.QueueUserWorkItem(new WaitCallback(Scrape), parameters);

            return parameters.Result;
        }
        public IScrapeTransport CreateTransport(IScrapeRequest request)
        {
            UdpScrapeRequestPacket requestPacket = new UdpScrapeRequestPacket();

            if (request is IScrapeRequest2)
            {
                IScrapeRequest2 request2 = (IScrapeRequest2)request;

                if (request2.InfoHashList.Count > UdpScrapeTransport.MultiScrapeRange)
                    throw new ArgumentOutOfRangeException("request", String.Format("UdpTransport supports IScrapeRequest2 with up to {0} items using MTU=1500 - {2} items specified", UdpScrapeTransport.MultiScrapeRange, 1500, request2.InfoHashList.Count));

                requestPacket.info_hash = request2.InfoHashList.ToArray();
            }
            else
            {
                requestPacket.info_hash = new InfoHash[1] { request.InfoHash };
            }

            UdpScrapeTransport transport =  new UdpScrapeTransport(Tracker.Ip, Tracker.AnnounceUrl.Port, 60, requestPacket);
            transport.Request = request;

            return transport;
        }
        public IScrapeTransport CreateTransport(IScrapeRequest request)
        {
            NameValueCollection query = new NameValueCollection(baseScrapeQuery);

            if (request.InfoHash != null)
                query.Add("info_hash", HttpUtility.UrlEncode(request.InfoHash));

            if (request is IScrapeRequest2)
            {
                IScrapeRequest2 request2 = (IScrapeRequest2)request;

                foreach(InfoHash infoHash in request2.InfoHashList)
                    query.Add("info_hash", HttpUtility.UrlEncode(infoHash));
            }

            UriBuilder requestUriBuilder = new UriBuilder(baseScrapeUri);
            requestUriBuilder.Query = BuildQueryString(query, false);

            HttpScrapeTransport transport = new HttpScrapeTransport(requestUriBuilder.Uri);
            transport.Request = request;

            return transport;
        }
 public AsyncScrapeParameters(IScrapeRequest request, AsyncCallback callback, object state)
 {
     Request = request;
     Result = new AsyncScrapeResult(state);
     Callback = callback;
 }