Ejemplo n.º 1
0
        private void ConnectScrapeCallback(IAsyncResult ar)
        {
            ConnectScrapeState scrapeState = (ConnectScrapeState)ar;

            try
            {
                if (scrapeState.SavedException != null)
                {
                    FailureMessage = scrapeState.SavedException.Message;
                    amConnecting   = false;
                    DoScrapeComplete(false, scrapeState.AsyncState);
                    return;
                }
                if (!ConnectCallback(ar))//bad transaction id
                {
                    DoScrapeComplete(false, scrapeState.AsyncState);
                    return;
                }
                DoScrape(scrapeState.Parameters, scrapeState.AsyncState);
            }
            catch
            {
                DoScrapeComplete(false, scrapeState.AsyncState);
            }
        }
Ejemplo n.º 2
0
        private void DoScrape(ScrapeParameters parameters, object state)
        {
            //strange because here only one infohash???
            //or get all torrent infohash so loop on torrents of client engine
            List <byte[]> infohashs = new List <byte[]>(1);

            infohashs.Add(parameters.InfoHash.Hash);
            ConnectScrapeState scrapeState = new ConnectScrapeState(parameters, ScrapeCallback, state);

            scrapeState.Message = new ScrapeMessage(DateTime.Now.GetHashCode(), connectionId, infohashs);
            try
            {
                SendAndReceive(scrapeState);
            }
            catch (SocketException)
            {
                DoScrapeComplete(false, state);
            }
        }
Ejemplo n.º 3
0
 private void ScrapeCallback(IAsyncResult ar)
 {
     try
     {
         ConnectScrapeState scrapeState = (ConnectScrapeState)ar;
         if (scrapeState.SavedException != null)
         {
             FailureMessage = scrapeState.SavedException.Message;
             DoScrapeComplete(false, scrapeState.AsyncState);
             return;
         }
         UdpTrackerMessage rsp = Receive(scrapeState, scrapeState.Data);
         if (!(rsp is ScrapeResponseMessage))
         {
             DoScrapeComplete(false, scrapeState.AsyncState);
             return;
         }
         CompleteScrape(rsp, scrapeState.AsyncState);
     }
     catch
     {
         // Nothing to do i think
     }
 }
Ejemplo n.º 4
0
 private void DoScrape(ScrapeParameters parameters, object state)
 {
     //strange because here only one infohash???
     //or get all torrent infohash so loop on torrents of client engine
     var infohashs = new List<byte[]>(1);
     infohashs.Add(parameters.InfoHash.Hash);
     var scrapeState = new ConnectScrapeState(parameters, ScrapeCallback, state);
     scrapeState.Message = new ScrapeMessage(DateTime.Now.GetHashCode(), connectionId, infohashs);
     try
     {
         SendAndReceive(scrapeState);
     }
     catch (SocketException)
     {
         DoScrapeComplete(false, state);
     }
 }