示例#1
0
        private void SendChannelSubscriptionNotifications(ChannelSubscription subscription)
        {
            CheckLocked();

            RefreshSubscriptions();

            SendJoinedSubscriptionNotifications(subscription);
            SendCreatedNotifications(subscription);
            SendUpdatedNotifications(subscription);
            SendActivatedNotifications(subscription);

            SendChannelDataNotifications(subscription);

            SendDeactivatedNotifications(subscription);
            SendUnjoinedSubscriptionNotifications(subscription);

            foreach (var @object in subscription.GetAllRemovedObjects())
            {
                subscription.ChannelScopeUuidByChannelUuid.Remove(@object.Uuid);
                subscription.ChannelSubscriptionsByChannelUuid.Remove(@object.Uuid);
                subscription.ChannelScopeUuidByChannelUuid.Remove(@object.Uuid);
            }

            subscription.PreviousObjects = subscription.Objects;
            subscription.Objects         = new Dictionary <Guid, MockObject>();

            subscription.LastNotificationTime = StoreLastWrite;
        }
示例#2
0
        private void SendChannelDataNotifications(ChannelSubscription subscription)
        {
            if (StoreLastWrite - subscription.LastSendTime < subscription.MaxMessageRate)
            {
                return;
            }

            var streamingInfos = subscription.ValidChannelIds.Values.Where(s => s.IsStarted && !s.Channel.IsDeleted && s.Channel is IMockGrowingObject);

            var dataItems = GetChannelData(subscription.Version, streamingInfos, subscription.MaxDataItems);

            if (dataItems.Count > 0)
            {
                subscription.Callbacks.DataAppended(subscription.Uuid, dataItems);
                subscription.LastSendTime = StoreLastWrite;
            }
        }
示例#3
0
        public bool StartChannelSubscription(EtpVersion version, Guid sessionId, int maxDataItems, TimeSpan maxMessageRate, bool autoStart, MockGrowingObjectCallbacks callbacks)
        {
            CheckLocked();

            if (ChannelSubscriptionsBySessionId.ContainsKey(sessionId))
            {
                return(false);
            }

            ChannelSubscriptionsBySessionId[sessionId] = new ChannelSubscription
            {
                Version = version,
                Uuid    = sessionId,
                LastNotificationTime = StoreLastWrite,
                AutoStart            = autoStart,
                MaxDataItems         = maxDataItems,
                MaxMessageRate       = maxMessageRate,
                Callbacks            = callbacks,
            };

            return(true);
        }
示例#4
0
        private void RefreshChannelSubscription(ChannelSubscription subscription)
        {
            var allObjects = new Dictionary <Guid, MockObject>();

            subscription.ChannelScopeUuidByChannelUuid.Clear();
            subscription.ValidChannelIds.Clear();
            foreach (var subscriptionInfo in subscription.ChannelScopesByChannelScopeUuid.Values)
            {
                foreach (var @object in GetObjects(subscription.Version, subscriptionInfo.Context))
                {
                    allObjects[@object.Uuid] = @object;
                    if (!subscription.ChannelScopeUuidByChannelUuid.ContainsKey(@object.Uuid))
                    {
                        subscription.ChannelScopeUuidByChannelUuid[@object.Uuid] = subscriptionInfo.RequestUuid;
                        ChannelSubscriptionInfo info;
                        if (!subscription.ChannelSubscriptionsByChannelUuid.TryGetValue(@object.Uuid, out info))
                        {
                            info = new ChannelSubscriptionInfo
                            {
                                Channel          = @object,
                                ChannelId        = subscription.NextChannelId++,
                                ChannelScopeUuid = subscriptionInfo.RequestUuid,
                                IsStarted        = false,
                                SendChanges      = false,
                            };
                            if (subscription.AutoStart)
                            {
                                StartChannelSubscriptionInfo(info, null, false);
                            }
                            subscription.ChannelSubscriptionsByChannelUuid[@object.Uuid] = info;
                        }
                        subscription.ValidChannelIds[info.ChannelId] = info;
                    }
                }
            }

            RefreshSubscriptionObjects(subscription, allObjects.Values);
        }