/// <summary> Remove a listener from all outstanding questions. The listener will no longer /// receive any updates. /// </summary> internal virtual void RemoveListener(IDNSListener listener) { lock (this) { listeners.Remove(listener); } }
/// <summary> Add a listener for a question. The listener will receive updates /// of answers to the question as they arrive, or from the cache if they /// are already available. /// </summary> internal virtual void AddListener(IDNSListener listener, DNSQuestion question) { long now = (DateTime.Now.Ticks - 621355968000000000) / 10000; // add the new listener lock (this) { listeners.Add(listener); } // report existing matched records if (question != null) { for (DNSCache.CacheNode i = cache.find(question.name); i != null; i = i.Next) { DNSRecord c = (DNSRecord)i.Value; if (question.IsAnsweredBy(c) && !c.IsExpired(now)) { listener.UpdateRecord(this, now, c); } } } }
/// <summary> Add a listener for a question. The listener will receive updates /// of answers to the question as they arrive, or from the cache if they /// are already available. /// </summary> internal virtual void AddListener(IDNSListener listener, DNSQuestion question) { long now = (DateTime.Now.Ticks - 621355968000000000) / 10000; // add the new listener lock (this) { listeners.Add(listener); } // report existing matched records if (question != null) { for (DNSCache.CacheNode i = cache.find(question.name); i != null; i = i.Next) { DNSRecord c = (DNSRecord) i.Value; if (question.IsAnsweredBy(c) && !c.IsExpired(now)) { listener.UpdateRecord(this, now, c); } } } }