-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathZoneGroupTopologyService.cs
More file actions
33 lines (29 loc) · 1.19 KB
/
ZoneGroupTopologyService.cs
File metadata and controls
33 lines (29 loc) · 1.19 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
using System.IO;
using System.Threading.Tasks;
using System.Xml.Serialization;
using ByteDev.Sonos.Upnp.Proxy;
using ByteDev.Sonos.Upnp.Services.Models;
namespace ByteDev.Sonos.Upnp.Services
{
public class ZoneGroupTopologyService
{
private readonly IUpnpClient _upnpClient;
private static readonly XmlSerializer XmlSerializer = new XmlSerializer(typeof(ZoneGroupState));
private const string ControlUrl = "/ZoneGroupTopology/Control";
private const string ActionNamespace = "urn:schemas-upnp-org:service:ZoneGroupTopology:1";
public ZoneGroupTopologyService(string ipAddress)
{
var upnpUri = new SonosUri(ipAddress, ControlUrl);
_upnpClient = new UpnpClient(upnpUri.ToUri(), ActionNamespace);
}
public async Task<ZoneGroupState> GetZoneGroupStateAsync()
{
var xmlResponse = await _upnpClient.InvokeFuncAsync<string>("GetZoneGroupState");
using (var responseStream = new StringReader(xmlResponse))
{
var zoneGroupState = (ZoneGroupState) XmlSerializer.Deserialize(responseStream);
return zoneGroupState;
}
}
}
}