Class DiscoveredSsdpDevice
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.
Inheritance
Inherited Members
Namespace: Rssdp
Assembly: cs.temp.dll.dll
Syntax
public sealed class DiscoveredSsdpDevice
Constructors
DiscoveredSsdpDevice(String, HttpHeaders)
Creates a new DiscoveredSsdpDevice instance.
Declaration
public DiscoveredSsdpDevice(string notificationType, HttpHeaders responseHeaders)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | notificationType | The value of the NotificationType property, being either a uuid, device type, service type or upnp:rootdevice. |
| HttpHeaders | responseHeaders | The headers from the SSDP device response message. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
Properties
AsAt
Sets or returns the date and time this information was received.
Declaration
public DateTimeOffset AsAt { get; set; }
Property Value
| Type | Description |
|---|---|
| System.DateTimeOffset |
CacheLifetime
Sets or returns the length of time this information is valid for (from the AsAt time).
Declaration
public TimeSpan CacheLifetime { get; set; }
Property Value
| Type | Description |
|---|---|
| System.TimeSpan |
DescriptionLocation
Sets or returns a URL pointing to the device description document for this device.
Declaration
public Uri DescriptionLocation { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Uri |
NotificationType
Sets or returns the type of notification, being either a uuid, device type, service type or upnp:rootdevice.
Declaration
public string NotificationType { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
ResponseHeaders
Returns the headers from the SSDP device response message
Declaration
public HttpHeaders ResponseHeaders { get; }
Property Value
| Type | Description |
|---|---|
| HttpHeaders |
Usn
Sets or returns the universal service name (USN) of the device.
Declaration
public string Usn { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
GetDeviceInfo()
Retrieves the device description document specified by the DescriptionLocation property.
Declaration
public async Task<SsdpDevice> GetDeviceInfo()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<SsdpDevice> | An SsdpDevice instance describing the full device details. |
Remarks
This method may choose to cache (or return cached) information if called multiple times within the CacheLifetime period.
Exceptions
| Type | Condition |
|---|---|
| System.Exception | This method using an HttpClient instance to retrieve the device description document, and as such any exception that can be thrown by HttpClient may be rethrown by this method. On the UWP platform this is likely to be a System.Exception instance and the hresult can be checked to determine the exact nature of the error. On other platforms it is likely to be a System.Net.WebException or System.Net.Http.HttpRequestException. Check the documentation for HttpClient on the platform(s) you're using. |
GetDeviceInfo(HttpClient)
Retrieves the device description document specified by the DescriptionLocation property using the provided
Declaration
public async Task<SsdpRootDevice> GetDeviceInfo(HttpClient downloadHttpClient)
Parameters
| Type | Name | Description |
|---|---|---|
| HttpClient | downloadHttpClient | A |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<SsdpRootDevice> | An SsdpDevice instance describing the full device details. |
Remarks
This method may choose to cache (or return cached) information if called multiple times within the CacheLifetime period.
This method performs no error handling, if an exception occurs downloading or parsing the document it will be thrown to the calling code. Ensure you setup correct error handling for these scenarios.
Exceptions
| Type | Condition |
|---|---|
| System.Exception | This method using an HttpClient instance to retrieve the device description document, and as such any exception that can be thrown by HttpClient may be rethrown by this method. On the UWP platform this is likely to be a System.Exception instance and the hresult can be checked to determine the exact nature of the error. On other platforms it is likely to be a System.Net.WebException or System.Net.Http.HttpRequestException. Check the documentation for HttpClient on the platform(s) you're using. |
| System.InvalidOperationException | Thrown if the DescriptionLocation property is not set. |
GetDeviceInfo(HttpClient, Nullable<XmlReaderSettings>)
Retrieves the device description document specified by the DescriptionLocation property using the provided
Declaration
public async Task<SsdpRootDevice> GetDeviceInfo(HttpClient downloadHttpClient, XmlReaderSettings? xmlReaderSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| HttpClient | downloadHttpClient | A |
| System.Nullable<XmlReaderSettings> | xmlReaderSettings | A |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<SsdpRootDevice> | An SsdpDevice instance describing the full device details. |
Remarks
This method may choose to cache (or return cached) information if called multiple times within the CacheLifetime period.
This method performs no error handling, if an exception occurs downloading or parsing the document it will be thrown to the calling code. Ensure you setup correct error handling for these scenarios.
Exceptions
| Type | Condition |
|---|---|
| System.Exception | This method using an HttpClient instance to retrieve the device description document, and as such any exception that can be thrown by HttpClient may be rethrown by this method. On the UWP platform this is likely to be a System.Exception instance and the hresult can be checked to determine the exact nature of the error. On other platforms it is likely to be a System.Net.WebException or System.Net.Http.HttpRequestException. Check the documentation for HttpClient on the platform(s) you're using. |
| System.InvalidOperationException | Thrown if the DescriptionLocation property is not set. |
IsExpired()
Returns true if this device information has expired, based on the current date/time, and the CacheLifetime & AsAt properties.
Declaration
public bool IsExpired()
Returns
| Type | Description |
|---|---|
| System.Boolean |
ToString()
Returns the device's Usn value.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A string containing the device's universal service name. |