Esempio n. 1
0
        public KamailioMessageHandlerResult CloseCall(KamailioDialogMessage sipMessage)
        {
            log.Debug("Closing call with id:\"{0}\", hash id:\"{1}\", hash entry:\"{2}\"", sipMessage.CallId, sipMessage.HashId, sipMessage.HashEntry);

            try
            {
                CallInfo call = _callRepository.GetCallInfo(sipMessage.CallId, sipMessage.HashId, sipMessage.HashEntry);

                if (call == null)
                {
                    log.Warn("Unable to find call with call id: {0}, hash id:{1}, hash entry:{2}", sipMessage.CallId, sipMessage.HashId, sipMessage.HashEntry);
                    return(NothingChangedResult);
                }

                if (call.Closed)
                {
                    log.Warn("Call with call id: {0} already closed", sipMessage.CallId);
                    return(NothingChangedResult);
                }

                _callRepository.CloseCall(call.Id);
                return(SipMessageResult(KamailioMessageChangeStatus.CallClosed, call.Id));
            }
            catch (Exception ex)
            {
                log.Error(ex, "Error while closing call with call id: {0}", sipMessage.CallId);
                return(NothingChangedResult);
            }
        }
Esempio n. 2
0
        public void when_call_ended_registeredsip_should_be_updated_in_cache()
        {
            try
            {
                // Lägg till registrerade kodare
                var codec1 = "*****@*****.**";
                var codec2 = "*****@*****.**";

                RegisterSip(codec1, "192.0.2.236", "MTU 01", "QuantumST/3.5.3g");
                RegisterSip(codec2, "192.0.2.4", "MTU 02", "QuantumST/3.5.3g");
                RegisterSip("*****@*****.**", "192.0.2.215", "MTU 31", "QuantumST/3.5.3g");

                //PrintCodecStatus(codec1, codec2);

                for (int i = 0; i < 10; i++)
                {
                    // Starta samtal
                    var dialogMessage = new SipDialogMessage
                    {
                        FromSipUri = new SipUri(codec1),
                        ToSipUri   = new SipUri(codec2),
                        CallId     = Guid.NewGuid().ToString(),
                        HashId     = "0",
                        HashEntry  = "0"
                    };

                    var result = _kamailioMessageManager.RegisterCall(dialogMessage);
                    Console.WriteLine("Call from {0} to {1} started with status {2}", codec1, codec2, result.ChangeStatus);

                    // Läs ut kodare-status
                    PrintCodecStatus(codec1, codec2);

                    // Läs ut samtal
                    var call = _callRepository.GetCallInfo(dialogMessage.CallId, dialogMessage.HashId, dialogMessage.HashId);
                    Console.WriteLine("Call from {0} to {1} started {2}", call.FromSipAddress, call.ToSipAddress, call.Started);

                    // Avsluta samtal
                    var hangupResult = _kamailioMessageManager.CloseCall(dialogMessage);
                    Console.WriteLine("Call from  {0} to {1} ended with result: {2}", codec1, codec2, hangupResult.ChangeStatus);

                    // Läs ut kodare-status
                    PrintCodecStatus(codec1, codec2);
                }
            }
            finally
            {
                TearDown();
            }
        }
Esempio n. 3
0
 public CallInfo GetCallInfo(string callId, string hashId, string hashEnt)
 {
     return(_internalRepository.GetCallInfo(callId, hashId, hashEnt));
 }