コード例 #1
0
 public void AddFriend(FriendRequest fr)
 {
     for (int i = 0; i < Config.Instance.NumberOfReplicas; i++)
     {
         string addr;
         lock (indexLock)
         {
             addr = replicas[(serverAddressToCall + i) % Config.Instance.NumberOfReplicas];
         }
         IClientServices obj = (IClientServices)Activator.GetObject(typeof(IClientServices), addr + "/ClientServices");
         if (obj != null)
         {
             try
             {
                 obj.AcceptFriendRequest(fr);
                 return;
             }
             catch (IOException) { }
             catch (SocketException) { }
         }
     }
     throw new ServiceUnavailableException("Unable to contact any server.");
 }