using System;
using System.Net.Http.Headers;
namespace Rssdp
{
///
/// Represents a discovered device, containing basic information about the device and the location of it's full device description document. Also provides convenience methods for retrieving the device description document.
///
///
///
public sealed class DiscoveredSsdpDevice
{
#region Fields
private DateTimeOffset _AsAt;
#endregion
#region Public Properties
///
/// Sets or returns the type of notification, being either a uuid, device type, service type or upnp:rootdevice.
///
public string NotificationType { get; set; }
///
/// Sets or returns the universal service name (USN) of the device.
///
public string Usn { get; set; }
///
/// Sets or returns a URL pointing to the device description document for this device.
///
public Uri DescriptionLocation { get; set; }
///
/// Sets or returns the length of time this information is valid for (from the time).
///
public TimeSpan CacheLifetime { get; set; }
///
/// Sets or returns the date and time this information was received.
///
public DateTimeOffset AsAt
{
get { return _AsAt; }
set
{
if (_AsAt != value)
{
_AsAt = value;
}
}
}
///
/// Returns the headers from the SSDP device response message
///
public HttpHeaders ResponseHeaders { get; set; }
#endregion
#region Public Methods
///
/// Returns true if this device information has expired, based on the current date/time, and the & properties.
///
///
public bool IsExpired()
{
return this.CacheLifetime == TimeSpan.Zero || this.AsAt.Add(this.CacheLifetime) <= DateTimeOffset.Now;
}
#endregion
#region Overrides
///
/// Returns the device's value.
///
/// A string containing the device's universal service name.
public override string ToString()
{
return this.Usn;
}
#endregion
}
}