protected BaseWoopsaSubscriptionServiceSubscription(
     WoopsaSubscriptionChannel channel,
     WoopsaContainer root,
     int subscriptionId, string propertyPath,
     TimeSpan monitorInterval, TimeSpan publishInterval)
 {
     Channel = channel;
     Root = root;
     SubscriptionId = subscriptionId;
     MonitorInterval = monitorInterval;
     PublishInterval = publishInterval;
     PropertyPath = propertyPath;
     _lock = new object();
     _notifications = new List<IWoopsaNotification>();
     if (monitorInterval == WoopsaSubscriptionServiceConst.MonitorIntervalLastPublishedValueOnly &&
         publishInterval == WoopsaSubscriptionServiceConst.PublishIntervalOnce)
         DoPublish();
     else if (publishInterval > TimeSpan.FromMilliseconds(0))
     {
         _publishTimer = channel.ServiceImplementation.TimerScheduler.AllocateTimer(publishInterval);
         _publishTimer.Elapsed += _publishTimer_Elapsed;
         _publishTimer.IsEnabled = true;
     }
     else
         throw new WoopsaException("A publish interval of 0 with a non-zero monitor interval is not allowed");
 }
 protected BaseWoopsaSubscriptionServiceSubscription(
     WoopsaSubscriptionChannel channel,
     WoopsaContainer root,
     int subscriptionId, string propertyPath,
     TimeSpan monitorInterval, TimeSpan publishInterval)
 {
     Channel         = channel;
     Root            = root;
     SubscriptionId  = subscriptionId;
     MonitorInterval = monitorInterval;
     PublishInterval = publishInterval;
     PropertyPath    = propertyPath;
     _lock           = new object();
     _notifications  = new List <IWoopsaNotification>();
     if (monitorInterval == WoopsaSubscriptionServiceConst.MonitorIntervalLastPublishedValueOnly &&
         publishInterval == WoopsaSubscriptionServiceConst.PublishIntervalOnce)
     {
         DoPublish();
     }
     else if (publishInterval > TimeSpan.FromMilliseconds(0))
     {
         _publishTimer           = channel.ServiceImplementation.TimerScheduler.AllocateTimer(publishInterval);
         _publishTimer.Elapsed  += _publishTimer_Elapsed;
         _publishTimer.IsEnabled = true;
     }
     else
     {
         throw new WoopsaException("A publish interval of 0 with a non-zero monitor interval is not allowed");
     }
 }
        public WoopsaSubscriptionServiceSubscriptionServerSubClient(
            WoopsaSubscriptionChannel channel,
            WoopsaContainer root,
            int subscriptionId, string propertyPath,
            TimeSpan monitorInterval, TimeSpan publishInterval,
            WoopsaBaseClientObject subClient, string relativePropertyPath) :
            base(channel, root, subscriptionId, propertyPath, monitorInterval, publishInterval)
        {
            bool isSingleNotification =
                monitorInterval == WoopsaSubscriptionServiceConst.MonitorIntervalLastPublishedValueOnly &&
                publishInterval == WoopsaSubscriptionServiceConst.PublishIntervalOnce;
            EventHandler <WoopsaNotificationEventArgs> handler;

            if (isSingleNotification)
            {
                handler =
                    (sender, e) =>
                {
                    EnqueueNewMonitoredValue(e.Notification.Value);
                    DoPublish();     // there is not publish timer, force publishing the unique notification
                }
            }
            ;
            else
            {
                handler =
                    (sender, e) =>
                {
                    EnqueueNewMonitoredValue(e.Notification.Value);
                }
            };
            _clientSubscription = subClient.Subscribe(relativePropertyPath, handler,
                                                      monitorInterval, publishInterval);
        }
 public WoopsaSubscriptionServiceSubscriptionMonitorClient(
     WoopsaSubscriptionChannel channel,
     WoopsaBaseClientObject root,
     int subscriptionId, string propertyPath,
     TimeSpan monitorInterval, TimeSpan publishInterval) :
     base(channel, root, subscriptionId, propertyPath, monitorInterval, publishInterval)
 {
 }
 public WoopsaSubscriptionServiceSubscriptionMonitorServer(
     WoopsaSubscriptionChannel channel,
     WoopsaContainer root,
     int subscriptionId, string propertyPath,
     TimeSpan monitorInterval, TimeSpan publishInterval) :
     base(channel, root, subscriptionId, propertyPath, monitorInterval, publishInterval)
 {
 }
 public int CreateSubscriptionChannel(int notificationQueueSize)
 {
     var channel = new WoopsaSubscriptionChannel(this, notificationQueueSize);
     channel.BeforeWoopsaModelAccess += Channel_BeforeWoopsaModelAccess;
     channel.AfterWoopsaModelAccess += Channel_AfterWoopsaModelAccess;
     lock (_channels)
         _channels.Add(channel.Id, channel);
     return new WoopsaValue(channel.Id);
 }
Esempio n. 7
0
        public int CreateSubscriptionChannel(int notificationQueueSize)
        {
            var channel = new WoopsaSubscriptionChannel(this, notificationQueueSize);

            channel.BeforeWoopsaModelAccess += Channel_BeforeWoopsaModelAccess;
            channel.AfterWoopsaModelAccess  += Channel_AfterWoopsaModelAccess;
            lock (_channels)
                _channels.Add(channel.Id, channel);
            return(new WoopsaValue(channel.Id));
        }
 public WoopsaSubscriptionServiceSubscriptionMonitor(
     WoopsaSubscriptionChannel channel,
     WoopsaContainer root,
     int subscriptionId, string propertyPath,
     TimeSpan monitorInterval, TimeSpan publishInterval) :
     base(channel, root, subscriptionId, propertyPath, monitorInterval, publishInterval)
 {
     if (monitorInterval != WoopsaSubscriptionServiceConst.MonitorIntervalLastPublishedValueOnly)
     {
         // create monitor timer
         _monitorTimer           = channel.ServiceImplementation.TimerScheduler.AllocateTimer(monitorInterval);
         _monitorTimer.Elapsed  += _monitorTimer_Elapsed;
         _monitorTimer.IsEnabled = true;
     }
     // Force immediate publishing of the current value
     DoMonitor();
     DoPublish();
 }
 public WoopsaSubscriptionServiceSubscriptionServerSubClient(
     WoopsaSubscriptionChannel channel,
     WoopsaContainer root,
     int subscriptionId, string propertyPath,
     TimeSpan monitorInterval, TimeSpan publishInterval,
     WoopsaBaseClientObject subClient, string relativePropertyPath)
     : base(channel, root, subscriptionId, propertyPath, monitorInterval, publishInterval)
 {
     bool isSingleNotification =
         monitorInterval == WoopsaSubscriptionServiceConst.MonitorIntervalLastPublishedValueOnly &&
         publishInterval == WoopsaSubscriptionServiceConst.PublishIntervalOnce;
     EventHandler<WoopsaNotificationEventArgs> handler;
     if (isSingleNotification)
         handler =
             (sender, e) =>
             {
                 EnqueueNewMonitoredValue(e.Notification.Value);
                 DoPublish(); // there is not publish timer, force publishing the unique notification
             };
     else
         handler =
             (sender, e) =>
             {
                 EnqueueNewMonitoredValue(e.Notification.Value);
             };
     _clientSubscription = subClient.Subscribe(relativePropertyPath, handler,
             monitorInterval, publishInterval);
 }
 public WoopsaSubscriptionServiceSubscriptionMonitorServer(
     WoopsaSubscriptionChannel channel,
     WoopsaContainer root,
     int subscriptionId, string propertyPath,
     TimeSpan monitorInterval, TimeSpan publishInterval)
     : base(channel, root, subscriptionId, propertyPath, monitorInterval, publishInterval)
 {
 }
 public WoopsaSubscriptionServiceSubscriptionMonitorClient(
     WoopsaSubscriptionChannel channel,
     WoopsaBaseClientObject root,
     int subscriptionId, string propertyPath,
     TimeSpan monitorInterval, TimeSpan publishInterval)
     : base(channel, root, subscriptionId, propertyPath, monitorInterval, publishInterval)
 {
 }
 public WoopsaSubscriptionServiceSubscriptionMonitor(
     WoopsaSubscriptionChannel channel,
     WoopsaContainer root,
     int subscriptionId, string propertyPath,
     TimeSpan monitorInterval, TimeSpan publishInterval)
     : base(channel, root, subscriptionId, propertyPath, monitorInterval, publishInterval)
 {
     if (monitorInterval != WoopsaSubscriptionServiceConst.MonitorIntervalLastPublishedValueOnly)
     {
         // create monitor timer
         _monitorTimer = channel.ServiceImplementation.TimerScheduler.AllocateTimer(monitorInterval);
         _monitorTimer.Elapsed += _monitorTimer_Elapsed;
         _monitorTimer.IsEnabled = true;
     }
     // Force immediate publishing of the current value
     DoMonitor();
     DoPublish();
 }