private Hosts GetHosts(string accessPoint) { var task = Task.Run(async() => { try { var uri = new Uri(GetHostsUri); var content = new ClientCharacteristicsRoot(accessPoint); var response = await Client.PostAsJsonAsync(uri, content).ConfigureAwait(false); response.EnsureSuccessStatusCode(); return(await response.Content.ReadAsAsync <Hosts>().ConfigureAwait(false)); } catch (Exception) { return(null); } }); return(task.Result); }
public async Task <CurrentState> GetCurrentStateAsync(CancellationToken cancellationToken) { var content = new ClientCharacteristicsRoot(client.AccessPoint); return(await client.PostRequestAsync <CurrentState, ClientCharacteristicsRoot>(RequestUri.GetCurrentState, content, cancellationToken).ConfigureAwait(false)); }