forked from PeterWaher/IoTGateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeviceLocation.cs
More file actions
112 lines (102 loc) · 3.34 KB
/
Copy pathDeviceLocation.cs
File metadata and controls
112 lines (102 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Waher.Networking.UPnP
{
/// <summary>
/// Contains information about the location of a device on the network.
/// </summary>
public class DeviceLocation
{
private UPnPClient client;
private UPnPHeaders headers;
private string searchTarget;
private string server;
private string location;
private string uniqueServiceName;
/// <summary>
/// Contains information about the location of a device on the network.
/// </summary>
/// <param name="Client">UPnP Client.</param>
/// <param name="SearchTarget">SSDP Search Target</param>
/// <param name="Server">Server</param>
/// <param name="Location">Location of device information</param>
/// <param name="UniqueServiceName">Unique Service Name (USN)</param>
/// <param name="Headers">All headers in response.</param>
internal DeviceLocation(UPnPClient Client, string SearchTarget, string Server, string Location, string UniqueServiceName, UPnPHeaders Headers)
{
this.client = Client;
this.searchTarget = SearchTarget;
this.server = Server;
this.location = Location;
this.uniqueServiceName = UniqueServiceName;
this.headers = Headers;
}
/// <summary>
/// SSDP Search Target
/// </summary>
public string SearchTarget
{
get { return this.searchTarget; }
}
/// <summary>
/// Server
/// </summary>
public string Server
{
get { return this.server; }
}
/// <summary>
/// Location of device information
/// </summary>
public string Location
{
get { return this.location; }
}
/// <summary>
/// Unique Service Name (USN)
/// </summary>
public string UniqueServiceName
{
get { return this.uniqueServiceName; }
}
/// <summary>
/// Gets the device description document from a device in the network.
/// This method is the synchronous version of <see cref="GetDeviceAsync"/>.
/// </summary>
/// <returns>Device Description Document.</returns>
/// <exception cref="TimeoutException">If the document could not be retrieved within the timeout time.</exception>
/// <exception cref="Exception">If the document could not be retrieved, or could not be parsed.</exception>
public DeviceDescriptionDocument GetDevice()
{
return this.client.GetDevice(this.location);
}
/// <summary>
/// Gets the device description document from a device in the network.
/// This method is the synchronous version of <see cref="GetDeviceAsync"/>.
/// </summary>
/// <param name="Timeout">Timeout, in milliseconds.</param>
/// <returns>Device Description Document.</returns>
/// <exception cref="TimeoutException">If the document could not be retrieved within the timeout time.</exception>
/// <exception cref="Exception">If the document could not be retrieved, or could not be parsed.</exception>
public DeviceDescriptionDocument GetDevice(int Timeout)
{
return this.client.GetDevice(this.location, Timeout);
}
/// <summary>
/// Gets a Device Description Document from a device.
/// </summary>
/// <returns>Device description document, if found, or null otherwise.</returns>
public Task<DeviceDescriptionDocument> GetDeviceAsync()
{
return this.client.GetDeviceAsync(this.location);
}
/// <summary>
/// <see cref="Object.ToString()"/>
/// </summary>
public override string ToString()
{
return this.location;
}
}
}