public async Task <IActionResult> PutIce(string from, string to, [FromBody] RTCIceCandidateInit ice) { if (string.IsNullOrEmpty(to) || string.IsNullOrEmpty(from) || ice == null || ice.candidate == null) { _logger.LogWarning($"WebRTC signal controller PUT ice candidate request had invalid parameters."); return(BadRequest()); } WebRTCSignal iceSignal = new WebRTCSignal { ID = Guid.NewGuid().ToString(), To = to, From = from, SignalType = WebRTCSignalTypesEnum.ice.ToString(), Signal = ice.toJSON(), Inserted = DateTime.UtcNow.ToString("o") }; _context.WebRTCSignals.Add(iceSignal); await _context.SaveChangesAsync(); return(Ok()); }
public async Task <ActionResult> Ice(string id, [FromBody] RTCIceCandidateInit candidate) { _logger.LogDebug($"Echo controller posting ice candidate to {_echoTestRestUrl}/ice/{id}."); _logger.LogDebug($"Candidate={candidate.candidate}"); HttpClient client = new HttpClient(); var postResp = await client.PostAsync($"{_echoTestRestUrl}/ice/{id}", new StringContent(candidate.toJSON(), Encoding.UTF8, REST_CONTENT_TYPE)); _logger.LogDebug($"Echo controller post ice response {postResp.StatusCode}:{postResp.ReasonPhrase}."); return(postResp.IsSuccessStatusCode ? Ok() : BadRequest(postResp.ReasonPhrase)); }