public ServerSelector() { InitializeComponent(); _browser = new NetServiceBrowser(); _browser.DidFindDomain += new NetServiceBrowser.DomainFound(_browser_DidFindDomain); _browser.DidFindService += new NetServiceBrowser.ServiceFound(_browser_DidFindService); _browser.SearchForBrowseableDomains(); }
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); }
private void StartServiceBrowser() { _browser = new NetServiceBrowser(); _browser.ServiceFound += _browser_ServiceFound; _browser.ServiceRemoved += _browser_ServiceRemoved; _browser.SearchForServices("_touch-able._tcp.local."); browseStartButton.IsEnabled = false; browseStopButton.IsEnabled = true; }
void browser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing) { lock (serverInfoLock) { if (serverInfos != null) { serverInfos.Remove(service.Name); Logger.Debug("RemoteHandler: Removed service - {0}", service.Name); } } }
public void Stop() { if (browser != null) { browser.Stop(); browser = null; lock (serverInfoLock) serverInfos = null; } }
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); } }
/// <summary> /// Callback for when a service is removed from the browser /// </summary> /// <param name="browser">the NetServiceBrowser browsing for services</param> /// <param name="service">the Service removed</param> /// <param name="moreComing">true if more services are coming</param> private void NetServiceBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing) { Console.WriteLine("NetServiceBrowser_DidRemoveService: {0}", service.Name); services.Remove(service.Name); service.Dispose(); if (!moreComing) { Console.WriteLine("No More coming so signal DACP Server we are done"); this.dacpServer.OnClientListChanged(); } }
/// <summary> /// /// </summary> /// <param name="browser"></param> /// <param name="service"></param> /// <param name="moreComing"></param> void nsBrowser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing) { // Service found. Need to resolve it to find the name if (resolvingNS == null) { resolvingNS = new ArrayList(); } resolvingNS.Add(service); // So that service is not garbage collected away service.DidResolveService += new NetService.ServiceResolved(nsBrowser_DidResolveService); service.ResolveWithTimeout(5); }
private void StartServiceBrowser() { StartBrowseButton.IsEnabled = false; _discoveredServices = new ObservableCollectionEx <string>(); PageViewSource["DiscoveredServices"] = _discoveredServices; _browser = new NetServiceBrowser(); _browser.ServiceFound += _browser_ServiceFound; _browser.ServiceRemoved += _browser_ServiceRemoved; _browser.SearchForServices("_touch-able._tcp.local"); StopBrowseButton.IsEnabled = true; }
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."); } }
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>(); } }
/// <summary> /// Callback for when a service is detected in the browser. /// </summary> /// <param name="browser">the NetServiceBrowser browsing for services</param> /// <param name="service">the Service found</param> /// <param name="moreComing">true if more services are coming</param> private void NetServiceBrowser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing) { Console.WriteLine("NetServiceBrowser_DidFindService: {0}", service.Name); service.DidResolveService += new NetService.ServiceResolved(NetService_DidResolveService); service.StartMonitoring(); services.Add(service.Name, service); service.ResolveWithTimeout(5); if (!moreComing) { Console.WriteLine("No More coming so signal DACP Server we are done"); } }
void nsBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing) { Debug.WriteLine(String.Format("{0}: nsBrowser_DidRemoveService: {1}", System.Threading.Thread.CurrentThread.ManagedThreadId, service.Name)); servicesList.BeginUpdate(); foreach (ListViewItem item in servicesList.Items) { if (item.Tag == service) { servicesList.Items.Remove(item); } } servicesList.EndUpdate(); service.Dispose(); }
/// <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(); }
public static void SearchForPairingUtility() { if (_pairingUtilityBrowser != null) { return; } _log.Info("Searching for pairing utility..."); _pairingUtilityBrowser = new NetServiceBrowser(); HookEvents(); // Begin searching for services if (NetworkManager.IsLocalNetworkAvailable) { _pairingUtilityBrowser.SearchForServices(PairingUtilityServiceName); } }
public static void StopSearchingForPairingUtility() { if (_pairingUtilityBrowser == null) { return; } _log.Info("Stopping search for pairing utility..."); UnhookEvents(); _pairingUtilityBrowser.Stop(); ThreadUtility.RunOnUIThread(() => { DiscoveredPairingUtilities.Clear(); }); _pairingUtilityBrowser = null; }
/// <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); }
/// <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); }
void _browser_DidFindDomain(NetServiceBrowser browser, string domainName, bool moreComing) { _browser.SearchForService("_plexmediasvr._tcp", domainName); }
/// <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); }
private void DiscoverRemovedService(NetServiceBrowser browser, NetService service, bool moreComing) { HandleDiscoverEvent(service, "Disappearing", ServiceDisappeared); }
/// <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 }
private void DiscoverFoundService(NetServiceBrowser browser, NetService service, bool moreComing) { service.DidResolveService += new NetService.ServiceResolved(DiscoverResolvedService); service.ResolveWithTimeout(TIMEOUT); }
/// <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); }
/// <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(); }
void _browser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing) { service.DidResolveService += new NetService.ServiceResolved(service_DidResolveService); service.ResolveWithTimeout(60); }
void browser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing) { Logger.Debug("RemoteHandler: Found service - {0}", service.Name); service.DidResolveService += service_DidResolveService; service.ResolveWithTimeout(10); }
/// <summary> /// /// </summary> /// <param name="browser"></param> /// <param name="service"></param> /// <param name="moreComing"></param> void nsBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing) { MenuItem items; Boolean player = false; if (service.Type.StartsWith(Shared.DisplayCastGlobals.PLAYER)) { items = playersItem; player = true; } else if (service.Type.StartsWith(Shared.DisplayCastGlobals.ARCHIVER)) { items = archiversItem; } else { return; } Trace.WriteLine("DEBUG: Removing service " + service.Name + " of type " + service.Type); ArrayList itemsToRemove = new ArrayList(); foreach (MenuItem item in items.MenuItems) { if (item == null) { continue; // WTF? } NetService iService = (NetService)item.Tag; if (resolvingNS.Contains(iService)) { resolvingNS.Remove(iService); } // Check for the separator item if (iService == null) { continue; } if (iService.Name.Equals(service.Name)) { itemsToRemove.Add(item); // Dec 5, 2011 iService.StopMonitoring(); iService.Stop(); if (player) { numPlayers--; } else { numArchivers--; } } } foreach (MenuItem item in itemsToRemove) { items.MenuItems.Remove(item); } itemsToRemove.Clear(); }
void nsBrowser_DidFindDomain(NetServiceBrowser browser, string domainName, bool moreComing) { Debug.WriteLine(browser, domainName); }
protected void NetServiceBrowserDidRemoveDomain(NetServiceBrowser aNetServiceBrowser, string domainString, bool moreComing) { logger.TraceEvent(TraceEventType.Verbose, 0, String.Format("{0}: didRemoveDomain: {1}", aNetServiceBrowser, domainString)); }