예제 #1
0
파일: mDNS.cs 프로젝트: rajeshwarn/mDNS
 /// <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);
     }
 }
예제 #2
0
파일: mDNS.cs 프로젝트: rajeshwarn/mDNS
        /// <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);
                    }
                }
            }
        }
예제 #3
0
파일: mDNS.cs 프로젝트: pisker/mDNS
		/// <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);
			}
		}
예제 #4
0
파일: mDNS.cs 프로젝트: pisker/mDNS
		/// <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);
					}
				}
			}
		}