private void SendObjectSubscriptionNotifications(ObjectSubscription subscription) { CheckLocked(); RefreshSubscriptions(); SendJoinedSubscriptionNotifications(subscription); SendCreatedNotifications(subscription); SendUpdatedNotifications(subscription); SendJoinedAndUnjoinedNotifications(subscription); SendActivatedNotifications(subscription); SendDeactivatedNotifications(subscription); SendUnjoinedSubscriptionNotifications(subscription); subscription.PreviousObjects = subscription.Objects; subscription.Objects = new Dictionary <Guid, MockObject>(); if (subscription.Root?.IsDeleted ?? false && subscription.EndIfRootDeleted) { subscription.Callbacks.SubscriptionEnded?.Invoke(subscription.Uuid, $"Object Deleted: {subscription.Root.Uri(subscription.Version)}"); ObjectSubscriptionsByRequestUuid.Remove(subscription.Uuid); } subscription.LastNotificationTime = StoreLastWrite; subscription.SendHistoricalChanges = false; // Only send historical changes the first time. }
public bool SubscribeObjectNotifications(EtpVersion version, bool sendHistoricalChanges, DateTime historicalChangesStartTime, bool endIfRootDeleted, Guid sessionId, MockSubscriptionInfo subscriptionInfo, MockObjectCallbacks callbacks) { CheckLocked(); if (ObjectSubscriptionsByRequestUuid.ContainsKey(subscriptionInfo.RequestUuid)) { return(false); } MockObject root = null; var uri = subscriptionInfo.Context.Uri; if (uri.IsObjectUri) { root = GetObject(version, uri); if (root == null) { return(false); } } ObjectSubscriptionsByRequestUuid[subscriptionInfo.RequestUuid] = new ObjectSubscription { SessionId = sessionId, Version = version, Uuid = subscriptionInfo.RequestUuid, LastNotificationTime = sendHistoricalChanges ? historicalChangesStartTime : StoreLastWrite, SubscriptionInfo = subscriptionInfo, Callbacks = callbacks, Root = root, SendHistoricalChanges = sendHistoricalChanges, EndIfRootDeleted = endIfRootDeleted, }; return(true); }
public bool UnsubscribeObjectNotifications(Guid requestUuid) { CheckLocked(); return(ObjectSubscriptionsByRequestUuid.Remove(requestUuid)); }