public MySynchronizationBusinessLogic(Guid id, MyUserUpdateState userUpdateState) { this.id = id; this.userUpdateState = userUpdateState; syncLock = new object(); MyStateDictionary = new ObservableDictionary <Guid, MyUserUpdateState>(Dispatcher.CurrentDispatcher); }
/// <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; } } }
public MainWindow() { InitializeComponent(); ProcessId = Process.GetCurrentProcess().Id; UserState = new MyUserUpdateState { IsOwnPeerData = true, Name = string.Format("Peer {0}-{1}", Environment.MachineName, ProcessId), Data = string.Format("{0}-{1}", ProcessId, Environment.TickCount) }; id = Guid.NewGuid(); MySynchronizationBusinessLogic = new MySynchronizationBusinessLogic(id, UserState); CreateSyncManager(); DataContext = this; }