public IActionResult Put([FromBody] Call call)
 {
     if (call != null)
     {
         using (var scope = new TransactionScope())
         {
             _callRepository.UpdateCall(call);
             scope.Complete();
             return(new OkResult());
         }
     }
     return(new NoContentResult());
 }
示例#2
0
        public SipEventHandlerResult RegisterCall(SipDialogMessage sipMessage)
        {
            log.Debug("Register call from {0} to {1}, call id \"{2}\", hash id:\"{3}\", hash entry:\"{4}\"",
                      sipMessage.FromSipUri.UserAtHost, sipMessage.ToSipUri.UserAtHost, sipMessage.CallId, sipMessage.HashId, sipMessage.HashEntry);

            if (_callRepository.CallExists(sipMessage.CallId, sipMessage.HashId, sipMessage.HashEntry))
            {
                // TODO: Find out what HashId and HashEntry is and if they are both needed
                log.Debug("Call with id {0}, hash id:{1}, hash entry:{2} already exists", sipMessage.CallId, sipMessage.HashId, sipMessage.HashEntry);
                return(NothingChangedResult);
            }

            var call = new Call();

            // If the user-part is numeric, we make the assumption
            // that it is a phone number (even though sip-address
            // can be of the numeric kind)
            var fromSip = sipMessage.FromSipUri.User.IsNumeric() ? sipMessage.FromSipUri.User : sipMessage.FromSipUri.UserAtHost;
            var from    = _sipRepository.GetRegisteredUserAgents().SingleOrDefault(x => x.SipUri == fromSip);

            call.FromSip         = fromSip;
            call.FromDisplayName = sipMessage.FromDisplayName;
            call.FromId          = from?.Id ?? Guid.Empty;

            var toSip = sipMessage.ToSipUri.User.IsNumeric() ? sipMessage.ToSipUri.User : sipMessage.ToSipUri.UserAtHost;
            var to    = _sipRepository.GetRegisteredUserAgents().SingleOrDefault(x => x.SipUri == toSip);

            call.ToSip         = toSip;
            call.ToDisplayName = sipMessage.ToDisplayName;
            call.ToId          = to?.Id ?? Guid.Empty;

            call.Started     = DateTime.UtcNow;
            call.CallId      = sipMessage.CallId;
            call.DlgHashId   = sipMessage.HashId;
            call.DlgHashEnt  = sipMessage.HashEntry;
            call.Updated     = DateTime.UtcNow;
            call.ToTag       = sipMessage.ToTag;
            call.FromTag     = sipMessage.FromTag;
            call.IsPhoneCall = sipMessage.FromSipUri.User.IsNumeric() || sipMessage.ToSipUri.User.IsNumeric();

            _callRepository.UpdateCall(call);
            return(SipMessageResult(SipEventChangeStatus.CallStarted, call.Id));
        }
示例#3
0
        public KamailioMessageHandlerResult RegisterCall(KamailioDialogMessage sipMessage)
        {
            log.Debug("Register call from {0} to {1}, call id \"{2}\", hash id:\"{3}\", hash entry:\"{4}\"",
                      sipMessage.FromSipUri.UserAtHost, sipMessage.ToSipUri.UserAtHost, sipMessage.CallId, sipMessage.HashId, sipMessage.HashEntry);

            if (_callRepository.CallExists(sipMessage.CallId, sipMessage.HashId, sipMessage.HashEntry))
            {
                log.Debug("Call with id {0}, hash id:{1}, hash entry:{2} already exists", sipMessage.CallId, sipMessage.HashId, sipMessage.HashEntry);
                return(NothingChangedResult);
            }

            var call = new Call();

            // Om user-delen är numerisk antar vi att det är ett telefonnummer (trots att sip-adresser egentligen kan vara numeriska)
            var fromSip = sipMessage.FromSipUri.User.IsNumeric() ? sipMessage.FromSipUri.User : sipMessage.FromSipUri.UserAtHost;
            var from    = _sipRepository.GetCachedRegisteredSips().SingleOrDefault(rs => rs.Sip == fromSip);

            call.FromSip         = fromSip;
            call.FromDisplayName = sipMessage.FromDisplayName;
            call.FromId          = from != null ? from.Id : Guid.Empty;

            var toSip = sipMessage.ToSipUri.User.IsNumeric() ? sipMessage.ToSipUri.User : sipMessage.ToSipUri.UserAtHost;
            var to    = _sipRepository.GetCachedRegisteredSips().SingleOrDefault(rs => rs.Sip == toSip);

            call.ToSip         = toSip;
            call.ToDisplayName = sipMessage.ToDisplayName;
            call.ToId          = to != null ? to.Id : Guid.Empty;

            call.Started     = DateTime.UtcNow;
            call.CallId      = sipMessage.CallId;
            call.DlgHashId   = sipMessage.HashId;
            call.DlgHashEnt  = sipMessage.HashEntry;
            call.Updated     = DateTime.UtcNow;
            call.ToTag       = sipMessage.ToTag;
            call.FromTag     = sipMessage.FromTag;
            call.IsPhoneCall = sipMessage.FromSipUri.User.IsNumeric() || sipMessage.ToSipUri.User.IsNumeric(); // Sätts till true om någon parts adress är numeriskt.
            _callRepository.UpdateCall(call);
            return(SipMessageResult(KamailioMessageChangeStatus.CallStarted, call.Id));
        }
示例#4
0
 public void UpdateCall(Call call)
 {
     _internalRepository.UpdateCall(call);
     // Some registered codecs may have changed state. Reload cache.
     _lazyCache.ClearRegisteredSips();
 }
示例#5
0
 public void UpdateCall(Call call)
 {
     _internalRepository.UpdateCall(call);
     _lazyCache.ClearOngoingCalls();
 }