/// <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); } }
/// <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; }
/// <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); }
/// <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); } } }
/// <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; } } }
/// <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; } }
/// <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); } }
public void RemoveMonitor(Address zoneId, ZoneNotification subscriber) { _monitoredZones.Remove(zoneId); }
public void Monitor(Address zoneId, ZoneNotification subscriber) { _monitoredZones.Add(zoneId, subscriber); }