Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
        public RemoteControl()
        {
            InitializeComponent();

            try
            {
                nsBrowser = new NetServiceBrowser();
                nsBrowser.InvokeableObject = this;
                nsBrowser.DidFindService += new NetServiceBrowser.ServiceFound(nsBrowser_DidFindService);
                nsBrowser.DidRemoveService += new NetServiceBrowser.ServiceRemoved(nsBrowser_DidRemoveService);
                nsBrowser.SearchForService("_monitor_control._tcp", String.Empty);
            }
            catch
            {
                MessageBox.Show("Bonjour is not installed");
            }
        }
 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);
     }
 }
Esempio n. 5
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;
        }
Esempio n. 6
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);
            }
             */
        }
Esempio n. 7
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
        }
Esempio n. 8
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);
        }