예제 #1
0
        public void Start()
        {
            try
            {
                logger.Debug("SIP Registrar daemon starting...");

                // Configure the SIP transport layer.
                Transport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine(), false);
                Transport.PerformanceMonitorPrefix = SIPSorceryPerformanceMonitor.REGISTRAR_PREFIX;
                Transport.MsgEncode = _account.MsgEncode;
                List <SIPChannel> sipChannels = SIPTransportConfig.ParseSIPChannelsNode(_account.LocalIP, _account.LocalPort, _account.MsgProtocol);
                Transport.AddSIPChannel(sipChannels);

                Transport.SIPTransportRequestReceived  += AddMessageRequest;
                Transport.SIPTransportResponseReceived += AddMessageResponse;

                m_registrarCore      = new RegistrarCore(Transport, true, true, SIPRequestAuthenticator.AuthenticateSIPRequest);
                m_registrarCore.Auth = _account.Authentication;
                m_registrarCore.Start(1);

                Console.ForegroundColor = ConsoleColor.Green;
                logger.Debug("SIP Registrar successfully started.");
                Console.ForegroundColor = ConsoleColor.White;
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPRegistrarDaemon Start. " + excp.Message);
            }
        }
예제 #2
0
        public void Initialize(SIPAuthenticateRequestDelegate sipRequestAuthenticator,
                               Dictionary <string, PlatformConfig> platformList,
                               SIPAccount account)
        {
            m_registrarCore = new RegistrarCore(Transport, true, true, sipRequestAuthenticator);
            m_registrarCore.Start(1);


            foreach (var item in platformList)
            {
                string      sipEndPointStr = "udp:" + item.Value.RemoteIP + ":" + item.Value.RemotePort;
                SIPEndPoint sipPoint       = SIPEndPoint.ParseSIPEndPoint(sipEndPointStr);
                for (int i = 0; i < 2; i++)
                {
                    CommandType cmdType = CommandType.Unknown;
                    if (i == 0)
                    {
                        cmdType = CommandType.Play;
                    }
                    else
                    {
                        cmdType = CommandType.Playback;
                    }
                    string             key     = item.Key + cmdType;
                    ISIPMonitorService monitor = new SIPMonitorCore_2011(this, item.Key, item.Value.ChannelName, sipPoint);
                    monitor.OnSIPServiceChanged += monitor_OnSIPServiceChanged;
                    MonitorService.Add(key, monitor);
                }
            }
        }
예제 #3
0
        public void Start()
        {
            try
            {
                logger.Debug("SIP Registrar daemon starting...");

                // Pre-flight checks.
                if (m_sipRegistrarSocketsNode == null || m_sipRegistrarSocketsNode.ChildNodes.Count == 0)
                {
                    throw new ApplicationException("The SIP Registrar cannot start without at least one socket specified to listen on, please check config file.");
                }

                // Send events from this process to the monitoring socket.
                if (m_monitorLoopbackPort != 0)
                {
                    // Events will be sent by the monitor channel to the loopback interface and this port.
                    m_monitorEventWriter = new SIPMonitorEventWriter(m_monitorLoopbackPort);
                    logger.Debug("Monitor channel initialised for 127.0.0.1:" + m_monitorLoopbackPort + ".");
                }

                // Configure the SIP transport layer.
                m_sipTransport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine(), false);
                m_sipTransport.PerformanceMonitorPrefix = SIPSorceryPerformanceMonitor.REGISTRAR_PREFIX;
                List <SIPChannel> sipChannels = SIPTransportConfig.ParseSIPChannelsNode(m_sipRegistrarSocketsNode);
                m_sipTransport.AddSIPChannel(sipChannels);

                // Create and configure the SIP Registrar core.
                if (m_natKeepAliveRelaySocket != null)
                {
                    m_natKeepAliveSender = new UdpClient();
                }

                SIPUserAgentConfigurationManager userAgentConfigManager = new SIPUserAgentConfigurationManager(m_userAgentsConfigNode);
                if (m_userAgentsConfigNode == null)
                {
                    logger.Warn("The UserAgent config's node was missing.");
                }
                m_registrarBindingsManager = new SIPRegistrarBindingsManager(FireSIPMonitorEvent, m_registrarBindingsPersistor, SendNATKeepAlive, m_maximumAccountBindings, userAgentConfigManager);
                m_registrarBindingsManager.Start();

                m_registrarCore = new RegistrarCore(m_sipTransport, m_registrarBindingsManager, GetSIPAccount_External, GetCanonicalDomain_External, true, true, FireSIPMonitorEvent, userAgentConfigManager, SIPAuthenticateRequest_External, m_switchboardUserAgentPrefix, CustomerPersistor_External);
                m_registrarCore.Start(m_threadCount);
                m_sipTransport.SIPTransportRequestReceived += m_registrarCore.AddRegisterRequest;

                logger.Debug("SIP Registrar successfully started.");
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPRegistrarDaemon Start. " + excp.Message);
            }
        }
예제 #4
0
 public override void Initialize(SIPAuthenticateRequestDelegate sipRequestAuthenticator, SIPAccount account, SIPTransport transport)
 {
     PlatformType   = account.PlatformType;
     LocalSIPId     = account.LocalID;
     LocalEndPoint  = new SIPEndPoint(SIPProtocolsEnum.udp, account.LocalIP, account.LocalPort);
     RemoteSIPId    = account.RemoteID;
     RemoteEndPoint = new SIPEndPoint(SIPProtocolsEnum.udp, account.RemoteIP, account.RemotePort);
     Transport      = transport;
     MonitorService = new Dictionary <string, ISIPMonitorService>();
     if (PlatformType == PlatformType.DownPlatform)
     {
         m_registrarCore = new RegistrarCore(Transport, true, true, sipRequestAuthenticator);
         m_registrarCore.Start(1);
     }
 }
예제 #5
0
        public void Initialize(SIPAuthenticateRequestDelegate sipRequestAuthenticator,
                               Dictionary <string, PlatformConfig> platformList,
                               SIPAccount account)
        {
            LocalEndPoint = SIPEndPoint.ParseSIPEndPoint("udp:" + account.LocalIP.ToString() + ":" + account.LocalPort);
            LocalSIPId    = account.LocalID;
            //foreach (var account in accounts)
            //{
            //    SIPEndPoint remoteEP = SIPEndPoint.ParseSIPEndPoint("udp:" + account.SIPDomain);
            //    RemoteTrans.Add(remoteEP.ToString(), account.SIPUsername);
            //    if (LocalEndPoint == null)
            //    {
            //        LocalEndPoint = SIPEndPoint.ParseSIPEndPoint("udp:" + account.LocalIP.ToString() + ":" + account.LocalPort);
            //    }
            //    if (LocalSIPId == null)
            //    {
            //        LocalSIPId = account.LocalID;
            //    }
            //}

            m_registrarCore = new RegistrarCore(Transport, true, true, sipRequestAuthenticator);
            m_registrarCore.Start(1);
            MonitorService = new Dictionary <string, ISIPMonitorService>();

            foreach (var item in platformList)
            {
                string      sipEndPointStr = "udp:" + item.Value.RemoteIP + ":" + item.Value.RemotePort;
                SIPEndPoint sipPoint       = SIPEndPoint.ParseSIPEndPoint(sipEndPointStr);
                for (int i = 0; i < 2; i++)
                {
                    CommandType cmdType = CommandType.Unknown;
                    if (i == 0)
                    {
                        cmdType = CommandType.Play;
                    }
                    else
                    {
                        cmdType = CommandType.Playback;
                    }
                    string             key     = item.Key + cmdType;
                    ISIPMonitorService monitor = new SIPMonitorCore(this, item.Key, item.Value.ChannelName, sipPoint);
                    monitor.OnSIPServiceChanged += monitor_OnSIPServiceChanged;
                    MonitorService.Add(key, monitor);
                }
            }
        }
        public void Initialize(string switchboarduserAgentPrefix,
                               SIPAuthenticateRequestDelegate sipRequestAuthenticator,
                               GetCanonicalDomainDelegate getCanonicalDomain,
                               SIPAssetGetDelegate <SIPAccount> getSIPAccount,
                               SIPUserAgentConfigurationManager userAgentConfigs,
                               SIPRegistrarBindingsManager registrarBindingsManager,
                               Dictionary <string, string> devList)
        {
            m_registrarCore = new RegistrarCore(Transport, registrarBindingsManager, getSIPAccount, getCanonicalDomain, true, true, userAgentConfigs, sipRequestAuthenticator, switchboarduserAgentPrefix);
            m_registrarCore.Start(1);
            MonitorService = new Dictionary <string, ISIPMonitorService>();

            foreach (var item in devList)
            {
                ISIPMonitorService monitor = new SIPMonitorCore(this, item.Key, item.Value);
                monitor.OnSIPServiceChanged += monitor_OnSIPServiceChanged;
                MonitorService.Add(item.Key, monitor);
            }
        }