Inheritance: Mono.Zeroconf.ServiceBrowseEventArgs
Beispiel #1
0
        private static void OnBrowseReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex, ServiceError errorCode,
                                          string serviceName, string regtype, string replyDomain, IntPtr context)
        {
            var           handle         = GCHandle.FromIntPtr(context);
            var           serviceBrowser = handle.Target as ServiceBrowser;
            BrowseService service        = new BrowseService();

            service.Flags           = flags;
            service.Name            = serviceName;
            service.RegType         = regtype;
            service.ReplyDomain     = replyDomain;
            service.InterfaceIndex  = interfaceIndex;
            service.AddressProtocol = serviceBrowser.address_protocol;

            Log.To.Discovery.V(TAG, "{0} (0x{1}) entered OnBrowseReply (found={2} flags={3})",
                               serviceBrowser, sdRef.Raw.ToString("X"), service, flags);

            ServiceBrowseEventArgs args = new ServiceBrowseEventArgs(
                service, (flags & ServiceFlags.MoreComing) != 0);

            if ((flags & ServiceFlags.Add) != 0)
            {
                lock (serviceBrowser.service_table) {
                    if (serviceBrowser.service_table.ContainsKey(serviceName))
                    {
                        serviceBrowser.service_table[serviceName] = service;
                    }
                    else
                    {
                        serviceBrowser.service_table.Add(serviceName, service);
                    }
                }

                ServiceBrowseEventHandler handler = serviceBrowser._serviceAdded;
                if (handler != null)
                {
                    handler(serviceBrowser, args);
                }
            }
            else
            {
                lock (serviceBrowser.service_table) {
                    if (serviceBrowser.service_table.ContainsKey(serviceName))
                    {
                        serviceBrowser.service_table.Remove(serviceName);
                    }
                }

                ServiceBrowseEventHandler handler = serviceBrowser._serviceRemoved;
                if (handler != null)
                {
                    handler(serviceBrowser, args);
                }

                service.Dispose();
            }
        }
Beispiel #2
0
        private void OnBrowseReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex, ServiceError errorCode,
                                   IntPtr serviceName, string regtype, string replyDomain, IntPtr context)
        {
            string        name    = Native.Utf8toString(serviceName);
            BrowseService service = new BrowseService();

            service.Flags           = flags;
            service.Name            = name;
            service.RegType         = regtype;
            service.ReplyDomain     = replyDomain;
            service.InterfaceIndex  = interfaceIndex;
            service.AddressProtocol = address_protocol;

            ServiceBrowseEventArgs args = new ServiceBrowseEventArgs(
                service, (flags & ServiceFlags.MoreComing) != 0);

            if ((flags & ServiceFlags.Add) != 0)
            {
                lock (service_table) {
                    if (service_table.ContainsKey(name))
                    {
                        service_table[name] = service;
                    }
                    else
                    {
                        service_table.Add(name, service);
                    }
                }

                ServiceBrowseEventHandler handler = ServiceAdded;
                if (handler != null)
                {
                    handler(this, args);
                }
            }
            else
            {
                lock (service_table) {
                    if (service_table.ContainsKey(name))
                    {
                        service_table.Remove(name);
                    }
                }

                ServiceBrowseEventHandler handler = ServiceRemoved;
                if (handler != null)
                {
                    handler(this, args);
                }
            }
        }
Beispiel #3
0
        private void OnBrowseReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex, ServiceError errorCode, 
            string serviceName, string regtype, string replyDomain, IntPtr context)
        {
            BrowseService service = new BrowseService();
            service.Flags = flags;
            service.Name = serviceName;
            service.RegType = regtype;
            service.ReplyDomain = replyDomain;
            service.InterfaceIndex = interfaceIndex;
            service.AddressProtocol = address_protocol;

            ServiceBrowseEventArgs args = new ServiceBrowseEventArgs(
                service, (flags & ServiceFlags.MoreComing) != 0);

            if((flags & ServiceFlags.Add) != 0) {
                lock (service_table) {
                    if (service_table.ContainsKey (serviceName)) {
                        service_table[serviceName] = service;
                    } else {
                        service_table.Add (serviceName, service);
                    }
                }

                ServiceBrowseEventHandler handler = ServiceAdded;
                if(handler != null) {
                    handler(this, args);
                }
            } else {
                lock (service_table) {
                    if (service_table.ContainsKey (serviceName)) {
                        service_table.Remove (serviceName);
                    }
                }

                ServiceBrowseEventHandler handler = ServiceRemoved;
                if(handler != null) {
                    handler(this, args);
                }
            }
        }
        private static void OnBrowseReply(ServiceRef sdRef, ServiceFlags flags, uint interfaceIndex, ServiceError errorCode, 
            string serviceName, string regtype, string replyDomain, IntPtr context)
        {
            var handle = GCHandle.FromIntPtr(context);
            var serviceBrowser = handle.Target as ServiceBrowser;
            BrowseService service = new BrowseService();
            service.Flags = flags;
            service.Name = serviceName;
            service.RegType = regtype;
            service.ReplyDomain = replyDomain;
            service.InterfaceIndex = interfaceIndex;
            service.AddressProtocol = serviceBrowser.address_protocol;

            Log.To.Discovery.V(TAG, "{0} (0x{1}) entered OnBrowseReply (found={2} flags={3})", 
                serviceBrowser, sdRef.Raw.ToString("X"), service, flags);
            
            ServiceBrowseEventArgs args = new ServiceBrowseEventArgs(
                service, (flags & ServiceFlags.MoreComing) != 0);
            
            if((flags & ServiceFlags.Add) != 0) {
                lock (serviceBrowser.service_table) {
                    if (serviceBrowser.service_table.ContainsKey (serviceName)) {
                        serviceBrowser.service_table[serviceName] = service;
                    } else {
                        serviceBrowser.service_table.Add (serviceName, service);
                    }
                }
                
                ServiceBrowseEventHandler handler = serviceBrowser._serviceAdded;
                if(handler != null) {
                    handler(serviceBrowser, args);
                }
            } else {
                lock (serviceBrowser.service_table) {
                    if (serviceBrowser.service_table.ContainsKey (serviceName)) {
                        serviceBrowser.service_table.Remove (serviceName);
                    }
                }
                
                ServiceBrowseEventHandler handler = serviceBrowser._serviceRemoved;
                if(handler != null) {
                    handler(serviceBrowser, args);
                }

                service.Dispose();
            }
        }