コード例 #1
0
ファイル: ZoneServer.cs プロジェクト: ImfeldC/NuvoControl2
 /// <summary>
 /// <see cref="IZoneServer"/>
 /// </summary>
 /// <param name="zoneId"></param>
 /// <param name="subscriber"></param>
 public void RemoveMonitor(Address zoneId, ZoneNotification subscriber)
 {
     lock (this)
     {
         ValidateZone(zoneId);
         _zoneControllers[zoneId].RemoveMonitor(subscriber);
     }
 }
コード例 #2
0
            /// <summary>
            /// Add a new subriber to this zone.
            /// </summary>
            /// <param name="zoneNotification">Delegate of the subscriber.</param>
            public void AddSubscriber(ZoneNotification zoneNotification)
            {
                if (subscribers.ContainsKey(zoneNotification))
                {
                    return;
                }

                subscribers.Add(zoneNotification, zoneNotification);
                _zoneNotification += zoneNotification;
                return;
            }
コード例 #3
0
            /// <summary>
            /// Remove the subscriber from this zone.
            /// </summary>
            /// <param name="zoneNotification">Delegate of the subscriber.</param>
            /// <returns>The number of subscribers.</returns>
            public int RemoveSubscriber(ZoneNotification zoneNotification)
            {
                if (subscribers.ContainsKey(zoneNotification) == false)
                {
                    return(subscribers.Count);
                }

                subscribers.Remove(zoneNotification);
                _zoneNotification -= zoneNotification;
                return(subscribers.Count);
            }
コード例 #4
0
 /// <summary>
 /// <see cref="IZoneController"/>
 /// </summary>
 /// <param name="subscriber"></param>
 public void RemoveMonitor(ZoneNotification subscriber)
 {
     lock (this)
     {
         try
         {
             _zoneNotification -= subscriber;
         }
         catch (Exception exc)
         {
             _log.Warn("Failed to unsubscribe for the zone.", exc);
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// <see cref="IZoneController"/>
 /// </summary>
 /// <param name="subscriber"></param>
 public void Monitor(ZoneNotification subscriber)
 {
     lock (this)
     {
         try
         {
             _zoneNotification += subscriber;
         }
         catch (ArgumentException exc)
         {
             _log.Error("Failed to subscribe for the zone.", exc);
             throw exc;
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// Monitors a zone. (Subscribes for zone state changes.)
        /// </summary>
        /// <param name="zoneId">Address of the zone.</param>
        /// <param name="subscriber">The subscriber.</param>
        public void Monitor(Address zoneId, ZoneNotification subscriber)
        {
            _log.Trace(m => m(String.Format("M&C Proxy; Monitor(); Address: {0}", zoneId)));

            try
            {
                if (_zoneSubscriptions.ContainsKey(zoneId) == false)
                {
                    _zoneSubscriptions.Add(zoneId, new ZoneSubscriptions(zoneId));
                    _mcServiceProxy.Monitor(zoneId);
                }
                _zoneSubscriptions[zoneId].AddSubscriber(subscriber);
            }
            catch (ArgumentException exc)
            {
                _log.Error("Failed to subscribe for the zone.", exc);
                throw exc;
            }
        }
コード例 #7
0
        /// <summary>
        /// Removes a monitor for a zone. (Unubscribes for zone state changes.)
        /// </summary>
        /// <param name="zoneId">Address of the zone.</param>
        /// <param name="subscriber">The subscriber.</param>
        public void RemoveMonitor(Address zoneId, ZoneNotification subscriber)
        {
            _log.Trace(m => m(String.Format("M&C Proxy; RemoveMonitor(); Address: {0}", zoneId)));

            try
            {
                if (_zoneSubscriptions.ContainsKey(zoneId) == false)
                {
                    return;
                }

                if (_zoneSubscriptions[zoneId].RemoveSubscriber(subscriber) == 0)
                {
                    _mcServiceProxy.RemoveMonitor(zoneId);
                    _zoneSubscriptions.Remove(zoneId);
                }
            }
            catch (Exception exc)
            {
                _log.Warn("Failed to unsubscribe for the zone.", exc);
            }
        }
コード例 #8
0
 public void RemoveMonitor(Address zoneId, ZoneNotification subscriber)
 {
     _monitoredZones.Remove(zoneId);
 }
コード例 #9
0
 public void Monitor(Address zoneId, ZoneNotification subscriber)
 {
     _monitoredZones.Add(zoneId, subscriber);
 }