Beispiel #1
0
 public void AddObserver(FriendObserver observer)
 {
     if (observer == null)
     {
         return;
     }
     Observers.Add(observer);
 }
Beispiel #2
0
        public void RemoveObserver(FriendObserver observer)
        {
            if (observer == null)
            {
                return;
            }

            Observers.Remove(observer);
        }
Beispiel #3
0
 public void AddParticularFriendObserver(Guid buddy_id, FriendObserver observer)
 {
     if (buddy_id != Guid.Empty && observer != null)
     {
         if (ParticularFriendObserverMap.ContainsKey(buddy_id) == false)
         {
             ParticularFriendObserverMap[buddy_id] = new HashSet <FriendObserver>();
         }
         ParticularFriendObserverMap[buddy_id].Add(observer);
     }
 }
Beispiel #4
0
        public void RemoveParticularFriendObserver(Guid buddy_id, FriendObserver observer)
        {
            if (buddy_id == Guid.Empty || observer == null)
            {
                return;
            }

            if (ParticularFriendObserverMap.ContainsKey(buddy_id) == false)
            {
                return;
            }

            ParticularFriendObserverMap[buddy_id].Remove(observer);

            // purge empty sets from the map
            if (ParticularFriendObserverMap[buddy_id].Count == 0)
            {
                ParticularFriendObserverMap.Remove(buddy_id);
            }
        }