Exemplo n.º 1
0
        public ActionResult DeleteCall(string id)
        {
            Guid callIdGuid;

            if (!Guid.TryParse(id, out callIdGuid))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var call = _callRepository.GetCallInfoById(callIdGuid);

            if (call == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var model = new DeleteCallViewModel()
            {
                CallId             = callIdGuid,
                CallFromSipAddress = call.FromSipAddress,
                CallToSipAddress   = call.ToSipAddress,
                CallStarted        = call.Started.ToLocalTime()
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public void Update(SipEventHandlerResult updateResult)
        {
            if (updateResult.ChangeStatus == SipEventChangeStatus.CallStarted)
            {
                // Load call and update to and from codecs
                var callId   = updateResult.ChangedObjectId;
                var callInfo = _callRepository.GetCallInfoById(callId);

                if (callInfo != null)
                {
                    log.Debug($"CodecStatusHub. Call started. From: {callInfo.FromId}, To: {callInfo.ToId}");
                    UpdateCodecStatusByGuid(callInfo.FromId);
                    UpdateCodecStatusByGuid(callInfo.ToId);
                }
                else
                {
                    log.Error($"CodecStatusHub. Call started but was not found in database. Call Id: {callId}");
                }
            }

            if (updateResult.ChangeStatus == SipEventChangeStatus.CallClosed)
            {
                // Load call and update to and from codecs
                var         callId = updateResult.ChangedObjectId;
                CallHistory call   = _callHistoryRepository.GetCallHistoryByCallId(callId);

                if (call != null)
                {
                    log.Debug($"CodecStatusHub. Call closed. From: {call.FromId}, To: {call.ToId}, Call Id: {callId}");
                    UpdateCodecStatusByGuid(call.FromId);
                    UpdateCodecStatusByGuid(call.ToId);
                }
                else
                {
                    log.Error($"CodecStatusHub. Call closed but was not found in call history. Call Id: {callId}");
                }
            }

            if (updateResult.ChangeStatus == SipEventChangeStatus.CodecAdded)
            {
                UpdateCodecStatusByGuid(updateResult.ChangedObjectId);
            }

            if (updateResult.ChangeStatus == SipEventChangeStatus.CodecUpdated)
            {
                UpdateCodecStatusByGuid(updateResult.ChangedObjectId);
            }

            if (updateResult.ChangeStatus == SipEventChangeStatus.CodecRemoved)
            {
                var codecStatus = new CodecStatusViewModel
                {
                    State      = CodecState.NotRegistered,
                    SipAddress = updateResult.SipAddress
                };
                CodecStatusHub.UpdateCodecStatusRemoved(codecStatus);
            }

            log.Debug($"CodecStatusHub. Status: {updateResult.ChangeStatus}, Id: {updateResult.ChangedObjectId}, SipAddress: {updateResult.SipAddress}");
        }
Exemplo n.º 3
0
        public void Update(KamailioMessageHandlerResult updateResult)
        {
            if (updateResult.ChangeStatus == KamailioMessageChangeStatus.CallStarted)
            {
                // Load call and update to and from codecs
                var callId   = updateResult.ChangedObjectId;
                var callInfo = _callRepository.GetCallInfoById(callId);

                if (callInfo != null)
                {
                    log.Warn("Call started. From:{0} To:{1}", callInfo.FromId, callInfo.ToId);
                    UpdateCodecStatusByGuid(callInfo.FromId);
                    UpdateCodecStatusByGuid(callInfo.ToId);
                }
                else
                {
                    log.Warn("Call started but was not found in database. Call Id:{0}", callId);
                }
            }

            if (updateResult.ChangeStatus == KamailioMessageChangeStatus.CallClosed)
            {
                // Load call and update to and from codecs
                var         callId = updateResult.ChangedObjectId;
                CallHistory call   = _callHistoryRepository.GetCallHistoryByCallId(callId);

                if (call != null)
                {
                    log.Info("Call closed. From:{0} To:{1} Call ID:{2}", call.FromId, call.ToId, callId);
                    UpdateCodecStatusByGuid(call.FromId);
                    UpdateCodecStatusByGuid(call.ToId);
                }
                else
                {
                    log.Warn("Call closed but was not found in call history. Call Id:{0}", callId);
                }
            }

            if (updateResult.ChangeStatus == KamailioMessageChangeStatus.CodecAdded ||
                updateResult.ChangeStatus == KamailioMessageChangeStatus.CodecUpdated)
            {
                UpdateCodecStatusByGuid(updateResult.ChangedObjectId);
            }

            if (updateResult.ChangeStatus == KamailioMessageChangeStatus.CodecRemoved)
            {
                var codecStatus = new CodecStatus {
                    State = CodecState.NotRegistered, SipAddress = updateResult.SipAddress
                };
                CodecStatusHub.UpdateCodecStatus(codecStatus);
            }

            log.Info("StatusHub is updating. status={0}, id={1}", updateResult.ChangeStatus, updateResult.ChangedObjectId);
        }
Exemplo n.º 4
0
 public CallInfo GetCallInfoById(Guid callId)
 {
     return(_internalRepository.GetCallInfoById(callId));
 }