/// <summary> /// Creates a search. /// </summary> /// <returns></returns> public virtual ISsdpSearch CreateSearch(bool requireUniqueLocation) { var search = new SsdpSearch(); var dict = new Dictionary<string, SsdpMessage>(); search.Filter = msg => { lock (dict) { // Restrict duplicate search responses based on location or UDN/USN // The reason for this is that there is potential for devices to share the same UDN // However, each unique location is definitely a separate result // And there's no potential for two devices to share the same location string key = (requireUniqueLocation ? msg.Location : msg.USN); if (dict.ContainsKey(key)) return false; dict.Add(key, msg); return true; } }; search.ResultFound += (sender, e) => { this.OnSsdpMessageReceived(sender, e); this.OnSearchResponse(sender, e); }; return search; }
/// <summary> /// Creates a search. /// </summary> /// <returns></returns> public virtual ISsdpSearch CreateSearch(bool requireUniqueLocation) { var search = new SsdpSearch(this.Sockets.ToArray()); var dict = new Dictionary <string, SsdpMessage>(); search.Filter = msg => { lock (dict) { // Restrict duplicate search responses based on location or UDN/USN // The reason for this is that there is potential for devices to share the same UDN // However, each unique location is definitely a separate result // And there's no potential for two devices to share the same location string key = (requireUniqueLocation ? msg.Location : msg.USN); if (dict.ContainsKey(key)) { return(false); } dict.Add(key, msg); return(true); } }; search.ResultFound += (sender, e) => { this.OnSsdpMessageReceived(sender, e); this.OnSearchResponse(sender, e); }; return(search); }