public HttpResponseMessage Wait(TwilioVoiceRequest request, [FromUri] Guid?callerId = null, [FromUri] int contactId = 0, [FromUri] string redirectTo = null) { try { request.AddAdditionalFields(callerId, contactId, redirectTo: redirectTo); if (Convert.ToInt32(request.QueueTime) == 0) { var history = CallFromTwilioRequest(request); history.ParentID = history.Id; voipEngine.SaveOrUpdateCall(history); var to = request.RedirectTo; if (string.IsNullOrEmpty(to)) { request.GetSignalRHelper().Enqueue(request.CallSid, callerId.HasValue ? callerId.Value.ToString() : ""); } else { request.GetSignalRHelper().Incoming(request.CallSid, to); } } return(GetHttpResponse(request.Wait())); } catch (Exception e) { Log.Error(e); throw; } }
private void MissCall(TwilioVoiceRequest request, VoipEngine voipEngine) { var voipCall = CallFromTwilioRequest(request); voipCall.Status = VoipCallStatus.Missed; if (!string.IsNullOrEmpty(request.RecordingSid)) { if (voipCall.VoipRecord == null || string.IsNullOrEmpty(voipCall.VoipRecord.Id)) { voipCall.VoipRecord = new VoipRecord { Id = request.RecordingSid }; } } voipCall = voipEngine.SaveOrUpdateCall(voipCall); request.GetSignalRHelper().MissCall(request.CallSid, voipCall.AnsweredBy.ToString()); voipEngine.SaveAdditionalInfo(voipCall.Id); }