コード例 #1
0
        private void PluginForm_Load(object sender, EventArgs e)
        {
            Console.WriteLine("PluginForm_Load");

            CheckForIllegalCrossThreadCalls = false;

            //Pluginmain.loopstop = false;

            Console.WriteLine("CLR version from PluginForm_Load: {0}", Environment.Version);


            //-------------------------------------------------
            //begin setup zeroconf


            bonjourBrowserService = new RegisterService(); // <-- this line is where we get the problem


            bonjourBrowserService.Name        = "CNCTouch Wi-fi Server";
            bonjourBrowserService.RegType     = "_cnctouch._tcp";
            bonjourBrowserService.ReplyDomain = "local.";
            bonjourBrowserService.Port        = 2030;

            // TxtRecords are optional
            TxtRecord txt_record = new TxtRecord();

            txt_record.Add("Password", "false");
            bonjourBrowserService.TxtRecord = txt_record;

            bonjourBrowserService.Register();

            // End setup zeroconf
            //---------------------------------------------------
        }
コード例 #2
0
        /// <summary>
        /// Publish the service via Bonjour protocol to the network
        /// </summary>
        internal void PublishBonjourService()
        {
            if (_servicePublishing)
            {
                Logger.Debug("WifiRemote: Already in the process of publishing the Bonjour service. Aborting publish ...");
                return;
            }

            _servicePublishing = true;

            try
            {
                _publishService             = new RegisterService();
                _publishService.Name        = _serviceName;
                _publishService.RegType     = serviceType;
                _publishService.ReplyDomain = _domain;
                _publishService.Port        = Convert.ToInt16(_port);

                // Get the MAC addresses and set it as bonjour txt record
                // Needed by the clients to implement wake on lan
                TxtRecord txt_record = new TxtRecord();
                txt_record.Add("hwAddr", GetHardwareAddresses());
                _publishService.TxtRecord = txt_record;

                _publishService.Response += PublishService_Response;
                _publishService.Register();
            }
            catch (Exception ex)
            {
                Logger.Debug("WifiRemote: Bonjour enabled but failed to publish!", ex);
                Logger.Info("WifiRemote: Disabling Bonjour for this session. If not installed get it at http://support.apple.com/downloads/Bonjour_for_Windows");
                _disableBonjour = true;
                return;
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Mono.Zeroconf.RegisterService bonjourBrowserService = null;

            //-------------------------------------------------
            //begin setup zeroconf
            bonjourBrowserService             = new RegisterService();
            bonjourBrowserService.Name        = "CNCTouch Wi-fi Server";
            bonjourBrowserService.RegType     = "_cnctouch._tcp";
            bonjourBrowserService.ReplyDomain = "local.";
            bonjourBrowserService.Port        = 2030;

            // TxtRecords are optional
            TxtRecord txt_record = new TxtRecord();

            txt_record.Add("Password", "false");
            bonjourBrowserService.TxtRecord = txt_record;

            bonjourBrowserService.Register();

            // End setup zeroconf
            //---------------------------------------------------

            Console.ReadKey();
        }
コード例 #4
0
    void UpdateService()
    {
        if (service != null)
        {
            DestroyService();
        }

        service             = new RegisterService();
        service.Name        = "Augmenta - " + _name;
        service.RegType     = "_osc._udp";
        service.ReplyDomain = "local.";
        service.UPort       = (ushort)_port;

        if (_keys != null && _keys.Count > 0)
        {
            TxtRecord txt = new TxtRecord();
            foreach (KeyValuePair <string, string> kv in _keys)
            {
                txt.Add(kv.Key, kv.Value);
            }
            service.TxtRecord = txt;
        }

        service.Register();
    }
コード例 #5
0
    public static void Main()
    {
        Application.Init();

        // Register a sample service
        RegisterService service = new RegisterService("Fruity Music", null, "_daap._tcp");
        TxtRecord       record  = new TxtRecord();

        record.Add("A", "Apples");
        record.Add("B", "Bananas");
        record.Add("C", "Carrots");
        service.Port      = 8080;
        service.TxtRecord = record;
        service.RegisterAsync();

        // Listen for events of some service type
        ServiceBrowser browser = new ServiceBrowser("_daap._tcp");

        browser.ServiceAdded   += OnServiceAdded;
        browser.ServiceRemoved += OnServiceRemoved;
        browser.StartAsync();

        // Unregister our service in 10 seconds
        GLib.Timeout.Add(10000, delegate {
            service.Dispose();
            return(false);
        });

        // Stop browsing and quit in 15 seconds
        GLib.Timeout.Add(15000, delegate {
            browser.Dispose();
            Application.Quit();
            return(false);
        });

        Application.Run();
    }
コード例 #6
0
ファイル: Program.cs プロジェクト: ppumkin/HomeKit
        private static void StartBonjourService()
        {
            RegisterService service = new RegisterService();

            service.Name        = ServiceName;
            service.RegType     = "_hap._tcp";
            service.ReplyDomain = "local.";
            service.Port        = unchecked ((short)PORT); //documentated work around
                                                           // TxtRecords are optional
            TxtRecord txt_record = new TxtRecord();

            txt_record.Add("c#", "1");
            txt_record.Add("ff", "0");
            txt_record.Add("id", "22:32:43:54:54:01");
            txt_record.Add("md", ServiceName);
            txt_record.Add("pv", "1.0");
            txt_record.Add("s#", "1");
            txt_record.Add("sf", "1");
            txt_record.Add("ci", "2");

            service.TxtRecord = txt_record;

            service.Response += OnRegisterServiceResponse;
            service.Register();

            //ServiceBrowser browser = new ServiceBrowser();
            //browser.ServiceAdded += delegate (object o, ServiceBrowseEventArgs aargs)
            //{
            //    Console.WriteLine("Found Service: {0}", aargs.Service.Name);

            //    aargs.Service.Resolved += delegate (object oo, ServiceResolvedEventArgs argss)
            //    {
            //        IResolvableService s = (IResolvableService)argss.Service;
            //        Console.WriteLine("Resolved Service: {0} - {1}:{2} ({3} TXT record entries)",
            //            s.FullName, s.HostEntry.AddressList[0], s.Port, s.TxtRecord.Count);
            //    };

            //    aargs.Service.Resolve();
            //};

            //browser.Browse("_hap._tcp", "local");
        }
コード例 #7
0
        public void Register(ushort backup_port, ushort notify_port, ushort rest_port, string server_id, bool is_accepting, bool home_sharing)
        {
            m_svc.Name        = Environment.MachineName;
            m_svc.Port        = (short)backup_port;
            m_svc.RegType     = SVC_TYPE;
            m_svc.ReplyDomain = "local.";

            var txt = new TxtRecord();

            txt.Add("server_id", server_id);
            txt.Add("ws_port", backup_port.ToString());
            txt.Add("notify_port", notify_port.ToString());
            txt.Add("rest_port", rest_port.ToString());
            txt.Add("version", "1.0");
            txt.Add("service_name", ServiceName);
            txt.Add("waiting_for_pair", is_accepting ? "true" : "false");
            txt.Add("home_sharing", home_sharing ? "true" : "false");
            m_svc.TxtRecord = txt;
            m_svc.Register();
        }
コード例 #8
0
        /// <summary>
        /// Publish ZeroConf, so that WaveBox may advertise itself using mDNS to capable devices
        /// </summary>
        public bool Start()
        {
            string serverUrl = ServerUtility.GetServerUrl();

            if ((object)serverUrl == null)
            {
                logger.Error("Could not start ZeroConf service, due to null ServerUrl");
                return(false);
            }

            // If we're already registered, dispose of it and create a new one
            if ((object)ZeroConf != null)
            {
                this.Stop();
            }

            // Create and register the service
            try
            {
                ZeroConf             = new RegisterService();
                ZeroConf.Name        = Hostname;
                ZeroConf.RegType     = RegType;
                ZeroConf.ReplyDomain = ReplyDomain;
                ZeroConf.Port        = (short)Injection.Kernel.Get <IServerSettings>().Port;

                TxtRecord record = new TxtRecord();
                record.Add(ServerUrlKey, serverUrl);
                ZeroConf.TxtRecord = record;

                ZeroConf.Register();
            }
            catch (Exception e)
            {
                logger.Error(e);
                this.Stop();
                return(false);
            }

            return(true);
        }
コード例 #9
0
ファイル: GiverService.cs プロジェクト: tcausby/giver
        private void AdvertiseService()
        {
            try {
                Logger.Debug("Adding Zeroconf Service _giver._tcp");
                TxtRecord txt = new TxtRecord();

                txt.Add("User Name", Application.Preferences.UserName);
                txt.Add("Machine Name", Environment.MachineName);
                txt.Add("Version", Defines.Version);

                if (Application.Preferences.PhotoType.CompareTo(Preferences.Local) == 0)
                {
                    txt.Add("PhotoType", Preferences.Local);
                    txt.Add("Photo", "none");
                }
                else if (Application.Preferences.PhotoType.CompareTo(Preferences.Gravatar) == 0)
                {
                    txt.Add("PhotoType", Preferences.Gravatar);
                    txt.Add("Photo", Giver.Utilities.GetMd5Sum(Application.Preferences.PhotoLocation));
                }
                else if (Application.Preferences.PhotoType.CompareTo(Preferences.Uri) == 0)
                {
                    txt.Add("PhotoType", Preferences.Uri);
                    txt.Add("Photo", Application.Preferences.PhotoLocation);
                }
                else
                {
                    txt.Add("PhotoType", Preferences.None);
                    txt.Add("Photo", "none");
                }

                client.Name        = "giver on " + Application.Preferences.UserName + "@" + Environment.MachineName;
                client.RegType     = "_giver._tcp";
                client.ReplyDomain = "local.";
                client.Port        = (short)port;
                client.TxtRecord   = txt;

                client.Register();
                Logger.Debug("Avahi Service  _giver._tcp is added");
            } catch (Exception e) {
                Logger.Debug("Exception adding service: {0}", e.Message);
                Logger.Debug("Exception is: {0}", e);
            }
        }