/// <summary>
 /// called when receive from the other peer offline message
 /// </summary>
 /// <param name="compactPresenceInfo">contain the presence information of the peer that send the message</param>
 void IAnnouncementBusinessLogic.OnOfflineAnnouncementReceived(CompactPresenceInfo compactPresenceInfo)
 {
     if (compactPresenceInfo is MyCompactPresenceInfo)
     {
         var info    = compactPresenceInfo as MyCompactPresenceInfo;
         var removed = false;
         MyUserUpdateState state;
         lock (syncLock)
         {
             if (MyStateDictionary.TryGetValue(info.CorrelateKey, out state))
             {
                 removed = MyStateDictionary.Remove(info.CorrelateKey);
             }
         }
         if (removed)
         {
             LogManager.GetCurrentClassLogger().Debug("peer with key: {0} and name: {1} go offline",
                                                      info.CorrelateKey, state.Name);
         }
         else
         {
             LogManager.GetCurrentClassLogger().Debug("peer with key: {0} was not found !",
                                                      info.CorrelateKey);
         }
     }
 }
        /// <summary>
        /// called when receive from the other peer online message
        /// </summary>
        /// <param name="fullPresenceInfo">contain the presence information of the peer that send the online message</param>
        void IAnnouncementBusinessLogic.OnOnlineAnnouncementReceived(FullPresenceInfo fullPresenceInfo)
        {
            if (!(fullPresenceInfo is MyFullPresenceInfo))
            {
                return;
            }

            var info = fullPresenceInfo as MyFullPresenceInfo;

            lock (syncLock)
            {
                MyUserUpdateState myUserUpdateState;
                if (!MyStateDictionary.TryGetValue(info.CorrelateKey, out myUserUpdateState))
                {
                    myUserUpdateState = new MyUserUpdateState
                    {
                        FullPresenceInfo = info
                    };
                    MyStateDictionary.Add(info.CorrelateKey, myUserUpdateState);
                }
                else
                {
                    MyStateDictionary[info.CorrelateKey].FullPresenceInfo = info;
                }
            }
        }
 private void UpdateState(Dictionary <Guid, MyUserUpdateState> myUserUpdateStates)
 {
     lock (syncLock)
     {
         foreach (var kvp in myUserUpdateStates)
         {
             MyUserUpdateState value;
             if (MyStateDictionary.TryGetValue(kvp.Key, out value))
             {
                 if (value.IsOwnPeerData)
                 {
                     continue;
                 }
             }
             MyStateDictionary[kvp.Key] = kvp.Value;
         }
     }
 }