示例#1
0
        public void Add(TlfPosition tlf)
        {
            Debug.Assert(_DesiredMembers.Contains(tlf));
            _Logger.Trace("Add to conf ");
            if (!_Members.Contains(tlf))
            {
                _Members.Add(tlf);
                //NotifyConfInfo();

                General.SafeLaunchEvent(MemberAdded, this, tlf);
            }

            if ((tlf.State == TlfState.Conf) && (_Members.Count > 1))
            {
                _ConferenceState = ConfState.Executing;

                NotifyConfInfo();

                foreach (TlfPosition member in _Members)
                {
                    if ((member != tlf) && (member.State == TlfState.Conf))
                    {
                        Top.Mixer.Link(tlf.CallId, member.CallId, MixerDir.SendRecv, FuentesGlp.Telefonia);
                    }
                }
            }
        }
示例#2
0
 /// <summary>
 /// Evento recibido con el resultado de la transferencia
 /// Si se recibe un codigo de error se intenta la transferencia con el otro participante
 /// </summary>
 /// <param name="newRtxGroup"></param>
 /// <returns></returns>
 private void OnTransferStatus(object sender, int callId, int code)
 {
     if ((code > 101) && (code < 300) && (code != SipAgent.SIP_ACCEPTED))
     {
         if (_AssociateCall != null)
         {
             _AssociateCall.HangUp(0);
         }
         Top.Sip.TlfTransferStatus -= OnTransferStatus;
         State       = FunctionState.Idle;
         _ToTransfer = null;
         _FromTransferDisplayName = "";
     }
     else if ((code >= 300) && !_FirstTransferTryKO && (_ToTransfer != null))
     {
         _FirstTransferTryKO = true;
         //Try transfer with other participant
         SipAgent.TransferCall(_ToTransfer.CallId, AssociateCall.CallId, null, _FromTransferDisplayName);
         AssociateCall            = _ToTransfer;
         _ToTransfer              = null;
         _FromTransferDisplayName = "";
     }
     else if ((code >= 300) && _FirstTransferTryKO)
     {
         AssociateCall              = null;
         Top.Sip.TlfTransferStatus -= OnTransferStatus;
         State       = FunctionState.Error;
         _ToTransfer = null;
         _FromTransferDisplayName = "";
     }
 }
示例#3
0
        public void Remove(TlfPosition tlf)
        {
            if (_DesiredMembers.Remove(tlf))
            {
                if (_DesiredMembers.Count == 1)
                {
                    Dispose();
                }
                else
                {
                    if (_Members.Remove(tlf))
                    {
                        _Logger.Trace("Remove from conf ");
                        NotifyConfInfo();
                    }

                    _Priority = CORESIP_Priority.CORESIP_PR_UNKNOWN;

                    foreach (TlfPosition member in _DesiredMembers)
                    {
                        _Priority = (CORESIP_Priority)Math.Min((int)_Priority, (int)tlf.CallPriority);
                    }
                    General.SafeLaunchEvent(MemberRemoved, this, tlf);
                }
            }
        }
示例#4
0
        public void To(int id)
        {
            if (_State == FunctionState.Idle)
            {
                Debug.Assert(id < Tlf.NumDestinations);

                TlfPosition   to = Top.Tlf[id];
                FunctionState st = FunctionState.Error;

                if (to.IsTop)
                {
                    _To = new TlfIaPosition(to);
                    _To.Listen();

                    if (_To.State == TlfState.Out)
                    {
                        _To.TlfPosStateChanged += OnToMonitoringCallStateChanged;
                        st = FunctionState.Executing;

                        Top.WorkingThread.Enqueue("SetSnmp", delegate()
                        {
                            string snmpString = Top.Cfg.PositionId + "_" + "LISTEN" + "_" + _To.Literal;
                            General.SafeLaunchEvent(SetSnmpString, this, new SnmpStringMsg <string, string>(Settings.Default.TlfFacilityOid, snmpString));
                        });
                    }
                }

                State = st;
            }
        }
示例#5
0
        /// <summary>
        /// Al establecerse la llamada y terminar con exito la captura se envia el mensaje
        /// al target
        /// </summary>
        /// <param name="sender"></param>
        private void OnCapturedCallStateChanged(object sender)
        {
            TlfPosition tlf = (TlfPosition)sender;

            try
            {
                if (tlf.State == TlfState.Set)
                {
                    _Captured.TlfPosStateChanged -= OnCapturedCallStateChanged;
                    SipAgent.SendInstantMessage(_Target.Channels[0].AccId, _Target.Uri, PickUpTag + Top.Cfg.PositionId + Resources.HasCaptured + _Captured.Literal, _UseProxy);
                    _Ringing.Remove(_Captured.Pos);
                    foreach (int pos in _Ringing.Keys)
                    {
                        Top.Tlf[pos].State = TlfState.Idle;
                    }
                    _Ringing.Clear();
                    _Target.TlfPosStateChanged -= OnTargetCallStateChanged;
                    _Target.State = TlfState.Idle; // se pasa a reposo al terminar la captura, no al entrar los ringing
                    _Target       = null;
                    _TargetUris   = null;
                    State         = FunctionState.Idle;
                    Top.WorkingThread.Enqueue("SetSnmp", delegate()
                    {
                        string snmpString = Top.Cfg.PositionId + "_" + "CAPTURED" + "_" + _Captured.Literal;
                        General.SafeLaunchEvent(SetSnmpString, this, new SnmpStringMsg <string, string>(Settings.Default.TlfFacilityOid, snmpString));
                    });
                }
            }
            catch (Exception exc)
            {
                _Logger.Error("OnCapturedCallStateChanged exception {0}", exc.Message);
            }
        }
示例#6
0
        public void To(int id)
        {
            _FirstTransferTryKO      = false;
            _ToTransfer              = null;
            _FromTransferDisplayName = "";
            if (_State == FunctionState.Idle)
            {
                List <TlfPosition> activeCalls = Top.Tlf.ActiveCalls;
                FunctionState      st          = FunctionState.Error;

                if (activeCalls.Count == 1)
                {
                    if ((activeCalls[0].State == TlfState.Set) || (activeCalls[0].State == TlfState.Conf))
                    {
                        TlfPosition tlf = activeCalls[0];
                        TlfPosition to  = Top.Tlf[id];

                        bool transferDone = false;
                        if (Top.Tlf[id].State == TlfState.Idle)
                        {
                            string toUri = to.Uri;
                            if (TlfManager.GetDisplayName(to.Uri) == null && to.Literal.Length > 0)
                            {
                                //Si to.Uri no tiene display name se añade el Literal como display name en la transferencia directa
                                toUri = "\"" + to.Literal + "\" " + to.Uri;
                            }
                            SipAgent.TransferCall(tlf.CallId, -1, toUri, null);

                            transferDone = true;
                        }
                        else if (Top.Tlf[id].State == TlfState.Hold)
                        {
                            SipAgent.HoldCall(activeCalls[0].CallId);
                            System.Threading.Thread.Sleep(50);
                            SipAgent.TransferCall(tlf.CallId, to.CallId, null, "\"" + to.Literal + "\"");
                            transferDone             = true;
                            _ToTransfer              = to;
                            _FromTransferDisplayName = "\"" + tlf.Literal + "\"";
                        }
                        if (transferDone)
                        {
                            _Logger.Debug("Iniciando transferencia...");
                            Top.Sip.TlfTransferStatus += OnTransferStatus;
                            AssociateCall              = tlf;

                            st = FunctionState.Executing;

                            Top.WorkingThread.Enqueue("SetSnmp", delegate()
                            {
                                string snmpString = Top.Cfg.PositionId + "_" + "TRANSFER" + "_" + tlf.Literal;
                                General.SafeLaunchEvent(SetSnmpString, this, new SnmpStringMsg <string, string>(Settings.Default.TlfFacilityOid, snmpString));
                            });
                        }
                    }
                }

                State = st;
            }
        }
示例#7
0
        /// <summary>
        /// Si el objetivo sobre el que capturamos cambia de estado, damos por errónea la captura
        /// </summary>
        /// <param name="sender"></param>
        private void OnTargetCallStateChanged(object sender)
        {
            TlfPosition tlf = (TlfPosition)sender;

            if ((tlf.OldState != TlfState.InProcess) || (tlf.State != TlfState.Idle))
            {
                Cancel(false);
            }
        }
示例#8
0
        public void Cancel()
        {
            if (_State == FunctionState.Executing)
            {
                AssociateCall              = null;
                Top.Sip.TlfTransferStatus -= OnTransferStatus;
            }

            State = FunctionState.Idle;
        }
示例#9
0
 private void OnMemberAdded(object sender, TlfPosition tlf)
 {
     if (_State == IntrusionState.InProgress)
     {
         if (!CompleteIntrusion())
         {
             Dispose();
         }
     }
 }
示例#10
0
        public void TryAddIncoming(TlfPosition tlf)
        {
            Debug.Assert(!_Members.Contains(tlf));
            Top.Tlf.Accept(tlf.Pos, this);

            if (!_DesiredMembers.Contains(tlf))
            {
                _Priority = (CORESIP_Priority)Math.Min((int)_Priority, (int)tlf.CallPriority);
                _Intruder = tlf;
                _DesiredMembers.Add(tlf);
            }
        }
示例#11
0
        public TlfIntrusion(TlfPosition intruderCall)
        {
            Top.Tlf.ActivityChanged += OnActivityChanged;

            _State         = IntrusionState.Queued;
            _AssociateCall = intruderCall;
            _AssociateCall.TlfPosStateChanged += OnAssociateCallStateChanged;

            _IntrusionTout.AutoReset = false;
            _IntrusionTout.Elapsed  += OnIntrusionTimeout;
            _IntrusionTout.Interval  = Math.Max(1, Settings.Default.IntrusionTout);
            _IntrusionTout.Enabled   = true;
        }
示例#12
0
        public ForwardUnitTest()
        {
            //
            // Prepara el mock del TlfManager
            //
            //user TlfManager constructor for testing
            mockTlf  = new Mock <TlfManager>(true);
            mockTlfA = new Mock <TlfPosition>(MockBehavior.Strict, 0);
            mockTlfA.SetupGet(m => m.NumerosAbonado).Returns(new List <string> {
                "A"
            });
            mockTlfB = new Mock <TlfPosition>(MockBehavior.Strict, 0);
            mockTlfB.SetupGet(m => m.NumerosAbonado).Returns(new List <string> {
                "B"
            });
            mockTlfC = new Mock <TlfPosition>(MockBehavior.Strict, 0);
            mockTlfC.SetupGet(m => m.NumerosAbonado).Returns(new List <string> {
                "C"
            });
            mockTlfD = new Mock <TlfPosition>(MockBehavior.Strict, 0);
            mockTlfD.SetupGet(m => m.NumerosAbonado).Returns(new List <string> {
                "D"
            });

            //SortedList<int, TlfPosition> ADConfigured = new SortedList<int, TlfPosition>();
            tlfA = new TlfPosition(0);
            //tlfA.Literal = "A";
            //ADConfigured.Add(0, tlfA);
            tlfB = new TlfPosition(1);
            //tlfB.Literal = "B";
            //ADConfigured.Add(1, tlfB);
            tlfC = new TlfPosition(2);
            //ADConfigured.Add(2, tlfC);
            //tlfC.Literal = "C";
            //mockTlf.SetupProperty<SortedList<int, TlfPosition>>(m => m._TlfPositions, ADConfigured);
            mockTlf.Setup(m => m.GetTlfPosition(uriDestA, destA, false, true)).Returns(mockTlfA.Object);
            mockTlf.Setup(m => m.GetTlfPosition(uriDestA, null, false, true)).Returns(mockTlfA.Object);
            mockTlf.Setup(m => m.GetTlfPosition(uriDestB, destB, false, true)).Returns(mockTlfB.Object);
            mockTlf.Setup(m => m.GetTlfPosition(uriDestB, null, false, true)).Returns(mockTlfB.Object);
            mockTlf.Setup(m => m.GetTlfPosition(uriDestC, destC, false, true)).Returns(mockTlfC.Object);
            mockTlf.Setup(m => m.GetTlfPosition(uriDestC, null, false, true)).Returns(mockTlfC.Object);
            mockTlf.Setup(m => m.GetTlfPosition(uriDestD, destD, false, true)).Returns(mockTlfD.Object);
            mockTlf.Setup(m => m.GetTlfPosition(uriDestD, null, false, true)).Returns(mockTlfD.Object);


            _A_UA = new ForwardManager.TlfForward("A", mockTlf.Object);
            _B_UA = new ForwardManager.TlfForward("B", mockTlf.Object);
            _C_UA = new ForwardManager.TlfForward("C", mockTlf.Object);
            _D_UA = new ForwardManager.TlfForward("D", mockTlf.Object);
        }
示例#13
0
        private void OnAssociateCallStateChanged(object sender)
        {
            Debug.Assert(_State == FunctionState.Executing);
            Debug.Assert(sender == _AssociateCall);

            switch (_AssociateCall.State)
            {
            case TlfState.Unavailable:
            case TlfState.Idle:
            case TlfState.PaPBusy:
                AssociateCall = null;
                break;
            }
        }
示例#14
0
        public bool TryAddExisting(TlfPosition tlf)
        {
            Debug.Assert(!_Members.Contains(tlf));
            Debug.Assert(!_DesiredMembers.Contains(tlf));

            if (_DesiredMembers.Count < 5)
            {
                tlf.AddToConference(this);

                _Priority = (CORESIP_Priority)Math.Min((int)_Priority, (int)tlf.CallPriority);
                _DesiredMembers.Add(tlf);

                return(true);
            }

            return(false);
        }
示例#15
0
        public void To(uint prefix, string dst, string number)
        {
            _FirstTransferTryKO      = false;
            _ToTransfer              = null;
            _FromTransferDisplayName = "";
            if (_State == FunctionState.Idle)
            {
                List <TlfPosition> activeCalls = Top.Tlf.ActiveCalls;
                FunctionState      st          = FunctionState.Error;

                if (activeCalls.Count == 1)
                {
                    TlfPosition tlf = activeCalls[0];

                    if ((tlf.State == TlfState.Set) || (tlf.State == TlfState.Conf))
                    {
                        using (TlfIaPosition to = new TlfIaPosition(prefix, dst))
                        {
                            string toUri = to.Uri;
                            if (TlfManager.GetDisplayName(to.Uri) == null && to.Literal.Length > 0)
                            {
                                //Si to.uri no tiene display name se añade el Literal como display name en la transferencia directa
                                toUri = "\"" + to.Literal + "\" " + to.Uri;
                            }
                            SipAgent.TransferCall(tlf.CallId, -1, toUri, null);

                            Top.Sip.TlfTransferStatus += OnTransferStatus;

                            AssociateCall = tlf;
                            st            = FunctionState.Executing;

                            Top.WorkingThread.Enqueue("SetSnmp", delegate()
                            {
                                string snmpString = Top.Cfg.PositionId + "_" + "TRANSFER" + "_" + tlf.Literal;
                                General.SafeLaunchEvent(SetSnmpString, this, new SnmpStringMsg <string, string>(Settings.Default.TlfFacilityOid, snmpString));
                            });
                        }
                    }
                }

                State = st;
            }
        }
示例#16
0
        /// <summary>
        /// Construye y envía el notify con los miembros de la conferencia.
        /// El primer miembro soy yo mismo, con todos los numeros a los que atiendo.
        /// Se llama cuando alguien se suscribe (1) y cuando se añaden miembros a la conferencia (2).
        /// Tiene un parametro opcional callId. Si viene, se envia el notify al miembro que
        /// contiene ese callId (1). El comportamiento por defecto es que si no viene el parámetro
        /// se envia a todos los miembros de la conferencia (2).
        /// </summary>
        /// <param name="callId" parámetro opcional, callId ></param>
        /// <returns> </returns>
        private void NotifyConfInfo(int callId = -1)
        {
            _Logger.Trace("NotifyConfInfo ");
            if (_Members.Count > 0)
            {
                CORESIP_ConfInfo info = new CORESIP_ConfInfo();

                info.Version = ++_Version;
                info.Users   = new CORESIP_ConfInfo.ConfUser[SipAgent.CORESIP_MAX_CONF_USERS];

                int j = 0;
                foreach (StrNumeroAbonado num in Top.Cfg.HostAddresses)
                {
                    info.Users[j].Id     = string.Format("<sip:{0}@{1}>", num.NumeroAbonado, Top.SipIp);;
                    info.Users[j++].Name = Top.Cfg.PositionId;
                }
                int i;
                info.UsersCount = (uint)(_Members.Count + j);;

                for (i = j; i < info.UsersCount; i++)
                {
                    TlfPosition member = _Members[i - j];

                    info.Users[i].Id   = member.Uri;
                    info.Users[i].Name = member.Literal;

                    if (member == _Intruder)
                    {
                        info.Users[i].Role = "Intruder";
                    }
                }

                foreach (TlfPosition member in _Members)
                {
                    if ((callId == -1) || (callId == member.CallId))
                    {
                        SipAgent.SendConfInfo(member.CallId, info);
                    }
                }
            }
        }
示例#17
0
 public TlfIaPosition(TlfPosition tlf)
     : base(1000)
 {
     Debug.Assert(tlf.Cfg != null);
     base.Reset(tlf.Cfg);
 }
        ///Tests para probar cuando se corta la llamada y pasa la tecla a reposo
        ///por una sectorización con cambios.
        ///Hay una llamada con canal, pero sin callId
        public void ChangeConfig3()
        {
            //Initial configuration
            TlfPosition      tlfTest = new TlfPosition(12);
            CfgEnlaceInterno link    = new CfgEnlaceInterno();

            link.Literal           = "BL";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            CfgRecursoEnlaceInterno rec = new CfgRecursoEnlaceInterno();

            rec.Prefijo       = 2;
            rec.NombreRecurso = "prubl";
            rec.Interface     = TipoInterface.TI_BL;
            link.ListaRecursos.Add(rec);

            tlfTest.Reset(link);

            //Give it an incomplete call, no callID
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            SipRemote remote = new SipRemote(rec.NombreRecurso);

            tlfTest._SipCall.Update(-1, link.OrigenR2, rec.NombreRecurso, tlfTest.Channels[0], remote, tlfTest.Channels[0].ListLines[0]);
            Assert.IsNotNull(tlfTest._SipCall);

            //1.Cambio configuracion origen R2
            link                   = new CfgEnlaceInterno();
            link.Literal           = "BL";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218002"; // Cambio
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "prubl";
            rec.Interface     = TipoInterface.TI_BL;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //Se corta la llamada
            Assert.IsNull(tlfTest._SipCall);

            //Give it an incomplete call, no callID
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            remote           = new SipRemote(rec.NombreRecurso);
            tlfTest._SipCall.Update(-1, link.OrigenR2, rec.NombreRecurso, tlfTest.Channels[0], remote, tlfTest.Channels[0].ListLines[0]);
            tlfTest.State = TlfState.Busy;

            //2.Cambio configuracion Prioridad, literal
            link                   = new CfgEnlaceInterno();
            link.Literal           = "BL_"; //Cambio
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 3;     // Cambio
            link.OrigenR2          = "218002";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "prubl";
            rec.Interface     = TipoInterface.TI_BL;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //Se corta la llamada porque no esta disponible la linea
            Assert.IsNull(tlfTest._SipCall);
            Assert.AreEqual(tlfTest.State, TlfState.Unavailable);

            //Give it an incomplete call, no channel
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            remote           = new SipRemote(rec.NombreRecurso);
            tlfTest._SipCall.Update(-1, link.OrigenR2, rec.NombreRecurso, tlfTest.Channels[0], remote, tlfTest.Channels[0].ListLines[0]);
            tlfTest.State = TlfState.Busy;
            Assert.IsNotNull(tlfTest._SipCall);

            //3.Cambio configuracion prefijo recurso, nombre rec
            link                   = new CfgEnlaceInterno();
            link.Literal           = "BL_";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 3;
            link.OrigenR2          = "218002";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 0;         // Cambio
            rec.NombreRecurso = "S4_SCV2"; //Cambio
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //Se corta la llamada
            Assert.IsNull(tlfTest._SipCall);
        }
        ///Tests para probar cuando se corta la llamada y pasa la tecla a reposo
        ///por una sectorización con cambios.
        ///La llamada no tiene canal
        public void ChangeConfig1()
        {
            //Initial configuration
            TlfPosition      tlfTest = new TlfPosition(12);
            CfgEnlaceInterno link    = new CfgEnlaceInterno();

            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            CfgRecursoEnlaceInterno rec = new CfgRecursoEnlaceInterno();

            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);

            tlfTest.Reset(link);

            //Give it an incomplete call, , no channel
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            Assert.IsNotNull(tlfTest._SipCall);

            //1.Cambio configuracion origen R2
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218002"; // Cambio
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //Se corta la llamada
            Assert.IsNull(tlfTest._SipCall);

            //Give it an incomplete call, no channel
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            Assert.IsNotNull(tlfTest._SipCall);

            //2.Cambio configuracion Prioridad, literal
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1_"; //Cambio
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;     // Cambio
            link.OrigenR2          = "218002";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //No se corta la llamada
            Assert.IsNotNull(tlfTest._SipCall);

            //Give it an incomplete call, no channel
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            Assert.IsNotNull(tlfTest._SipCall);

            //3.Cambio configuracion prefijo recurso, nombre rec
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1_";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218002";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 3;     // Cambio
            rec.NombreRecurso = "S1_"; //Cambio
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //No Se corta la llamada
            Assert.IsNotNull(tlfTest._SipCall);
        }
        ///Tests para probar que no se corta la llamada ni cambia de estado
        ///por una sectorización sin cambios
        public void ChangeConfig2()
        {
            //Initial configuration
            TlfPosition      tlfTest = new TlfPosition(12);
            CfgEnlaceInterno link    = new CfgEnlaceInterno();

            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            CfgRecursoEnlaceInterno rec = new CfgRecursoEnlaceInterno();

            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);

            tlfTest.Reset(link);
            //Give it an incomplete call, estado unavailable
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            Assert.IsNotNull(tlfTest._SipCall);
            Assert.AreEqual(tlfTest.State, TlfState.Unavailable);

            //1.sin cambios, en estado unavailable
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //No se corta la llamada
            Assert.IsNotNull(tlfTest._SipCall);
            Assert.AreEqual(tlfTest.State, TlfState.Unavailable);

            //2. Tecla en congestion, no cambia
            tlfTest.State          = TlfState.Congestion;
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //No se corta la llamada
            Assert.IsNotNull(tlfTest._SipCall);
            Assert.AreEqual(tlfTest.State, TlfState.Congestion);

            //3. Tecla en busy, no cambia
            tlfTest.State          = TlfState.Busy;
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //No se corta la llamada
            Assert.IsNotNull(tlfTest._SipCall);
            Assert.AreEqual(tlfTest.State, TlfState.Busy);

            //3. Tecla en InProcess, no cambia
            tlfTest.State          = TlfState.InProcess;
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //No se corta la llamada
            Assert.IsNotNull(tlfTest._SipCall);
            Assert.AreEqual(tlfTest.State, TlfState.InProcess);
        }
示例#21
0
        /// <summary>
        /// Receive data of present dialogs.
        /// With early dialogs it signals ringing state
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="xml"></param>
        /// <param name="len"></param>
        private void OnNotifyDialog(object sender, string xml)
        {
            string source = null;

            if ((State != FunctionState.Executing) || _IgnoreNotify)
            {
                return;
            }
            List <DialogData> dialogs = NotifyDialogParse(xml, out source);

            if (_Target != null)
            {
                try
                {
                    //it's for me
                    IEnumerable <DialogData> earlyDialogs = dialogs.Where <DialogData>(x => x.state == "early");
                    IEnumerable <DialogData> otherDialogs = dialogs.Where <DialogData>(x => x.state != "early");
                    foreach (DialogData dialog in otherDialogs)
                    {
                        TlfPosition tlf = Top.Tlf.GetTlfPosition(dialog.remoteId, dialog.display);
                        if ((tlf != null) && _Ringing.ContainsKey(tlf.Pos))
                        {
                            _Ringing.Remove(tlf.Pos);
                            //tlf.State = TlfState.Idle;
                            tlf.State = tlf.OldState;
                        }
                    }
                    foreach (DialogData dialog in earlyDialogs)
                    {
                        TlfPosition tlf = Top.Tlf.GetTlfPosition(dialog.remoteId, dialog.display);
                        if (tlf != null)
                        {
                            //No se tienen en cuenta las capturadas que ya estaban en entrantes
                            //en el sistema, tampoco se da por fallida la captura
                            // ej: captura de una linea pto a punto que suena en todos los puestos
                            if (tlf.State != TlfState.In)
                            {
                                tlf.State = TlfState.In;
                                _Ringing.Add(tlf.Pos, dialog);
                            }
                        }
                        else
                        {
                            //No hay hueco para la entrante
                            State = FunctionState.Error;
                            foreach (int pos in _Ringing.Keys)
                            {
                                Top.Tlf[pos].State = TlfState.Idle;
                            }
                            _Ringing.Clear();
                            //_Target.State = TlfState.Idle;
                            if (_TargetUris != null)
                            {
                                foreach (string uri in _TargetUris)
                                {
                                    SipAgent.DestroyDialogSubscription(uri);
                                }
                            }
                            General.SafeLaunchEvent(PickUpError, this, Resources.CaptureErrorCapacity);
                            break;
                        }
                    }
                    //if (_Ringing.Count > 0)
                    //    _Target.State = TlfState.Idle;

                    //State = FunctionState.Idle;
                }
                catch (Exception exc)
                {
                    _Logger.Error("NotifyDialog exception {0}", exc.Message);
                }
            }
            else
            {
                _Logger.Error("NotifyDialog not expected from {0}", source);
            }
        }