public async Task <IActionResult> Put(string from, string to, [FromBody] RTCSessionDescriptionInit sdp) { if (string.IsNullOrEmpty(to) || string.IsNullOrEmpty(from) || sdp == null || sdp.sdp == null) { _logger.LogWarning($"WebRTC signal controller PUT sdp request had invalid parameters."); return(BadRequest()); } if (sdp.type == RTCSdpType.offer) { await ExpireExisting(from, to); } WebRTCSignal sdpSignal = new WebRTCSignal { ID = Guid.NewGuid().ToString(), To = to, From = from, SignalType = WebRTCSignalTypesEnum.sdp.ToString(), Signal = sdp.toJSON(), Inserted = DateTime.UtcNow.ToString("o") }; _context.WebRTCSignals.Add(sdpSignal); await _context.SaveChangesAsync(); return(Ok()); }
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()); }