Example #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);
        }
Example #2
0
        void nsBrowser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing)
        {
            Debug.WriteLine(String.Format("{0}: nsBrowser_DidFindService: {1}", System.Threading.Thread.CurrentThread.ManagedThreadId, service.Name));

            service.DidUpdateTXT += new NetService.ServiceTXTUpdated(ns_DidUpdateTXT);
            service.DidResolveService += new NetService.ServiceResolved(ns_DidResolveService);

            service.StartMonitoring();

            ListViewItem item = new ListViewItem(service.Name);
            item.Tag = service;

            if (moreComing)
            {
                waitingAdd.Add(item);
            }
            else
            {
                servicesList.BeginUpdate();
                while (waitingAdd.Count > 0)
                {
                    servicesList.Items.Add((ListViewItem)waitingAdd[0]);
                    waitingAdd.RemoveAt(0);
                }
                servicesList.Items.Add(item);
                servicesList.EndUpdate();
            }
        }
        public ServerSelector()
        {
            InitializeComponent();

            _browser = new NetServiceBrowser();
            _browser.DidFindDomain += new NetServiceBrowser.DomainFound(_browser_DidFindDomain);
            _browser.DidFindService += new NetServiceBrowser.ServiceFound(_browser_DidFindService);
            _browser.SearchForBrowseableDomains();
        }
Example #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);
        }
        public ServerSelector()
        {
            InitializeComponent();

            _browser = new NetServiceBrowser();
            _browser.DidFindDomain += new NetServiceBrowser.DomainFound(_browser_DidFindDomain);
            _browser.DidFindService += new NetServiceBrowser.ServiceFound(_browser_DidFindService);
            try
            { _browser.SearchForBrowseableDomains(); }
            catch
            {
                MessageBox.Show("Couldn't locate servers via Bonjour.");
            }
        }
        void nsBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing)
        {
            servicesList.BeginUpdate();

            foreach (ServiceListEntry item in servicesList.Items)
            {
                if (item.Service == service)
                {
                    servicesList.Items.Remove(item);
                    break;
                }
            }

            servicesList.EndUpdate();
        }
        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");
            }
        }
 void _browser_DidFindDomain(NetServiceBrowser browser, string domainName, bool moreComing)
 {
     _browser.SearchForService("_plexmediasvr._tcp", domainName);
 }
Example #9
0
 public void p2p_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing)
 {
     foreach (TreeNode item in tnPeer2Peer.Nodes)
     {
         if (item.Text == service.Name)
             tnPeer2Peer.Nodes.Remove(item);
     }
 }
 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);
     }
 }
Example #11
0
 /// <summary>
 /// Bonjour service vanished
 /// </summary>
 /// <param name="browser"></param>
 /// <param name="service"></param>
 /// <param name="moreComing"></param>
 void bonjourBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing)
 {
     servers.Remove(service);
     if (servers.Count == 0)
     {
         buttonConnectDetected.Enabled = false;
     }
 }
Example #12
0
 protected void NetServiceBrowserDidRemoveService(NetServiceBrowser aNetServiceBrowser, NetService netService, bool moreComing)
 {
     logger.TraceEvent(TraceEventType.Verbose, 0, String.Format("{0}: didRemoveService: {1}", aNetServiceBrowser, netService));
     SDService service = new SDService(netService.Name, netService.HostName, (ushort)netService.Port, netService.Type, null);
     OnServiceLost(service);
 }
Example #13
0
 protected void NetServiceBrowserDidFindService(NetServiceBrowser aNetServiceBrowser, NetService netService, bool moreComing)
 {
     logger.TraceEvent(TraceEventType.Information, 0, String.Format("{0}: didFindService: {1}", aNetServiceBrowser, netService));
     netService.DidUpdateTXT += new NetService.ServiceTXTUpdated(NetServiceDidUpdateTXTRecordData);
     netService.DidResolveService += new NetService.ServiceResolved(NetServiceDidResolveAddress);
     netService.DidNotResolveService += new NetService.ServiceNotResolved(NetServiceDidNotResolve);
     netService.ResolveWithTimeout(10);
 }
Example #14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="browser"></param>
        /// <param name="service"></param>
        /// <param name="moreComing"></param>
        void nsBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing) {
            ArrayList itemsToRemove = new ArrayList();

#if PLAYER_TASKBAR
            foreach (MenuItem item in streamersItem.MenuItems) {
                if (item.Tag == service)
                    itemsToRemove.Add(item);
            }

            foreach (MenuItem item in itemsToRemove) {
                streamersItem.MenuItems.Remove(item);

                while (true) {
                    Streamer toDelete = null;

                    foreach (Streamer strm in streamers) {
                        if (strm.id.Equals(service.Name)) {
                            strm.Close();
                            toDelete = strm;
                            break;
                        }
                    }

                    if (toDelete != null)
                        streamers.Remove(toDelete);
                    else
                        break;
                }
            }

            itemsToRemove.Clear();
#else
            browserList.BeginUpdate();
            
            foreach (ListViewItem item in browserList.Items) {
                if (item.Tag == service)
                    itemsToRemove.Add(item);
            }
            
            foreach (ListViewItem item in itemsToRemove) {
                browserList.Items.Remove(item);

                while (true) {
                    Streamer toDelete = null;

                    foreach (Streamer strm in streamers) {
                        if (strm.id.Equals(service.Name)) {
                            strm.Close();
                            toDelete = strm;
                            break;
                        }
                    }

                    if (toDelete != null)
                        streamers.Remove(toDelete);
                    else
                        break;
                }
            }

            itemsToRemove.Clear();
            browserList.EndUpdate();
#endif
            service.Dispose();
        }
Example #15
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);
            }
             */
        }
Example #16
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
        }
Example #17
0
        /// <summary>
        /// Bonjour callback - cleanup removed services
        /// </summary>
        /// <param name="browser"></param>
        /// <param name="service"></param>
        /// <param name="moreComing"></param>
        private void didRemovePlayers(NetServiceBrowser browser, NetService service, bool moreComing)
        {
            // First remove from list of known players/streamers/archivers
            ArrayList list = getList(service.Type);
            if (list == null)
                return;

            ArrayList itemsToRemove = new ArrayList();
            lock (list.SyncRoot) {
                foreach (JSONSrcSink player in list) {
                    if (player.id.Equals(service.Name)) {
                        itemsToRemove.Add(player);
                        break;
                    }
                }
                if (itemsToRemove.Count > 0) {
                    foreach (JSONSrcSink player in itemsToRemove)
                        list.Remove(player);
                    itemsToRemove.Clear();
                    return;
                }
            }

            // now remove the services
            if (service.Type.StartsWith(Shared.DisplayCastGlobals.PLAYER) || service.Type.StartsWith(Shared.DisplayCastGlobals.ARCHIVER))
                lock(sinkServices.SyncRoot)
                    sinkServices.Remove(service);
            if (service.Type.StartsWith(Shared.DisplayCastGlobals.STREAMER))
                lock (sourceServices.SyncRoot)
                    sourceServices.Remove(service);

            service.Stop();
        }
Example #18
0
 /// <summary>
 /// Bonjour callback. We don't remember services until they are resolved
 /// </summary>
 /// <param name="browser"></param>
 /// <param name="service"></param>
 /// <param name="moreComing"></param>
 private void didFindPlayers(NetServiceBrowser browser, NetService service, bool moreComing)
 {
     service.DidResolveService += new NetService.ServiceResolved(didResolvePlayers);
     service.ResolveWithTimeout(5);
 }
Example #19
0
 void nsBrowser_DidFindDomain(NetServiceBrowser browser, string domainName, bool moreComing)
 {
     Debug.WriteLine(browser, domainName);
 }
 void _browser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing)
 {
     service.DidResolveService += new NetService.ServiceResolved(service_DidResolveService);
     service.ResolveWithTimeout(60);
 }
Example #21
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;
        }
Example #22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="browser"></param>
        /// <param name="service"></param>
        /// <param name="moreComing"></param>
        void nsBrowser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing) {
            service.DidResolveService += new NetService.ServiceResolved(ns_DidResolveService);

            Trace.WriteLine("DEBUG: Found - " + service.Name + ". Resolving...");
            service.ResolveWithTimeout(5);
         }
Example #23
0
 protected void NetServiceBrowserDidRemoveDomain(NetServiceBrowser aNetServiceBrowser, string domainString, bool moreComing)
 {
     logger.TraceEvent(TraceEventType.Verbose, 0, String.Format("{0}: didRemoveDomain: {1}", aNetServiceBrowser, domainString));
 }
Example #24
0
 P2PDB()
 {
     nsBrowser = new NetServiceBrowser();
 }
Example #25
0
 /// <summary>
 /// Did find bonjour service
 /// </summary>
 /// <param name="browser"></param>
 /// <param name="service"></param>
 /// <param name="moreComing"></param>
 void bonjourBrowser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing)
 {
     service.DidResolveService += new NetService.ServiceResolved(Remote_DidResolveService);
     service.ResolveWithTimeout(5);
 }
Example #26
0
        void nsBrowser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing)
        {
            ListViewItem item = new ListViewItem(service.Name);
            item.Tag = service;

            if (moreComing)
            {
                waitingAdd.Add(item);
            }
            else
            {
                servicesList.BeginUpdate();
                while (waitingAdd.Count > 0)
                {
                    servicesList.Items.Add((ListViewItem)waitingAdd[0]);
                    waitingAdd.RemoveAt(0);
                }
                servicesList.Items.Add(item);
                servicesList.EndUpdate();
            }
        }
 private void DiscoverFoundService(NetServiceBrowser browser, NetService service, bool moreComing)
 {
     service.DidResolveService += new NetService.ServiceResolved(DiscoverResolvedService);
     service.ResolveWithTimeout(TIMEOUT);
 }
Example #28
0
        void nsBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing)
        {
            servicesList.BeginUpdate();

            foreach (ListViewItem item in servicesList.Items)
            {
                if (item.Tag == service)
                    servicesList.Items.Remove(item);
            }

            servicesList.EndUpdate();
        }
 private void DiscoverRemovedService(NetServiceBrowser browser, NetService service, bool moreComing)
 {
     HandleDiscoverEvent(service, "Disappearing", ServiceDisappeared);
 }
Example #30
0
        public void p2p_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing)
        {
            if (service.Name != System.Environment.MachineName)
            {
                for (int i = tnPeer2Peer.Nodes.Count - 1; i >= 0; i--)
                {
                    TreeNode node = tnPeer2Peer.Nodes[i];

                    if (node.Text == service.Name)
                        node.Remove();
                }

                TreeNode newNode = new TreeNode(service.Name, 5, 5);
                newNode.Tag = service;
                tnPeer2Peer.Nodes.Add(newNode);
            }
        }