Example #1
0
 public void SearchMusic(IPeer p, string musicName, int ttl)
 {
     SetOutputMsg("Request from " + p.GetPeerURI());
     SetOutputMsg("Searching for music " + musicName);
     if (MyMusics.Contains(musicName))
     {
         p.MarkAsFoundMusic(this, musicName);
         return;
     }
     if (_musicsOnKnownPeers.ContainsKey(musicName))
     {
         IPeer peer = _musicsOnKnownPeers[musicName];
         try
         {
             p.MarkAsFoundMusic(peer, musicName);
         }
         catch (Exception)
         {
             SetOutputMsg("Peer to respond not found!!!");
         }
         return;
     }
     if (--ttl == 0)
     {
         return;
     }
     foreach (IPeer peer in MyKnownPeers)
     {
         try
         {
             peer.SearchMusic(p, musicName, ttl);
         }
         catch (Exception)
         {
             MyKnownPeers.Remove(peer);
         }
     }
 }