diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-08-24 15:52:19 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-08-24 15:52:19 -0400 |
| commit | e441e2f53db0b587c9864fe91d7008a2344d147b (patch) | |
| tree | c37b2148eb277671c7ee285c73b738542f279b22 /RSSDP/SsdpDeviceLocatorBase.cs | |
| parent | 5e0f8fd8c486ac37e487786c10c2d3f9e1293ce8 (diff) | |
update active recordings
Diffstat (limited to 'RSSDP/SsdpDeviceLocatorBase.cs')
| -rw-r--r-- | RSSDP/SsdpDeviceLocatorBase.cs | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/RSSDP/SsdpDeviceLocatorBase.cs b/RSSDP/SsdpDeviceLocatorBase.cs index 1adb95cdf..d1eaef88a 100644 --- a/RSSDP/SsdpDeviceLocatorBase.cs +++ b/RSSDP/SsdpDeviceLocatorBase.cs @@ -127,7 +127,7 @@ namespace Rssdp.Infrastructure } catch (Exception ex) { - + } } @@ -543,17 +543,9 @@ namespace Rssdp.Infrastructure } } - private IEnumerable<DiscoveredSsdpDevice> GetUnexpiredDevices() - { - lock (_Devices) - { - return (from device in _Devices where !device.IsExpired() select device).ToArray(); - } - } - private bool DeviceDied(string deviceUsn, bool expired) { - IEnumerable<DiscoveredSsdpDevice> existingDevices = null; + List<DiscoveredSsdpDevice> existingDevices = null; lock (_Devices) { existingDevices = FindExistingDeviceNotifications(_Devices, deviceUsn); @@ -565,7 +557,7 @@ namespace Rssdp.Infrastructure } } - if (existingDevices != null && existingDevices.Any()) + if (existingDevices != null && existingDevices.Count > 0) { foreach (var removedDevice in existingDevices) { @@ -591,12 +583,29 @@ namespace Rssdp.Infrastructure private static DiscoveredSsdpDevice FindExistingDeviceNotification(IEnumerable<DiscoveredSsdpDevice> devices, string notificationType, string usn) { - return (from d in devices where d.NotificationType == notificationType && d.Usn == usn select d).FirstOrDefault(); + foreach (var d in devices) + { + if (d.NotificationType == notificationType && d.Usn == usn) + { + return d; + } + } + return null; } - private static IEnumerable<DiscoveredSsdpDevice> FindExistingDeviceNotifications(IList<DiscoveredSsdpDevice> devices, string usn) + private static List<DiscoveredSsdpDevice> FindExistingDeviceNotifications(IList<DiscoveredSsdpDevice> devices, string usn) { - return (from d in devices where d.Usn == usn select d).ToArray(); + var list = new List<DiscoveredSsdpDevice>(); + + foreach (var d in devices) + { + if (d.Usn == usn) + { + list.Add(d); + } + } + + return list; } #endregion |
