Example #1
0
 public void RequestPeers(int count)
 {
     if (Status == PeerStatus.Connected)
     {
         var message = new RequestPeersMessage(count);
         if (ConnectionMode == ConnectionMode.Direct)
         {
             //проверка на дисконнект
             try
             {
                 Connection.SendObject(message.GetType().Name, message);
             }
             catch
             {
                 Status = PeerStatus.Disconnected;
                 Connect();
             }
         }
         else
         {
             tracker.SendMessageToPeer(message, this);
         }
         PeersRequestsCount++;
     }
     else
     {
         Connect();
     }
 }
Example #2
0
 public void RequestPeersFromTracker(int count)
 {
     if (Status == TrackerStatus.Connected)
     {
         var message = new RequestPeersMessage(count);
         try
         {
             Connection.SendObject(message.GetType().Name, message);
         }
         catch
         {
             Status = TrackerStatus.Disconnected;
             Connect();
         }
     }
     else
     {
         Connect();
     }
 }