public void Enqueue(BaseWoopsaSubscriptionServiceSubscription subscription, IWoopsaNotification notification,
                            out bool itemDiscarded)
        {
            PairSubscriptionNotification pair = new PairSubscriptionNotification(subscription, notification);

            lock (_notifications)
            {
                if (subscription.MonitorInterval == WoopsaSubscriptionServiceConst.MonitorIntervalLastPublishedValueOnly)
                {
                    // remove any existing notification from this subscription, as we want to keep only the last
                    LinkedListNode <PairSubscriptionNotification> node = _notifications.First;
                    while (node != null)
                    {
                        var next = node.Next;
                        if (node.Value.Key == subscription)
                        {
                            _notifications.Remove(node);
                        }
                        node = next;
                    }
                }
                itemDiscarded = _notifications.Count >= MaxQueueSize;
                if (itemDiscarded)
                {
                    while (_notifications.Count >= MaxQueueSize)
                    {
                        _notifications.RemoveFirst();
                    }
                }
                _notifications.AddLast(pair);
            }
        }
Exemple #2
0
 public CanWatchEventArgs(
     BaseWoopsaSubscriptionServiceSubscription subscription, IWoopsaProperty itemProperty)
 {
     Subscription = subscription;
     ItemProperty = itemProperty;
     CanWatch     = WoopsaSubscriptionServiceImplementation.
                    CanWatchDefaultValue;
 }
Exemple #3
0
 internal bool OnCanWatch(BaseWoopsaSubscriptionServiceSubscription subscription, IWoopsaProperty itemProperty)
 {
     if (CanWatch != null)
     {
         CanWatchEventArgs e = new
                               CanWatchEventArgs(subscription, itemProperty);
         CanWatch(this, e);
         return(e.CanWatch);
     }
     else
     {
         return(CanWatchDefaultValue);
     }
 }
        internal void SubscriptionPublishNotifications(
            BaseWoopsaSubscriptionServiceSubscription subscription,
            List <IWoopsaNotification> notifications)
        {
            foreach (var notification in notifications)
            {
                bool itemDiscarded;

                _lastNotificationId++;
                if (_lastNotificationId >= WoopsaSubscriptionServiceConst.MaximumNotificationId)
                {
                    _lastNotificationId = WoopsaSubscriptionServiceConst.MinimumNotificationId;
                }
                notification.Id = _lastNotificationId;
                _pendingNotifications.Enqueue(subscription, notification, out itemDiscarded);
                if (itemDiscarded)
                {
                    _notificationsLost = true;
                }
            }
            _waitNotificationEvent.Set();
        }
 public void Enqueue(BaseWoopsaSubscriptionServiceSubscription subscription, IWoopsaNotification notification,
     out bool itemDiscarded)
 {
     PairSubscriptionNotification pair = new PairSubscriptionNotification(subscription, notification);
     lock (_notifications)
     {
         if (subscription.MonitorInterval == WoopsaSubscriptionServiceConst.MonitorIntervalLastPublishedValueOnly)
         {
             // remove any existing notification from this subscription, as we want to keep only the last
             LinkedListNode<PairSubscriptionNotification> node = _notifications.First;
             while (node != null)
             {
                 var next = node.Next;
                 if (node.Value.Key == subscription)
                     _notifications.Remove(node);
                 node = next;
             }
         }
         itemDiscarded = _notifications.Count >= MaxQueueSize;
         if (itemDiscarded)
             while (_notifications.Count >= MaxQueueSize)
                 _notifications.RemoveFirst();
         _notifications.AddLast(pair);
     }
 }
        internal void SubscriptionPublishNotifications(
            BaseWoopsaSubscriptionServiceSubscription subscription,
            List<IWoopsaNotification> notifications)
        {
            foreach (var notification in notifications)
            {
                bool itemDiscarded;

                _lastNotificationId++;
                if (_lastNotificationId >= WoopsaSubscriptionServiceConst.MaximumNotificationId)
                    _lastNotificationId = WoopsaSubscriptionServiceConst.MinimumNotificationId;
                notification.Id = _lastNotificationId;
                _pendingNotifications.Enqueue(subscription, notification, out itemDiscarded);
                if (itemDiscarded)
                    _notificationsLost = true;
            }
            _waitNotificationEvent.Set();
        }
Exemple #7
0
 private bool OnCanWatch(
     BaseWoopsaSubscriptionServiceSubscription subscription,
     IWoopsaProperty itemProperty)
 {
     return(Channel.OnCanWatch(subscription, itemProperty));
 }
 internal bool OnCanWatch(BaseWoopsaSubscriptionServiceSubscription subscription, IWoopsaProperty itemProperty)
 {
     return(ServiceImplementation.OnCanWatch(subscription, itemProperty));
 }