/// <summary> A service hase been resolved. Its details are now available in the /// ServiceInfo record. /// </summary> public virtual void ServiceResolved(object event_sender, ServiceEvent event_Renamed) { lock (infos.SyncRoot) { infos[event_Renamed.Name] = event_Renamed.Info; } }
protected virtual void OnServiceType(ServiceEvent eventParam) { if (ServiceTypeListenerDelegateVar != null) { ServiceTypeListenerDelegateVar(this, eventParam); } }
/// <summary>A service has been removed. </summary> public virtual void ServiceRemoved(object event_sender, ServiceEvent event_Renamed) { lock (infos.SyncRoot) { infos.Remove(event_Renamed.Name); } }
/// <summary>A service has been added. </summary> public virtual void ServiceAdded(object event_sender, ServiceEvent event_Renamed) { lock (infos.SyncRoot) { event_Renamed.DNS.RequestServiceInfo(event_Renamed.Type, event_Renamed.Name, 0); } }
// Remind: Method updateRecord should receive a better name. /// <summary> Notify all listeners that a record was updated.</summary> internal virtual void UpdateRecord(long now, DNSRecord rec) { // We do not want to block the entire DNS while we are updating the record for each listener (service info) IList listenerList = null; lock (this) { listenerList = new ArrayList(listeners); } foreach (IDNSListener listener in listenerList) { listener.UpdateRecord(this, now, rec); } if (rec.type == DNSConstants.TYPE_PTR || rec.type == DNSConstants.TYPE_SRV) { IList serviceListenerList = null; lock (this) { serviceListenerList = (IList)serviceListeners[rec.name.ToLower()]; // Iterate on a copy in case listeners will modify it if (serviceListenerList != null) { serviceListenerList = new ArrayList(serviceListenerList); } } if (serviceListenerList != null) { bool expired = rec.IsExpired(now); string type = rec.Name; string name = ((Pointer)rec).Alias; // DNSRecord old = (DNSRecord)services.get(name.toLowerCase()); if (!expired) { // new record ServiceEvent event_Renamed = new ServiceEvent(this, type, ToUnqualifiedName(type, name), null); foreach (IServiceListener listener in serviceListenerList) { listener.ServiceAdded(this, event_Renamed); } } else { // expire record ServiceEvent event_Renamed = new ServiceEvent(this, type, ToUnqualifiedName(type, name), null); foreach (IServiceListener listener in serviceListenerList) { listener.ServiceRemoved(this, event_Renamed); } } } } }
internal virtual void HandleServiceResolved(ServiceInfo info) { IList list = (IList)serviceListeners[info.type.ToLower()]; if (list != null) { ServiceEvent event_Renamed = new ServiceEvent(this, info.type, info.getName(), info); // Iterate on a copy in case listeners will modify it ArrayList listCopy = new ArrayList(list); foreach (IServiceListener listener in listCopy) { listener.ServiceResolved(this, event_Renamed); } } }
// Remind: Method updateRecord should receive a better name. /// <summary> Notify all listeners that a record was updated.</summary> internal virtual void UpdateRecord(long now, DNSRecord rec) { // We do not want to block the entire DNS while we are updating the record for each listener (service info) IList listenerList = null; lock (this) { listenerList = new ArrayList(listeners); } foreach (IDNSListener listener in listenerList) { listener.UpdateRecord(this, now, rec); } if (rec.type == DNSConstants.TYPE_PTR || rec.type == DNSConstants.TYPE_SRV) { IList serviceListenerList = null; lock (this) { serviceListenerList = (IList) serviceListeners[rec.name.ToLower()]; // Iterate on a copy in case listeners will modify it if (serviceListenerList != null) serviceListenerList = new ArrayList(serviceListenerList); } if (serviceListenerList != null) { bool expired = rec.IsExpired(now); string type = rec.Name; string name = ((Pointer) rec).Alias; // DNSRecord old = (DNSRecord)services.get(name.toLowerCase()); if (!expired) { // new record ServiceEvent event_Renamed = new ServiceEvent(this, type, ToUnqualifiedName(type, name), null); foreach (IServiceListener listener in serviceListenerList) { listener.ServiceAdded(this, event_Renamed); } } else { // expire record ServiceEvent event_Renamed = new ServiceEvent(this, type, ToUnqualifiedName(type, name), null); foreach (IServiceListener listener in serviceListenerList) { listener.ServiceRemoved(this, event_Renamed); } } } } }
protected virtual void OnServiceType(ServiceEvent eventParam) { if (ServiceTypeListenerDelegateVar != null) ServiceTypeListenerDelegateVar(this, eventParam); }
internal virtual void HandleServiceResolved(ServiceInfo info) { IList list = (IList) serviceListeners[info.type.ToLower()]; if (list != null) { ServiceEvent event_Renamed = new ServiceEvent(this, info.type, info.getName(), info); // Iterate on a copy in case listeners will modify it ArrayList listCopy = new ArrayList(list); foreach (IServiceListener listener in listCopy) { listener.ServiceResolved(this, event_Renamed); } } }