コード例 #1
0
        public async void Start()
        {
            if (mServer != null)
            {
                throw new InvalidOperationException();
            }
            lock (knownHosts) knownHosts.Clear();
            mServer = new HttpSelfHostServer(Configure());
            var             serverTask = mServer.OpenAsync();
            RegisterService rs         = new RegisterService();

            rs.RegType     = "_tincer._tcp";
            rs.ReplyDomain = "local.";
            rs.Name        = Environment.MachineName;
            rs.Port        = (short)(ushort)Arguments.Global.ListenPort;
            rs.TxtRecord   = new TxtRecord();
            rs.TxtRecord.Add("NODEID", ApiHost.Id.ToByteArray());
            rs.Register();
            rs.Response       += rs_Response;
            serviceRegister    = rs;
            sb.ServiceAdded   += sb_ServiceAdded;
            sb.ServiceRemoved += sb_ServiceRemoved;
            sb.Browse("_tincer._tcp", "local.");
            await serverTask;

            timer.Change(30000, 30000);
        }
コード例 #2
0
        public CanDiscoveryService(string mDnsService, string mDnsDomain)
        {
            _cans = new List <Can>();
            // _cans.Add(new Can("skynet.io", "skynet.io"));

            try
            {
                _browser = new ServiceBrowser();
                _browser.ServiceAdded += ServiceAdded;

                _subject = new Subject <IEnumerable <Can> >();
                var conn = _subject.Replay(1);
                conn.Connect();
                Cans = conn;

                _browser.Browse(0,
                                AddressProtocol.Any,
                                mDnsService,
                                mDnsDomain);
            }
            catch (Exception ex)
            {
                Cans = Observable.Throw <IEnumerable <Can> >(ex);
            }
        }
コード例 #3
0
        protected override void Initialize()
        {
            browser = new ServiceBrowser();
            browser.ServiceAdded += delegate(object o, ServiceBrowseEventArgs args)
            {
                Console.WriteLine("Found Service: {0}", args.Service.Name);
                args.Service.Resolved += delegate(object o2, ServiceResolvedEventArgs args2)
                {
                    lock (resolveLock)
                    {
                        IResolvableService s = (IResolvableService)args2.Service;

                        ServiceLocation loc = new ServiceLocation(s.HostEntry.AddressList[0], s.Port, s.FullName);
                        Logger.Info("A new ethernet interface was found");
                        SmartScopeInterfaceEthernet ethif = new SmartScopeInterfaceEthernet(loc.ip, loc.port, OnInterfaceDisconnect);
                        if (ethif.Connected)
                        {
                            createdInterfaces.Add(loc, ethif);
                            if (onConnect != null)
                            {
                                onConnect(ethif, true);
                            }
                        }
                        else
                        {
                            Logger.Info("... but could not connect to ethernet interface");
                        }
                    }
                };
                args.Service.Resolve();
            };

            browser.Browse(Net.Net.SERVICE_TYPE, Net.Net.REPLY_DOMAIN);
        }
コード例 #4
0
        public void Start()
        {
            if (acnSocket == null || !acnSocket.PortOpen)
            {
                acnSocket = new RdmNetSocket(UId.NewUId(0xFF), Guid.NewGuid(), "RDM Snoop");
                acnSocket.NewRdmPacket += acnSocket_NewRdmPacket;
                acnSocket.Open(new IPEndPoint(LocalAdapter, 0));
            }

#if SLP_Discovery
            slpUser = new SlpUserAgent("ACN-DEFAULT");
            slpUser.NetworkAdapter = localAdapter;
            slpUser.ServiceFound  += new EventHandler <ServiceFoundEventArgs>(slpUser_ServiceFound);


            slpUser.Open();
            slpUser.Find("service:rdmnet-device");
#endif

#if mDNS_Discovery
            dnsSD = new ServiceBrowser();
            dnsSD.ServiceAdded += dnsSD_ServiceAdded;
            dnsSD.Browse("_rdmnet._udp", "local");
#endif
        }
コード例 #5
0
 private void Browse()
 {
     browser = new ServiceBrowser();
     browser.ServiceAdded   += OnServiceAdded;
     browser.ServiceRemoved += OnServiceRemoved;
     browser.Browse(0, AddressProtocol.Any, RAOP_MDNS_TYPE, "local");
 }
コード例 #6
0
        /// <summary>
        /// Starts a discovery process
        /// </summary>
        public void Find(DiscoveryType type = DiscoveryType.WsDiscovery)
        {
            ActivityServices.Clear();
#if !ANDROID
            switch (type)
            {
            case DiscoveryType.WsDiscovery:
                using (var wsBrowser = new DiscoveryClient(new UdpDiscoveryEndpoint()))
                {
                    wsBrowser.FindProgressChanged += WsBrowserFindProgressChanged;
                    wsBrowser.FindCompleted       += WsBrowserFindCompleted;
                    wsBrowser.FindAsync(new FindCriteria(typeof(IDiscovery)));
                }
                break;

            case DiscoveryType.Zeroconf:
            {
                var zcBrowser = new ServiceBrowser();
                zcBrowser.ServiceAdded += zcBrowser_ServiceAdded;
                zcBrowser.Browse("_am._tcp", "local");
            }
            break;
            }
#else
            Probe();
#endif
        }
コード例 #7
0
        //
        // Configure the code that will be called back when the information
        // becomes available
        //

        public void Start()
        {
            browser = new ServiceBrowser();

            browser.ServiceAdded   += OnServiceAdded;
            browser.ServiceRemoved += OnServiceRemoved;

            browser.Browse("_dpap._tcp", "local");
        }
コード例 #8
0
 public void BrowseServices()
 {
     if (browser == null)
     {
         browser = new ServiceBrowser();
         browser.ServiceAdded   += new ServiceBrowseEventHandler(browser_ServiceAdded);
         browser.ServiceRemoved += new ServiceBrowseEventHandler(browser_ServiceRemoved);
         browser.Browse(0, AddressProtocol.Any, ZEROCONF_NAME, "local");
     }
 }
コード例 #9
0
        public void Start()
        {
            if (browser != null)
            {
                Stop();
            }

            browser = new ServiceBrowser();
            browser.ServiceAdded   += OnServiceAdded;
            browser.ServiceRemoved += OnServiceRemoved;
            browser.Browse("_daap._tcp", null);
        }
コード例 #10
0
ファイル: ServiceLocator.cs プロジェクト: tcausby/giver
        public void Start()
        {
            if (browser == null)
            {
                browser = new ServiceBrowser();

                browser.ServiceAdded   += OnServiceAdded;
                browser.ServiceRemoved += OnServiceRemoved;

                browser.Browse("_giver._tcp", "local");
            }
        }
コード例 #11
0
ファイル: FindServer.cs プロジェクト: jcable/sif-mmm
    public static int Main(string [] args)
    {
        string type = "_http._tcp";

        ServiceBrowser browser = new ServiceBrowser();

        browser.ServiceAdded   += OnServiceAdded;
        browser.ServiceRemoved += OnServiceRemoved;
        browser.Browse(type, "local");

        while (true)
        {
            System.Threading.Thread.Sleep(1000);
        }
    }
コード例 #12
0
        public SifClient()
        {
            string type = "_http._tcp";

            try {
                ServiceBrowser browser = new ServiceBrowser();
                browser.ServiceAdded   += OnServiceAdded;
                browser.ServiceRemoved += OnServiceRemoved;
                browser.Browse(type, "local");
            } catch (Exception e)
            {
                url = "http://localhost/sif";
                register();
            }
            while (!done)
            {
                System.Threading.Thread.Sleep(1000);
            }
        }
コード例 #13
0
        public static int Main(string[] args)
        {
            string    type     = "_http._tcp";
            ArrayList services = new ArrayList();

            Console.WriteLine("Hit ^C when you're bored waiting for responses.");
            Console.WriteLine();

            // Listen for events of some service type
            ServiceBrowser browser = new ServiceBrowser();

            browser.ServiceAdded   += OnServiceAdded;
            browser.ServiceRemoved += OnServiceRemoved;
            browser.Browse(@interface, address_protocol, type, domain);

            while (true)
            {
                System.Threading.Thread.Sleep(1000);
            }
        }
コード例 #14
0
    public static int Main(string [] args)
    {
        string    type      = "_workstation._tcp";
        bool      show_help = false;
        ArrayList services  = new ArrayList();

        services.Add("_http._tcp 80 mysimpleweb");


        for (int i = 0; i < args.Length; i++)
        {
            if (args[i][0] != '-')
            {
                continue;
            }

            switch (args[i])
            {
            case "-t":
            case "--type":
                type = args[++i];
                break;

            case "-r":
            case "--resolve":
                resolve_shares = true;
                break;

            case "-p":
            case "--publish":
                services.Add(args[++i]);
                break;

            case "-i":
            case "--interface":
                if (!UInt32.TryParse(args[++i], out @interface))
                {
                    Console.Error.WriteLine("Invalid interface index, '{0}'", args[i]);
                    show_help = true;
                }
                break;

            case "-a":
            case "--aprotocol":
                string proto = args[++i].ToLower().Trim();
                switch (proto)
                {
                case "ipv4":
                case "4": address_protocol = AddressProtocol.IPv4; break;

                case "ipv6":
                case "6": address_protocol = AddressProtocol.IPv6; break;

                case "any":
                case "all": address_protocol = AddressProtocol.Any; break;

                default:
                    Console.Error.WriteLine("Invalid IP Address Protocol, '{0}'", args[i]);
                    show_help = true;
                    break;
                }
                break;

            case "-d":
            case "--domain":
                domain = args[++i];
                break;

            case "-h":
            case "--help":
                show_help = true;
                break;

            case "-v":
            case "--verbose":
                verbose = true;
                break;
            }
        }

        if (show_help)
        {
            Console.WriteLine("Usage: {0} [-t type] [--resolve] [--publish \"description\"]", app_name);
            Console.WriteLine();
            Console.WriteLine("    -h|--help       shows this help");
            Console.WriteLine("    -v|--verbose    print verbose details of what's happening");
            Console.WriteLine("    -t|--type       uses 'type' as the service type");
            Console.WriteLine("                    (default is '_workstation._tcp')");
            Console.WriteLine("    -r|--resolve    resolve found services to hosts");
            Console.WriteLine("    -d|--domain     which domain to broadcast/listen on");
            Console.WriteLine("    -i|--interface  which network interface index to listen");
            Console.WriteLine("                    on (default is '0', meaning 'all')");
            Console.WriteLine("    -a|--aprotocol  which address protocol to use (Any, IPv4, IPv6)");
            Console.WriteLine("    -p|--publish    publish a service of 'description'");
            Console.WriteLine();
            Console.WriteLine("The -d, -i and -a options are optional. By default {0} will listen", app_name);
            Console.WriteLine("on all network interfaces ('0') on the 'local' domain, and will resolve ");
            Console.WriteLine("all address types, IPv4 and IPv6, as available.");
            Console.WriteLine();
            Console.WriteLine("The service description for publishing has the following syntax.");
            Console.WriteLine("The TXT record is optional.\n");
            Console.WriteLine("    <type> <port> <name> TXT [ <key>='<value>', ... ]\n");
            Console.WriteLine("For example:\n");
            Console.WriteLine("    -p \"_http._tcp 80 Simple Web Server\"");
            Console.WriteLine("    -p \"_daap._tcp 3689 Aaron's Music TXT [ Password='******', \\");
            Console.WriteLine("        Machine Name='Aaron\\'s Box', txtvers='1' ]\"");
            Console.WriteLine();
            return(1);
        }

        if (services.Count > 0)
        {
            foreach (string service_description in services)
            {
                RegisterService(service_description);
            }
        }
        else
        {
            if (verbose)
            {
                Console.WriteLine("Creating a ServiceBrowser with the following settings:");
                Console.WriteLine("  Interface         = {0}", @interface == 0 ? "0 (All)" : @interface.ToString());
                Console.WriteLine("  Address Protocol  = {0}", address_protocol);
                Console.WriteLine("  Domain            = {0}", domain);
                Console.WriteLine("  Registration Type = {0}", type);
                Console.WriteLine("  Resolve Shares    = {0}", resolve_shares);
                Console.WriteLine();
            }

            Console.WriteLine("Hit ^C when you're bored waiting for responses.");
            Console.WriteLine();

            // Listen for events of some service type
            ServiceBrowser browser = new ServiceBrowser();
            browser.ServiceAdded   += OnServiceAdded;
            browser.ServiceRemoved += OnServiceRemoved;
            browser.Browse(@interface, address_protocol, type, domain);
        }

        while (true)
        {
            System.Threading.Thread.Sleep(1000);
        }
    }
コード例 #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            ServiceBrowser browser = new ServiceBrowser();

            //
            // Configure the code that will be called back when the information
            // becomes available
            //
            browser.ServiceAdded += delegate(object o, ServiceBrowseEventArgs argss) {
                argss.Service.Resolved += delegate(object oo, ServiceResolvedEventArgs argsss) {
                    IResolvableService s = (IResolvableService)argsss.Service;

                    DataRow new_device = device_info.NewRow();
                    new_device["Name"] = s.Name;
                    new_device["IP"]   = s.HostEntry.AddressList[0];
                    new_device["Port"] = s.Port;
                    new_device["Attached Sensors/Actuators"] = s.TxtRecord.Count;


                    bool contains = device_info.AsEnumerable().Any(row => s.Name == row.Field <String>("Name"));
                    if (!contains)
                    {
                        device_info.Rows.Add(new_device);
                        DataTable device_components = new DataTable(s.Name);
                        device_components.Columns.Add("Type", typeof(string));
                        device_components.Columns.Add("OSC Address", typeof(string));
                        device_components.Columns.Add("Range", typeof(string));

                        for (int i = 0; i < s.TxtRecord.Count; i++)
                        {
                            DataRow       new_device_component = device_components.NewRow();
                            TxtRecordItem Component            = s.TxtRecord.BaseRecord.GetItemAt(i);

                            new_device_component["Type"] = Component.Key;

                            String[] ComponentList = Component.ValueString.Split(':');
                            new_device_component["OSC Address"] = ComponentList[0];
                            new_device_component["Range"]       = ComponentList[1];
                            device_components.Rows.Add(new_device_component);
                        }

                        devices.Tables.Add(device_components);
                    }
                };
                argss.Service.Resolve();
            };


            browser.Browse("_http._udp.", "local"); // Triggering the discovery request
            dataGridView1.DataSource = device_info; // Binding DataGridView with main table

            dataGridView1.Columns[0].Width = 220;
            dataGridView1.Columns[1].Width = 140;
            dataGridView1.Columns[2].Width = 100;
            dataGridView1.Columns[3].Width = 250;

            //
            // Adding Checkbox column in table
            //

            DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();

            chk.HeaderText = "Select";
            chk.Name       = "Checkbox";
            chk.Width      = dataGridView1.Width - dataGridView1.Columns[0].Width - dataGridView1.Columns[1].Width - dataGridView1.Columns[2].Width - dataGridView1.Columns[3].Width - 45;
            dataGridView1.Columns.Add(chk);
        }
コード例 #16
0
 public void LookForProPresenter()
 {
     _serviceBrowser.Browse("_pro6stagedsply._tcp", "local");
 }