Esempio n. 1
0
        /// <summary>
        /// Update AccDataList with new AccDataList built with new configuration
        /// Delete and create only accounts with data that has changed, to avoid
        /// interruption of service if data haven't changed
        /// </summary>
        /// <param name="NewAccDataList">list of new configurated params</param>
        private void SynchronizeAccountsList(List <AccountDataSip> NewAccDataList)
        {
            AccountDataSip found = null;

            List <AccountDataSip> AccDataListCopy = new List <AccountDataSip>(AccDataList);

            foreach (AccountDataSip data in AccDataListCopy)
            {
                found = NewAccDataList.Find(x => data.Equals(x));
                if (found == null)
                {
                    AccDataList.Remove(data);
                    SipAgent.DestroyAccount(data.NumeroAbonado);
                }
                else
                {
                    NewAccDataList.Remove(found);
                }
            }
            foreach (AccountDataSip newData in NewAccDataList)
            {
                AccDataList.Add(newData);
                if ((_ProxyIP == null) || (_ProxyIP.Length == 0))
                {
                    SipAgent.CreateAccount(newData.NumeroAbonado);
                }
                else
                {
                    SipAgent.CreateAccountAndRegisterInProxy(newData.NumeroAbonado, _ProxyIP, Settings.Default.ExpireInProxy, newData.NumeroAbonado, newData.NumeroAbonado, newData.IdAgrupacion);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handler to receive new configuration
        /// Avoid to re-create account if its data haven't changed
        /// </summary>
        /// <param name="sender"></param>
        private void OnConfigChanged(object sender)
        {
            string idEquipo;
            string newProxy = Top.Cfg.GetProxyIp(out idEquipo);
            List <AccountDataSip> NewAccDataList = new List <AccountDataSip>();

            foreach (StrNumeroAbonado num in Top.Cfg.HostAddresses)
            {
                if (num.Prefijo == Cd40Cfg.ATS_DST)
                {
                    NewAccDataList.Add(new AccountDataSip(num));
                }
            }

            if (_ProxyIP != newProxy)
            {
                // If proxy has changed all accounts are created again
                SipAgent.DestroyAccounts();
                AccDataList = new List <AccountDataSip>(NewAccDataList);
                _ProxyIP    = newProxy;
                foreach (AccountDataSip data in AccDataList)
                {
                    if ((_ProxyIP == null) || (_ProxyIP.Length == 0))
                    {
                        SipAgent.CreateAccount(data.NumeroAbonado);
                    }
                    else
                    {
                        SipAgent.CreateAccountAndRegisterInProxy(data.NumeroAbonado, _ProxyIP, Settings.Default.ExpireInProxy, data.NumeroAbonado, data.NumeroAbonado, data.IdAgrupacion);
                    }
                }
            }
            else
            {
                SynchronizeAccountsList(NewAccDataList);
            }


            // JCAM. 20170324
            // Incorporar las direcciones de los grabadores en la configuración
            // y hacer que el módulo de grabación se entere del cambio de configuración
            AsignacionUsuariosTV tv = Top.Cfg.GetUserTv(Top.Cfg.MainId);

            if (tv != null)
            {
                SipAgent.PictRecordingCfg(tv.IpGrabador1, tv.IpGrabador2, tv.RtspPort);
            }
        }