public async Task PhoneCallStarted(PhoneCallData model) { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var uri = $"http://{settingsService.HostIP}:{settingsService.HostPort}/api/SmartHouse/PhoneCallStarted"; var modelString = JsonConvert.SerializeObject(model); var content = new StringContent(modelString, Encoding.UTF8, "application/json"); var response = await client.PostAsync(uri, content); var json = await response.Content.ReadAsStringAsync(); } }
public async Task <bool> PhoneCallStarted(PhoneCallData phoneCall) { PushNotification("Phone call started"); var powerStatus = await _yamahaService.PowerStatus(); var isTurnOn = powerStatus == PowerStatusEnum.On; var state = await _smartHouseService.GetCurrentState(); var isPlaying = false; if (state == SmartHouseState.Pandora && isTurnOn) { isPlaying = _pandoraService.IsPlaying(); } else if (state == SmartHouseState.Music && isTurnOn) { isPlaying = _mpdService.GetStatus().State == MpdState.Play; } if (isPlaying) { if (state == SmartHouseState.Pandora) { if (!PhoneCallsStack.PhoneCallActive()) { _pandoraService.Pause(); } PhoneCallsStack.AddPhoneCall(phoneCall); } else if (state == SmartHouseState.Music) { if (!PhoneCallsStack.PhoneCallActive()) { _mpdService.Pause(); } PhoneCallsStack.AddPhoneCall(phoneCall); } } return(isPlaying); }