Example #1
0
        protected virtual void OnServiceRemoved(BrowseService service)
        {
            ServiceBrowseEventHandler handler = ServiceRemoved;

            if (handler != null)
            {
                handler(this, new ServiceBrowseEventArgs(service));
            }
        }
Example #2
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();
            }
        }
Example #3
0
        private void OnServiceRemoved(object o, AV.ServiceInfoArgs args)
        {
            ServiceBrowseEventHandler handler = ServiceRemoved;

            if (handler != null)
            {
                handler(this, new ServiceBrowseEventArgs(new ResolvableService(client, args.Service)));
            }
        }
Example #4
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);
                }
            }
        }
Example #5
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;

            ServiceBrowseEventArgs args = new ServiceBrowseEventArgs();

            args.Service    = service;
            args.MoreComing = (flags & ServiceFlags.MoreComing) != 0;

            if ((flags & ServiceFlags.Add) != 0)
            {
                lock (service_table.SyncRoot) {
                    service_table[serviceName] = service;
                }
                ServiceBrowseEventHandler handler = ServiceAdded;
                if (handler != null)
                {
                    handler(this, args);
                }
            }
            else
            {
                lock (service_table.SyncRoot) {
                    service_table.Remove(serviceName);
                }
                ServiceBrowseEventHandler handler = ServiceRemoved;
                if (handler != null)
                {
                    handler(this, args);
                }
            }
        }