From e441e2f53db0b587c9864fe91d7008a2344d147b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 24 Aug 2017 15:52:19 -0400 Subject: update active recordings --- RSSDP/SsdpDeviceLocatorBase.cs | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'RSSDP/SsdpDeviceLocatorBase.cs') diff --git a/RSSDP/SsdpDeviceLocatorBase.cs b/RSSDP/SsdpDeviceLocatorBase.cs index 1adb95cdf5..d1eaef88af 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 GetUnexpiredDevices() - { - lock (_Devices) - { - return (from device in _Devices where !device.IsExpired() select device).ToArray(); - } - } - private bool DeviceDied(string deviceUsn, bool expired) { - IEnumerable existingDevices = null; + List 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 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 FindExistingDeviceNotifications(IList devices, string usn) + private static List FindExistingDeviceNotifications(IList devices, string usn) { - return (from d in devices where d.Usn == usn select d).ToArray(); + var list = new List(); + + foreach (var d in devices) + { + if (d.Usn == usn) + { + list.Add(d); + } + } + + return list; } #endregion -- cgit v1.2.3