Ejemplo n.º 1
0
        private void BrowseReply(IntPtr sdRef,
                                 DNSServiceFlags flags,
                                 UInt32 interfaceIndex,
                                 DNSServiceErrorType errorCode,
                                 String serviceName,
                                 String regtype,
                                 String replyDomain,
                                 IntPtr context)
        {
            bool moreComing = ((flags & DNSServiceFlags.MoreComing) != 0);

            if ((flags & DNSServiceFlags.Add) != 0)
            {
                // Add
                NetService newService = new NetService(replyDomain, regtype, serviceName);
                newService.InheritInvokeOptions(this);

                foundServices.Add(newService);

                if (DidFindService != null)
                {
                    DidFindService(this, newService, moreComing);
                }
            }
            else
            {
                // Remove
                foreach (NetService service in foundServices)
                {
                    if (service.Name == serviceName && service.Type == regtype && service.Domain == replyDomain)
                    {
                        foundServices.Remove(service);
                        if (DidRemoveService != null)
                        {
                            DidRemoveService(this, service, moreComing);
                        }
                        break;
                    }
                }
            }
        }
        private void BrowseReply(IntPtr sdRef,
            DNSServiceFlags flags,
            UInt32 interfaceIndex,
            DNSServiceErrorType errorCode,
            String serviceName,
            String regtype,
            String replyDomain,
            IntPtr context)
        {
            bool moreComing = ((flags & DNSServiceFlags.MoreComing) != 0);
            if ((flags & DNSServiceFlags.Add) != 0)
            {
                // Add
                NetService newService = new NetService(replyDomain, regtype, serviceName);
                newService.InheritInvokeOptions(this);

                foundServices.Add(newService);

                if (DidFindService != null)
                    DidFindService(this, newService, moreComing);
            }
            else
            {
                // Remove
                foreach (NetService service in foundServices)
                {
                    if (service.Name == serviceName && service.Type == regtype && service.Domain == replyDomain)
                    {
                        foundServices.Remove(service);
                        if (DidRemoveService != null)
                            DidRemoveService(this, service, moreComing);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static void BrowseReply(IntPtr sdRef,
            DNSServiceFlags flags,
            UInt32 interfaceIndex,
            DNSServiceErrorType errorCode,
            String serviceName,
            String regtype,
            String replyDomain,
            IntPtr context)
        {
            GCHandle gch = (GCHandle)context;
            NetServiceBrowser c = (NetServiceBrowser)gch.Target;

            bool moreComing = ((flags & DNSServiceFlags.kDNSServiceFlagsMoreComing) != 0);

            if ((flags & DNSServiceFlags.kDNSServiceFlagsAdd) != 0)
            { /* add */
                NetService newService = new NetService(replyDomain, regtype, serviceName);
                newService.InheritInvokeOptions(c);

                c.foundServices.Add(newService);

                if (c.DidFindService != null)
                    c.DidFindService(c, newService, moreComing);
            }
            else
            { /* remove */

                foreach (NetService service in c.foundServices)
                {
                    if (service.Name == serviceName &&
                        service.Type == regtype &&
                        service.Domain == replyDomain)
                    {
                        c.foundServices.Remove(service);
                        if (c.DidRemoveService != null)
                            c.DidRemoveService(c, service, moreComing);
                        break;
                    }
                }

            }
        }