예제 #1
0
파일: mDNS.cs 프로젝트: rajeshwarn/mDNS
        /// <summary> Listen for services of a given type. The type has to be a fully qualified
        /// type name such as <code>_http._tcp.local.</code>.
        /// </summary>
        /// <param name="type">full qualified service type, such as <code>_http._tcp.local.</code>.
        /// </param>
        /// <param name="listener">listener for service updates
        /// </param>
        public virtual void AddServiceListener(string type, IServiceListener listener)
        {
            string lotype = type.ToLower();

            RemoveServiceListener(lotype, listener);
            IList list = null;

            lock (this)
            {
                list = (IList)serviceListeners[lotype];
                if (list == null)
                {
                    list = ArrayList.Synchronized(new ArrayList());
                    serviceListeners[lotype] = list;
                }
                list.Add(listener);
            }

            // report cached service types
            foreach (DictionaryEntry entry in cache)
            {
                for (DNSCache.CacheNode n = (DNSCache.CacheNode)entry.Value; n != null; n = n.Next)
                {
                    DNSRecord rec = (DNSRecord)n.Value;
                    if (rec.type == DNSConstants.TYPE_SRV)
                    {
                        if (rec.name.EndsWith(type))
                        {
                            listener.ServiceAdded(this, new ServiceEvent(this, type, ToUnqualifiedName(type, rec.name), null));
                        }
                    }
                }
            }
            new ServiceResolver(this, type).start();
        }
        static void n_ServiceAdded_Ljavax_jmdns_ServiceEvent_(IntPtr jnienv, IntPtr native__this, IntPtr native_p0)
        {
            IServiceListener __this = Java.Lang.Object.GetObject <IServiceListener> (native__this, JniHandleOwnership.DoNotTransfer);

            global::Javax.Jmdns.ServiceEvent p0 = Java.Lang.Object.GetObject <global::Javax.Jmdns.ServiceEvent> (native_p0, JniHandleOwnership.DoNotTransfer);
            __this.ServiceAdded(p0);
        }
예제 #3
0
파일: mDNS.cs 프로젝트: pisker/mDNS
		/// <summary> Listen for services of a given type. The type has to be a fully qualified
		/// type name such as <code>_http._tcp.local.</code>.
		/// </summary>
		/// <param name="type">full qualified service type, such as <code>_http._tcp.local.</code>.
		/// </param>
		/// <param name="listener">listener for service updates
		/// </param>
		public virtual void AddServiceListener(string type, IServiceListener listener)
		{
			string lotype = type.ToLower();
			RemoveServiceListener(lotype, listener);
			IList list = null;
			lock (this)
			{
				list = (IList) serviceListeners[lotype];
				if (list == null)
				{
					list = ArrayList.Synchronized(new ArrayList());
					serviceListeners[lotype] = list;
				}
				list.Add(listener);
			}
			
			// report cached service types
			foreach (DictionaryEntry entry in cache)
			{
				for (DNSCache.CacheNode n = (DNSCache.CacheNode)entry.Value; n != null; n = n.Next)
				{
					DNSRecord rec = (DNSRecord) n.Value;
					if (rec.type == DNSConstants.TYPE_SRV)
					{
						if (rec.name.EndsWith(type))
						{
							listener.ServiceAdded(this, new ServiceEvent(this, type, ToUnqualifiedName(type, rec.name), null));
						}
					}
				}
			}
			new ServiceResolver(this, type).start();
		}