Пример #1
0
        private void StreamerListLoaded(object sender, EventArgs e)
        {
            browserList.Items.Clear();

            nsBrowser = new NetServiceBrowser();
            nsBrowser.InvokeableObject      = this;
            nsBrowser.DidFindService       += new NetServiceBrowser.ServiceFound(nsBrowser_DidFindService);
            nsBrowser.DidRemoveService     += new NetServiceBrowser.ServiceRemoved(nsBrowser_DidRemoveService);
            nsBrowser.AllowApplicationForms = true;
            nsBrowser.SearchForService(DisplayCastGlobals.STREAMER, DisplayCastGlobals.BONJOURDOMAIN);

            using (RegistryKey dcs = Registry.CurrentUser.CreateSubKey("Software").CreateSubKey("FXPAL").CreateSubKey("DisplayCast").CreateSubKey("Player")) {
                myName.Text = dcs.GetValue("Name").ToString();
            }

            if (myMac == null)
            {
                locationDisclose.Enabled = false;
            }
            else
            {
                locationDisclose.Checked = discloseLocation;
            }

            /*
             * if (locationDisclose.Checked) {
             *  object[] pList = { "ALL", System.EventArgs.Empty };
             *  browserList.BeginInvoke(new System.EventHandler(monitorMyLocation), pList);
             * }
             */
        }
Пример #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sessions">Array of sessions: shared with API APIresponder</param>
        /// <param name="players">Array of players: shared with API APIresponder</param>
        /// <param name="streamers">Array of streamers: shared with API APIresponder</param>
        /// <param name="archivers">Array of archivers: shared with API APIresponder</param>
        /// <param name="sinkServices">Array of netservice sinks: shared with API APIresponder</param>
        /// <param name="sourceServices">Array of netservice sources: shared with API APIresponder</param>
        public monitorPlayers(ArrayList sessions, ArrayList players, ArrayList streamers, ArrayList archivers, ArrayList sinkServices, ArrayList sourceServices)
        {
            this.sessions       = sessions;
            this.players        = players;
            this.streamers      = streamers;
            this.archivers      = archivers;
            this.sinkServices   = sinkServices;
            this.sourceServices = sourceServices;

            // Start browsing for Players/Streamers and Archivers
            playerBrowser = new NetServiceBrowser();
            playerBrowser.AllowMultithreadedCallbacks = true;
            playerBrowser.DidFindService   += new NetServiceBrowser.ServiceFound(didFindPlayers);
            playerBrowser.DidRemoveService += new NetServiceBrowser.ServiceRemoved(didRemovePlayers);
            playerBrowser.SearchForService(Shared.DisplayCastGlobals.PLAYER, Shared.DisplayCastGlobals.BONJOURDOMAIN);

            streamerBrowser = new NetServiceBrowser();
            streamerBrowser.AllowMultithreadedCallbacks = true;
            streamerBrowser.DidFindService   += new NetServiceBrowser.ServiceFound(didFindPlayers);
            streamerBrowser.DidRemoveService += new NetServiceBrowser.ServiceRemoved(didRemovePlayers);
            streamerBrowser.SearchForService(Shared.DisplayCastGlobals.STREAMER, Shared.DisplayCastGlobals.BONJOURDOMAIN);

            archiveBrowser = new NetServiceBrowser();
            archiveBrowser.AllowMultithreadedCallbacks = true;
            archiveBrowser.DidFindService   += new NetServiceBrowser.ServiceFound(didFindPlayers);
            archiveBrowser.DidRemoveService += new NetServiceBrowser.ServiceRemoved(didRemovePlayers);
            archiveBrowser.SearchForService(Shared.DisplayCastGlobals.ARCHIVER, Shared.DisplayCastGlobals.BONJOURDOMAIN);
        }
Пример #3
0
        private void startStopButton_Click(object sender, EventArgs e)
        {
            if (!mBrowsing)
            {
                try
                {
                    Debug.WriteLine(String.Format("Bonjour Version: {0}", NetService.DaemonVersion));
                }
                catch (Exception ex)
                {
                    String message = ex is DNSServiceException ? "Bonjour is not installed!" : ex.Message;
                    MessageBox.Show(message, "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Application.Exit();
                }
            }

            if (!mBrowsing)
            {
                string service = serviceTextBox.Text;

                try
                {
                    nsBrowser.SearchForService(service, "");
                    mBrowsing = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Critical Error");
                }
            }
            else
            {
                nsBrowser.Stop();

                if (resolvingService != null)
                {
                    resolvingService.Stop();
                    resolvingService = null;
                }
                ClearTXTInfo();
                ClearResolveInfo();

                servicesList.BeginUpdate();
                servicesList.Items.Clear();
                servicesList.EndUpdate();

                mBrowsing = false;
            }

            if (mBrowsing)
            {
                startStopButton.Text = "Stop";
            }
            else
            {
                startStopButton.Text = "Start";
            }
        }
Пример #4
0
        public void StartDiscovery(EntryFoundCallback callback)
        {
            foundCallback = callback;

            browser = new NetServiceBrowser();
            browser.AllowMultithreadedCallbacks = true;
            browser.DidFindService += new NetServiceBrowser.ServiceFound(ZeroconfDiscoverFoundService);
            browser.SearchForService(SET_SERVICE_TYPE, DOMAIN);
        }
Пример #5
0
 public void StartServiceSearch(params WebService[] service)
 {
     browser = new NetServiceBrowser();
     browser.AllowMultithreadedCallbacks = true;
     browser.DidFindService   += new NetServiceBrowser.ServiceFound(DiscoverFoundService);
     browser.DidRemoveService += new NetServiceBrowser.ServiceRemoved(DiscoverRemovedService);
     foreach (var srv in service)
     {
         browser.SearchForService(serviceTypes[srv], DOMAIN);
     }
 }
Пример #6
0
        public void Start()
        {
            if (browser == null)
            {
                browser = new NetServiceBrowser();
                browser.AllowMultithreadedCallbacks = true;
                browser.DidFindService   += browser_DidFindService;
                browser.DidRemoveService += browser_DidRemoveService;
                browser.SearchForService("_dacp._tcp.", "");

                lock (serverInfoLock)
                    serverInfos = new Dictionary <string, NetService>();
            }
        }
Пример #7
0
        private void startBrowsing()
        {
            if (!mBrowsing)
            {
                try
                {
                    Debug.WriteLine(String.Format("Bonjour Version: {0}", NetService.DaemonVersion));
                }
                catch (Exception ex)
                {
                    String message = ex is DNSServiceException ? "Bonjour is not installed!" : ex.Message;
                    MessageBox.Show(message, "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Application.Exit();
                }
            }

            if (!mBrowsing)
            {
                string service = "_airmagic._tcp";
                try
                {
                    nsBrowser.SearchForService(service, "");
                    mBrowsing = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Critical Error");
                }
            }
            else
            {
                nsBrowser.Stop();

                if (resolvingService != null)
                {
                    resolvingService.Stop();
                    resolvingService = null;
                }


                mBrowsing = false;
            }

            if (mBrowsing)
            {
            }
            else
            {
            }
        }
        /// <summary>
        /// Constructor creates the mDNS service listener.
        /// </summary>
        public DACPPairingServer(DACPServer server)
        {
            Console.WriteLine("Initializing DACPPairingServer...");
            this.dacpServer = server;
            nsBrowser.AllowMultithreadedCallbacks = true;
            nsBrowser.DidFindService   += new NetServiceBrowser.ServiceFound(NetServiceBrowser_DidFindService);
            nsBrowser.DidRemoveService += new NetServiceBrowser.ServiceRemoved(NetServiceBrowser_DidRemoveService);

            try {
                Console.WriteLine("mDNS Version: {0}", NetService.DaemonVersion);
                nsBrowser.SearchForService(SERVICE_TYPE, "");
            } catch (Exception ex) {
                Console.WriteLine("Apple Bonjour is not installed!", ex);
                throw new DACPBonjourException("Bonjour is required by this application and it was not found.  Please install Bonjour For Windowsfrom Apple.com");
            }
        }
Пример #9
0
        /// <summary>
        /// Search for services of the specified type in the specified domain.
        /// </summary>
        /// <param name="type">
        /// Type of the services to search for.
        /// <para>
        /// `type` must contain both the service type and transport layer information. To
        /// ensure that the mDNS responder searches for services, as opposed to hosts,
        /// prefix both the service name and transport layer name with an underscore
        /// character ("_"). For example, to search for an HTTP service on TCP, you would
        /// use the type string `@"_http._tcp."`. Note that the period character at the end
        /// of the string, which indicates that the domain name is an absolute name, is
        /// required. It will be automatically set if it does not exists.
        /// </para>
        /// </param>
        /// <param name="domain">Domain name in which to perform the search.</param>
        public bool SearchForServices(String type, String domain)
        {
            if (!type.EndsWith("."))
            {
                type += ".";
            }

            String key = this.KeyForSearch(type, domain);

            if (this.IsSearching)
            {
                if (netServiceBrowsers.ContainsKey(key))
                {
                    logger.TraceEvent(TraceEventType.Warning, 0, String.Format("Already searching for type {0} in domain {1}", type, domain));
                    return(false);
                }
            }

            this.IsSearching = true;

            NetServiceBrowser netServiceBrowser = new NetServiceBrowser();

            netServiceBrowser.AllowApplicationForms       = false;
            netServiceBrowser.AllowMultithreadedCallbacks = true;

            netServiceBrowser.DidFindDomain    += new NetServiceBrowser.DomainFound(NetServiceBrowserDidFindDomain);
            netServiceBrowser.DidRemoveDomain  += new NetServiceBrowser.DomainRemoved(NetServiceBrowserDidRemoveDomain);
            netServiceBrowser.DidFindService   += new NetServiceBrowser.ServiceFound(NetServiceBrowserDidFindService);
            netServiceBrowser.DidRemoveService += new NetServiceBrowser.ServiceRemoved(NetServiceBrowserDidRemoveService);

            netServiceBrowsers[key] = netServiceBrowser;

            netServiceBrowser.SearchForService(type, domain);

            logger.TraceEvent(TraceEventType.Information, 0, String.Format("Search started for type {0} in domain {1}", type, domain));

            return(true);
        }
Пример #10
0
        public Remote()
        {
            InitializeComponent();

            // Bonjour check
            try
            {
                logWindow.Log = String.Format("Bonjour Version: {0}", NetService.DaemonVersion);
                useBonjour    = true;
            }
            catch (Exception ex)
            {
                String message = ex is DNSServiceException ? "Bonjour is not installed!" : ex.Message;
                MessageBox.Show(message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                useBonjour = false;
            }

            // Start browsing bonjour for WifiRemote service
            if (useBonjour)
            {
                listBoxServers.DataSource    = servers;
                listBoxServers.DisplayMember = "Name";

                bonjourBrowser.InvokeableObject  = this;
                bonjourBrowser.DidFindService   += new NetServiceBrowser.ServiceFound(bonjourBrowser_DidFindService);
                bonjourBrowser.DidRemoveService += new NetServiceBrowser.ServiceRemoved(bonjourBrowser_DidRemoveService);

                try
                {
                    bonjourBrowser.SearchForService(serviceType, domain);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Critical Error");
                }
            }
        }
Пример #11
0
 void _browser_DidFindDomain(NetServiceBrowser browser, string domainName, bool moreComing)
 {
     _browser.SearchForService("_plexmediasvr._tcp", domainName);
 }
Пример #12
0
        /// <summary>
        ///
        /// </summary>
        public StreamerList()
        {
            InitializeComponent();

#if PLAYER_TASKBAR
            this.ShowInTaskbar = false;

            streamersItem      = new System.Windows.Forms.MenuItem();
            streamersItem.Text = "W&atch Streamer";
            streamersItem.MenuItems.Add("-");

            MSE   = new QueryMSE();
            myMac = getWIFIMACAddress();

            /* if (myMac == null)
             *  myMac = displaycast; */
            if (myMac != null)
            {
                locationItem      = new System.Windows.Forms.MenuItem();
                locationItem.Text = "Disclose location?";
                // locationItem.Index = 4;
                // playersItem.Index++;
                // archiversItem.Index++;
                locationItem.Click += new System.EventHandler(locationChecked);
                using (RegistryKey dcs = Registry.CurrentUser.CreateSubKey("Software").CreateSubKey("FXPAL").CreateSubKey("DisplayCast").CreateSubKey("Streamer")) {
                    locationItem.Checked = Convert.ToBoolean(dcs.GetValue("discloseLocation"));
                }
                discloseLocation = locationItem.Checked;

                locThread = new Thread(new ThreadStart(monitorMyLocation));
                locThread.Start();
            }

            changeNameItem        = new System.Windows.Forms.MenuItem();
            changeNameItem.Text   = "C&hange Name";
            changeNameItem.Click += new System.EventHandler(changeName);

            aboutItem        = new System.Windows.Forms.MenuItem();
            aboutItem.Text   = "A&bout...";
            aboutItem.Click += new System.EventHandler(about);

            exitItem        = new System.Windows.Forms.MenuItem();
            exitItem.Text   = "E&xit";
            exitItem.Click += new System.EventHandler(exitItem_Click);

            contextMenu = new System.Windows.Forms.ContextMenu();

            contextMenu.MenuItems.Add(streamersItem);
            contextMenu.MenuItems.Add("-");

            if (locationItem != null)
            {
                contextMenu.MenuItems.Add(locationItem);
            }

            contextMenu.MenuItems.Add(changeNameItem);

            contextMenu.MenuItems.Add("-");
            contextMenu.MenuItems.Add(aboutItem);

            contextMenu.MenuItems.Add("-");
            contextMenu.MenuItems.Add(exitItem);

            iComponents     = new System.ComponentModel.Container();
            notifyIcon      = new NotifyIcon(iComponents);
            notifyIcon.Icon = new Icon("Player.ico");
            // notifyIcon.Icon = Streamer.Properties.Resources.Streamer;
            // notifyIcon.Icon = new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("FXPAL.DisplayCast.Streamer.Streamer.ico"));

            notifyIcon.ContextMenu  = contextMenu;
            notifyIcon.Text         = "FXPAL Displaycast Player";
            notifyIcon.Visible      = true;
            notifyIcon.DoubleClick += new System.EventHandler(this.notifyIcon_DoubleClick);

            nsBrowser = new NetServiceBrowser();
            nsBrowser.InvokeableObject      = this;
            nsBrowser.DidFindService       += new NetServiceBrowser.ServiceFound(nsBrowser_DidFindService);
            nsBrowser.DidRemoveService     += new NetServiceBrowser.ServiceRemoved(nsBrowser_DidRemoveService);
            nsBrowser.AllowApplicationForms = true;
            nsBrowser.SearchForService(Shared.DisplayCastGlobals.STREAMER, Shared.DisplayCastGlobals.BONJOURDOMAIN);
#endif
        }
Пример #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="publishService"></param>
        /// <param name="TXTrecords"></param>
        /// <param name="id"></param>
        public Console(NetService publishService, Hashtable TXTrecords, String id)
        {
            InitializeComponent();

#if USE_BLUETOOTH
            // If Bluetooth is supported, then scan for nearby players
            if (BluetoothRadio.IsSupported)
            {
                try {
                    bt = new BluetoothComponent();

                    bt.DiscoverDevicesComplete += new EventHandler <DiscoverDevicesEventArgs>(discoverComplete);
                    bt.DiscoverDevicesAsync(100, true, true, true, true, null);
                } catch {
                    if (bt != null)
                    {
                        bt.Dispose();
                    }
                    // Something is wrong with bluetooth module
                }
            }
#endif

            this.publishService = publishService;
            this.TXTrecords     = TXTrecords;
            this.id             = id;

            playersItem      = new System.Windows.Forms.MenuItem();
            playersItem.Text = "P&roject Me";
            playersItem.MenuItems.Add("-");

            archiversItem      = new System.Windows.Forms.MenuItem();
            archiversItem.Text = "A&rchive Me";
            archiversItem.MenuItems.Add("-");

#if USE_WIFI_LOCALIZATION
            MSE   = new QueryMSE();
            myMac = getWIFIMACAddress();

            /* if (myMac == null)
             *  myMac = displaycast; */
            if (myMac != null)
            {
                locationItem      = new System.Windows.Forms.MenuItem();
                locationItem.Text = "Disclose location?";
                // locationItem.Index = 4;
                // playersItem.Index++;
                // archiversItem.Index++;
                locationItem.Click += new System.EventHandler(locationChecked);
                using (RegistryKey dcs = Registry.CurrentUser.CreateSubKey("Software").CreateSubKey("FXPAL").CreateSubKey("DisplayCast").CreateSubKey("Streamer")) {
                    locationItem.Checked = Convert.ToBoolean(dcs.GetValue("discloseLocation"));
                }
                discloseLocation = locationItem.Checked;

                locThread = new Thread(new ThreadStart(monitorMyLocation));
                locThread.Start();
            }
#endif

            Screen[] screens = Screen.AllScreens;
            if (screens.Length > 1)
            {
                desktopItem      = new System.Windows.Forms.MenuItem();
                desktopItem.Text = "D&esktop to stream";

                desktopItem.MenuItems.Add("-");
                foreach (Screen screen in screens)
                {
                    MenuItem item = new MenuItem();
                    System.Drawing.Rectangle bounds = screen.Bounds;

                    item.Text    = "DESKTOP: " + bounds.X + "x" + bounds.Y + " " + bounds.Width + "x" + bounds.Height;
                    item.Click  += new System.EventHandler(selectDesktop);
                    item.Select += new System.EventHandler(selectDesktop);
                    item.Tag     = screen;

                    desktopItem.MenuItems.Add(item);
                }
            }

            changeNameItem        = new System.Windows.Forms.MenuItem();
            changeNameItem.Text   = "C&hange Name";
            changeNameItem.Click += new System.EventHandler(changeName);

            aboutItem        = new System.Windows.Forms.MenuItem();
            aboutItem.Text   = "A&bout...";
            aboutItem.Click += new System.EventHandler(about);

            exitItem        = new System.Windows.Forms.MenuItem();
            exitItem.Text   = "E&xit";
            exitItem.Click += new System.EventHandler(exitItem_Click);

            contextMenu = new System.Windows.Forms.ContextMenu();

            contextMenu.MenuItems.Add(playersItem);
            contextMenu.MenuItems.Add(archiversItem);
            contextMenu.MenuItems.Add("-");

            if (locationItem != null)
            {
                contextMenu.MenuItems.Add(locationItem);
            }

            if (desktopItem != null)
            {
                contextMenu.MenuItems.Add(desktopItem);
            }
            contextMenu.MenuItems.Add(changeNameItem);

            contextMenu.MenuItems.Add("-");
            contextMenu.MenuItems.Add(aboutItem);

            contextMenu.MenuItems.Add("-");
            contextMenu.MenuItems.Add(exitItem);

            iComponents     = new System.ComponentModel.Container();
            notifyIcon      = new NotifyIcon(iComponents);
            notifyIcon.Icon = new Icon("Streamer.ico");
            // notifyIcon.Icon = Streamer.Properties.Resources.Streamer;
            // notifyIcon.Icon = new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("FXPAL.DisplayCast.Streamer.Streamer.ico"));

            notifyIcon.ContextMenu  = contextMenu;
            notifyIcon.Text         = "FXPAL Displaycast Streamer";
            notifyIcon.Visible      = true;
            notifyIcon.DoubleClick += new System.EventHandler(this.notifyIcon_DoubleClick);

            player = new NetServiceBrowser();
            //player.InvokeableObject = this;
            player.AllowMultithreadedCallbacks = true;
            player.DidFindService   += new NetServiceBrowser.ServiceFound(nsBrowser_DidFindService);
            player.DidRemoveService += new NetServiceBrowser.ServiceRemoved(nsBrowser_DidRemoveService);
            player.SearchForService(Shared.DisplayCastGlobals.PLAYER, Shared.DisplayCastGlobals.BONJOURDOMAIN);

            archiver = new NetServiceBrowser();
            // archiver.InvokeableObject = this;
            archiver.AllowMultithreadedCallbacks = true;
            archiver.DidFindService   += new NetServiceBrowser.ServiceFound(nsBrowser_DidFindService);
            archiver.DidRemoveService += new NetServiceBrowser.ServiceRemoved(nsBrowser_DidRemoveService);
            archiver.SearchForService(Shared.DisplayCastGlobals.ARCHIVER, Shared.DisplayCastGlobals.BONJOURDOMAIN);
        }