コード例 #1
0
        public SIPNotifierService(ISIPMonitorPublisher sipMonitorPublisher, CustomerSessionManager customerSessionManager) :
            base(customerSessionManager)
        {
            SIPSorceryConfiguration sipSorceryConfig = new SIPSorceryConfiguration();

            m_sipMonitorEventPublisher = sipMonitorPublisher;
        }
コード例 #2
0
 public SIPMonitorMediator(
    int eventListenerPort,
    string fileLogDirectory,
    ISIPMonitorPublisher sipMonitorPublisher)
 {
     m_eventListenerPort = eventListenerPort;
     m_fileLogDirectory = fileLogDirectory;
     m_clientManager = sipMonitorPublisher;
 }
コード例 #3
0
 public SIPMonitorMediator(
     int eventListenerPort,
     string fileLogDirectory,
     ISIPMonitorPublisher sipMonitorPublisher)
 {
     m_eventListenerPort = eventListenerPort;
     m_fileLogDirectory  = fileLogDirectory;
     m_clientManager     = sipMonitorPublisher;
 }
コード例 #4
0
 public SSHServerDaemon(CustomerSessionManager customerSessionManager)
 {
     m_customerSessionManager = customerSessionManager;
     if (m_udpNotificationReceiverSocket.IsNullOrBlank())
     {
         m_monitorPublisher = new MonitorProxyManager();
     }
     else
     {
         m_monitorPublisher = new SIPMonitorUDPSink(m_udpNotificationReceiverSocket);
     }
 }
コード例 #5
0
 public SSHServerDaemon(CustomerSessionManager customerSessionManager)
 {
     m_customerSessionManager = customerSessionManager;
     if (m_udpNotificationReceiverSocket.IsNullOrBlank())
     {
         m_monitorPublisher = new MonitorProxyManager();
     }
     else
     {
         m_monitorPublisher = new SIPMonitorUDPSink(m_udpNotificationReceiverSocket);
     }
 }
コード例 #6
0
        private Dictionary<string, SIPEventSubscription> m_subscriptions = new Dictionary<string, SIPEventSubscription>();    // [monitor session ID, subscription].

        public NotifierSubscriptionsManager(
            SIPMonitorLogDelegate logDelegate,
            SIPAssetGetListDelegate<SIPDialogueAsset> getDialogues,
            SIPAssetGetByIdDelegate<SIPDialogueAsset> getDialogue,
            SIPAssetPersistor<SIPAccount> sipAssetPersistor,
            SIPAssetCountDelegate<SIPRegistrarBinding> getBindingsCount,
            SIPTransport sipTransport,
            SIPEndPoint outboundProxy,
            ISIPMonitorPublisher publisher)
        {
            MonitorLogEvent_External = logDelegate;
            GetDialogues_External = getDialogues;
            GetDialogue_External = getDialogue;
            GetSIPRegistrarBindingsCount_External = getBindingsCount;
            m_sipAssetPersistor = sipAssetPersistor;
            m_sipTransport = sipTransport;
            m_outboundProxy = outboundProxy;
            m_publisher = publisher;
            m_publisher.MonitorEventReady += MonitorEventAvailable;
        }
コード例 #7
0
        private Dictionary <string, SIPEventSubscription> m_subscriptions = new Dictionary <string, SIPEventSubscription>(); // [monitor session ID, subscription].

        public NotifierSubscriptionsManager(
            SIPMonitorLogDelegate logDelegate,
            SIPAssetGetListDelegate <SIPDialogueAsset> getDialogues,
            SIPAssetGetByIdDelegate <SIPDialogueAsset> getDialogue,
            SIPAssetPersistor <SIPAccount> sipAssetPersistor,
            SIPAssetCountDelegate <SIPRegistrarBinding> getBindingsCount,
            SIPTransport sipTransport,
            SIPEndPoint outboundProxy,
            ISIPMonitorPublisher publisher)
        {
            MonitorLogEvent_External = logDelegate;
            GetDialogues_External    = getDialogues;
            GetDialogue_External     = getDialogue;
            GetSIPRegistrarBindingsCount_External = getBindingsCount;
            m_sipAssetPersistor            = sipAssetPersistor;
            m_sipTransport                 = sipTransport;
            m_outboundProxy                = outboundProxy;
            m_publisher                    = publisher;
            m_publisher.MonitorEventReady += MonitorEventAvailable;
        }
コード例 #8
0
ファイル: SIPNotifierDaemon.cs プロジェクト: xycui/sipsorcery
 public SIPNotifierDaemon(
     SIPAssetGetDelegate <Customer> getCustomer,
     SIPAssetGetListDelegate <SIPDialogueAsset> getDialogues,
     SIPAssetGetByIdDelegate <SIPDialogueAsset> getDialogue,
     GetCanonicalDomainDelegate getDomain,
     SIPAssetPersistor <SIPAccount> sipAsssetPersistor,
     SIPAssetGetListDelegate <SIPRegistrarBinding> getSIPRegistrarBindings,
     SIPAssetGetListDelegate <SIPAccount> getSIPAccounts,
     SIPAssetCountDelegate <SIPRegistrarBinding> getBindingsCount,
     SIPAuthenticateRequestDelegate sipRequestAuthenticator,
     ISIPMonitorPublisher publisher)
 {
     GetCustomer_External             = getCustomer;
     GetDialogues_External            = getDialogues;
     GetDialogue_External             = getDialogue;
     GetCanonicalDomain_External      = getDomain;
     m_sipAssetPersistor              = sipAsssetPersistor;
     GetSIPRegistrarBindings_External = getSIPRegistrarBindings;
     GetBindingsCount_External        = getBindingsCount;
     SIPAuthenticateRequest_External  = sipRequestAuthenticator;
     m_publisher = publisher ?? new SIPMonitorUDPSink(m_udpNotificationReceiverSocket);
 }
コード例 #9
0
        public SIPSorceryVT100Server(Customer customer)
        {
            m_customer             = customer;
            Username               = customer.CustomerUsername;
            AdminId                = customer.AdminId;
            m_notificationsAddress = Guid.NewGuid().ToString();

            try
            {
                m_publisher = Dependency.Resolve <ISIPMonitorPublisher>();
                m_publisher.NotificationReady += NotificationReady;
                m_publisher.MonitorEventReady += MonitorEventAvailable;
            }
            catch (ApplicationException appExcp)
            {
                logger.Debug("Unable to resolve ISIPMonitorPublisher. " + appExcp.Message);
            }

            WriteWelcomeMessage(customer);
            OutStream.Write(Encoding.ASCII.GetBytes(FILTER_COMMAND_PROMPT));
            ThreadPool.QueueUserWorkItem(delegate { Listen(); });
        }
コード例 #10
0
        public SIPSorceryVT100Server(Customer customer)
        {
            m_customer = customer;
            Username = customer.CustomerUsername;
            AdminId = customer.AdminId;
            m_notificationsAddress = Guid.NewGuid().ToString();

            try
            {
                m_publisher = Dependency.Resolve<ISIPMonitorPublisher>();
                m_publisher.NotificationReady += NotificationReady;
                m_publisher.MonitorEventReady += MonitorEventAvailable;
            }
            catch (ApplicationException appExcp)
            {
                logger.Debug("Unable to resolve ISIPMonitorPublisher. " + appExcp.Message);
            }

            WriteWelcomeMessage(customer);
            OutStream.Write(Encoding.ASCII.GetBytes(FILTER_COMMAND_PROMPT));
            ThreadPool.QueueUserWorkItem(delegate { Listen(); });
        }
コード例 #11
0
ファイル: SIPNotifierCore.cs プロジェクト: xycui/sipsorcery
        public NotifierCore(
            SIPMonitorLogDelegate logDelegate,
            SIPTransport sipTransport,
            SIPAssetGetDelegate <Customer> getCustomer,
            SIPAssetGetListDelegate <SIPDialogueAsset> getDialogues,
            SIPAssetGetByIdDelegate <SIPDialogueAsset> getDialogue,
            GetCanonicalDomainDelegate getCanonicalDomain,
            SIPAssetPersistor <SIPAccount> sipAssetPersistor,
            SIPAssetCountDelegate <SIPRegistrarBinding> getBindingsCount,
            SIPAuthenticateRequestDelegate sipRequestAuthenticator,
            SIPEndPoint outboundProxy,
            ISIPMonitorPublisher publisher)
        {
            MonitorLogEvent_External         = logDelegate;
            m_sipTransport                   = sipTransport;
            GetCustomer_External             = getCustomer;
            m_sipAssetPersistor              = sipAssetPersistor;
            GetCanonicalDomain_External      = getCanonicalDomain;
            SIPRequestAuthenticator_External = sipRequestAuthenticator;
            m_outboundProxy                  = outboundProxy;
            m_subscriptionsManager           = new NotifierSubscriptionsManager(MonitorLogEvent_External, getDialogues, getDialogue, m_sipAssetPersistor, getBindingsCount, m_sipTransport, m_outboundProxy, publisher);

            ThreadPool.QueueUserWorkItem(delegate { ProcessSubscribeRequest(NOTIFIER_THREAD_NAME_PREFIX + "1"); });
        }
コード例 #12
0
 public SIPMonitorDaemon(ISIPMonitorPublisher monitorEventPublisher)
 {
     m_monitorEventPublisher = monitorEventPublisher;
 }
コード例 #13
0
 public SSHServerDaemon(CustomerSessionManager customerSessionManager, ISIPMonitorPublisher monitorPublisher)
 {
     m_customerSessionManager = customerSessionManager;
     m_monitorPublisher       = monitorPublisher;
 }
 public SIPNotifierServiceInstanceProvider(ISIPMonitorPublisher sipMonitorPublisher, CustomerSessionManager customerSessionManager) {
     m_sipMonitorPublisher = sipMonitorPublisher;
     m_customerSessionManager = customerSessionManager;
 }
コード例 #15
0
        public NotifierCore(
            SIPMonitorLogDelegate logDelegate,
            SIPTransport sipTransport,
            SIPAssetGetDelegate<Customer> getCustomer,
            SIPAssetGetListDelegate<SIPDialogueAsset> getDialogues,
            SIPAssetGetByIdDelegate<SIPDialogueAsset> getDialogue,
            GetCanonicalDomainDelegate getCanonicalDomain,
            SIPAssetPersistor<SIPAccount> sipAssetPersistor,
            SIPAssetCountDelegate<SIPRegistrarBinding> getBindingsCount,
            SIPAuthenticateRequestDelegate sipRequestAuthenticator,
            SIPEndPoint outboundProxy,
            ISIPMonitorPublisher publisher)
        {
            MonitorLogEvent_External = logDelegate;
            m_sipTransport = sipTransport;
            GetCustomer_External = getCustomer;
            m_sipAssetPersistor = sipAssetPersistor;
            GetCanonicalDomain_External = getCanonicalDomain;
            SIPRequestAuthenticator_External = sipRequestAuthenticator;
            m_outboundProxy = outboundProxy;
            m_subscriptionsManager = new NotifierSubscriptionsManager(MonitorLogEvent_External, getDialogues, getDialogue, m_sipAssetPersistor, getBindingsCount, m_sipTransport, m_outboundProxy, publisher);

            ThreadPool.QueueUserWorkItem(delegate { ProcessSubscribeRequest(NOTIFIER_THREAD_NAME_PREFIX + "1"); });
        }
コード例 #16
0
 public SIPMonitorClientManagerHost(ISIPMonitorPublisher publisher)
 {
     m_publisher = publisher;
 }
コード例 #17
0
 public SIPNotifierService(ISIPMonitorPublisher sipMonitorPublisher, CustomerSessionManager customerSessionManager)
     : base(customerSessionManager)
 {
     SIPSorceryConfiguration sipSorceryConfig = new SIPSorceryConfiguration();
     m_sipMonitorEventPublisher = sipMonitorPublisher;
 }
 public SIPNotifierServiceInstanceProvider(ISIPMonitorPublisher sipMonitorPublisher, CustomerSessionManager customerSessionManager)
 {
     m_sipMonitorPublisher    = sipMonitorPublisher;
     m_customerSessionManager = customerSessionManager;
 }
コード例 #19
0
 public SSHServerDaemon(CustomerSessionManager customerSessionManager, ISIPMonitorPublisher monitorPublisher)
 {
     m_customerSessionManager = customerSessionManager;
     m_monitorPublisher = monitorPublisher;
 }
コード例 #20
0
 public SIPMonitorDaemon(ISIPMonitorPublisher monitorEventPublisher)
 {
     m_monitorEventPublisher = monitorEventPublisher;
 }
コード例 #21
0
 public SIPNotifierDaemon(
     SIPAssetGetDelegate<Customer> getCustomer,
     SIPAssetGetListDelegate<SIPDialogueAsset> getDialogues,
     SIPAssetGetByIdDelegate<SIPDialogueAsset> getDialogue,
     GetCanonicalDomainDelegate getDomain,
     SIPAssetPersistor<SIPAccount> sipAsssetPersistor,
     SIPAssetGetListDelegate<SIPRegistrarBinding> getSIPRegistrarBindings,
     SIPAssetGetListDelegate<SIPAccount> getSIPAccounts,
     SIPAssetCountDelegate<SIPRegistrarBinding> getBindingsCount,
     SIPAuthenticateRequestDelegate sipRequestAuthenticator,
     ISIPMonitorPublisher publisher)
 {
     GetCustomer_External = getCustomer;
     GetDialogues_External = getDialogues;
     GetDialogue_External = getDialogue;
     GetCanonicalDomain_External = getDomain;
     m_sipAssetPersistor = sipAsssetPersistor;
     GetSIPRegistrarBindings_External = getSIPRegistrarBindings;
     GetBindingsCount_External = getBindingsCount;
     SIPAuthenticateRequest_External = sipRequestAuthenticator;
     m_publisher = publisher ?? new SIPMonitorUDPSink(m_udpNotificationReceiverSocket);
 }
コード例 #22
0
        public void Start()
        {
            try
            {
                logger.Debug("pid=" + Process.GetCurrentProcess().Id + ".");
                logger.Debug("os=" + System.Environment.OSVersion + ".");
                logger.Debug("current directory=" + m_currentDirectory + ".");
                logger.Debug("base directory=" + AppDomain.CurrentDomain.BaseDirectory + ".");

                SIPDNSManager.SIPMonitorLogEvent = FireSIPMonitorEvent;
                m_sipSorceryPersistor            = new SIPSorceryPersistor(m_storageType, m_connectionString);
                m_customerSessionManager         = new CustomerSessionManager(m_storageType, m_connectionString);
                m_cdrDataLayer = new Entities.CDRDataLayer();

                if (m_sipProxyEnabled)
                {
                    m_sipProxyDaemon = new SIPProxyDaemon();
                    m_sipProxyDaemon.Start();

                    if (m_sipProxyDaemon.PublicIPAddress != null)
                    {
                        m_publicIPAddress = m_sipProxyDaemon.PublicIPAddress;
                        DialStringParser.PublicIPAddress     = m_sipProxyDaemon.PublicIPAddress;
                        DialPlanScriptFacade.PublicIPAddress = m_sipProxyDaemon.PublicIPAddress;
                        SIPDialogueManager.PublicIPAddress   = m_sipProxyDaemon.PublicIPAddress;
                    }
                    else
                    {
                        m_sipProxyDaemon.PublicIPAddressUpdated += (ipAddress) =>
                        {
                            if (ipAddress != null && (m_publicIPAddress == null || ipAddress.ToString() != m_publicIPAddress.ToString()))
                            {
                                m_publicIPAddress = ipAddress;
                                DialStringParser.PublicIPAddress     = ipAddress;
                                DialPlanScriptFacade.PublicIPAddress = ipAddress;
                                SIPDialogueManager.PublicIPAddress   = ipAddress;
                            }
                        };
                    }
                }

                if (m_sipMonitorEnabled)
                {
                    m_sipMonitorPublisher = new SIPMonitorClientManager(null);
                    m_sipMonitorDaemon    = new SIPMonitorDaemon(m_sipMonitorPublisher);
                    m_sipMonitorDaemon.Start();
                }

                if (m_sipRegistrarEnabled)
                {
                    m_sipRegistrarDaemon = new SIPRegistrarDaemon(
                        m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                        m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                        m_sipSorceryPersistor.SIPRegistrarBindingPersistor,
                        SIPRequestAuthenticator.AuthenticateSIPRequest,
                        m_customerSessionManager.CustomerPersistor);
                    m_sipRegistrarDaemon.Start();
                }

                if (m_sipRegAgentEnabled)
                {
                    m_sipRegAgentDaemon = new SIPRegAgentDaemon(
                        m_sipSorceryPersistor.SIPProvidersPersistor,
                        m_sipSorceryPersistor.SIPProviderBindingsPersistor);

                    m_sipRegAgentDaemon.Start();
                }

                if (m_sipNotifierEnabled)
                {
                    m_sipNotifierDaemon = new SIPNotifierDaemon(
                        m_customerSessionManager.CustomerPersistor.Get,
                        m_sipSorceryPersistor.SIPDialoguePersistor.Get,
                        m_sipSorceryPersistor.SIPDialoguePersistor.Get,
                        m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                        m_sipSorceryPersistor.SIPAccountsPersistor,
                        m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Get,
                        m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                        m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Count,
                        SIPRequestAuthenticator.AuthenticateSIPRequest,
                        m_sipMonitorPublisher);
                    //new SIPMonitorUDPSink("127.0.0.1:10003"));
                    m_sipNotifierDaemon.Start();
                }

                if (m_sshServerEnabled)
                {
                    SSHServerDaemon daemon = new SSHServerDaemon(m_customerSessionManager, m_sipMonitorPublisher); // Uses memory to transfer events.
                    //SSHServerDaemon daemon = new SSHServerDaemon(m_customerSessionManager, new SIPMonitorUDPSink("127.0.0.1:10002"));
                    daemon.Start();
                }

                #region Initialise the SIP Application Server and its logging mechanisms including CDRs.

                logger.Debug("Initiating SIP Application Server Agent.");

                // Send events from this process to the monitoring socket.
                if (m_monitorEventLoopbackPort != 0)
                {
                    m_monitorEventWriter = new SIPMonitorEventWriter(m_monitorEventLoopbackPort);
                }

                if (m_cdrDataLayer != null)
                {
                    SIPCDR.CDRCreated  += m_cdrDataLayer.Add;
                    SIPCDR.CDRAnswered += m_cdrDataLayer.Update;
                    SIPCDR.CDRHungup   += m_cdrDataLayer.Update;
                    SIPCDR.CDRUpdated  += m_cdrDataLayer.Update;
                }

                #region Initialise the SIPTransport layers.

                m_sipTransport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine(), true);
                if (m_appServerEndPoint != null)
                {
                    if (m_appServerEndPoint.Protocol == SIPProtocolsEnum.udp)
                    {
                        logger.Debug("Using single SIP transport socket for App Server " + m_appServerEndPoint.ToString() + ".");
                        m_sipTransport.AddSIPChannel(new SIPUDPChannel(m_appServerEndPoint.GetIPEndPoint()));
                    }
                    else if (m_appServerEndPoint.Protocol == SIPProtocolsEnum.tcp)
                    {
                        logger.Debug("Using single SIP transport socket for App Server " + m_appServerEndPoint.ToString() + ".");
                        m_sipTransport.AddSIPChannel(new SIPTCPChannel(m_appServerEndPoint.GetIPEndPoint()));
                    }
                    else
                    {
                        throw new ApplicationException("The SIP End Point of " + m_appServerEndPoint + " cannot be used with the App Server transport layer.");
                    }
                }
                else if (m_sipAppServerSocketsNode != null)
                {
                    m_sipTransport.AddSIPChannel(SIPTransportConfig.ParseSIPChannelsNode(m_sipAppServerSocketsNode));
                }
                else
                {
                    throw new ApplicationException("The SIP App Server could not be started, no SIP sockets have been configured.");
                }

                m_sipTransport.SIPRequestInTraceEvent     += LogSIPRequestIn;
                m_sipTransport.SIPRequestOutTraceEvent    += LogSIPRequestOut;
                m_sipTransport.SIPResponseInTraceEvent    += LogSIPResponseIn;
                m_sipTransport.SIPResponseOutTraceEvent   += LogSIPResponseOut;
                m_sipTransport.SIPBadRequestInTraceEvent  += LogSIPBadRequestIn;
                m_sipTransport.SIPBadResponseInTraceEvent += LogSIPBadResponseIn;

                #endregion

                m_dialPlanEngine = new DialPlanEngine(
                    m_sipTransport,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                    FireSIPMonitorEvent,
                    m_sipSorceryPersistor,
                    //m_sipSorceryPersistor.SIPAccountsPersistor,
                    //m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Get,
                    //m_sipSorceryPersistor.SIPDialPlanPersistor,
                    //m_sipSorceryPersistor.SIPDialoguePersistor,
                    m_outboundProxy,
                    m_rubyScriptCommonPath,
                    m_dialplanImpersonationUsername,
                    m_dialplanImpersonationPassword,
                    m_maxDialPlanExecutionLimit);

                m_sipDialogueManager = new SIPDialogueManager(
                    m_sipTransport,
                    m_outboundProxy,
                    FireSIPMonitorEvent,
                    m_sipSorceryPersistor.SIPDialoguePersistor,
                    m_sipSorceryPersistor.SIPCDRPersistor,
                    SIPRequestAuthenticator.AuthenticateSIPRequest,
                    m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain);

                m_callManager = new SIPCallManager(
                    m_sipTransport,
                    m_outboundProxy,
                    FireSIPMonitorEvent,
                    m_sipDialogueManager,
                    m_sipSorceryPersistor.SIPDialoguePersistor,
                    m_sipSorceryPersistor.SIPCDRPersistor,
                    m_dialPlanEngine,
                    m_sipSorceryPersistor.SIPDialPlanPersistor.Get,
                    m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                    m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Get,
                    m_sipSorceryPersistor.SIPProvidersPersistor.Get,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                    m_customerSessionManager.CustomerPersistor,
                    m_sipSorceryPersistor.SIPDialPlanPersistor,
                    m_traceDirectory,
                    m_monitorCalls,
                    m_dailyCallLimit);
                m_callManager.Start();

                GetSIPAccountDelegate getSIPAccount = (username, domain) =>
                {
                    return(m_sipSorceryPersistor.SIPAccountsPersistor.Get(x => x.SIPUsername == username && x.SIPDomain == domain).SIPAccount);
                };

                m_appServerCore = new SIPAppServerCore(
                    m_sipTransport,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                    getSIPAccount,
                    FireSIPMonitorEvent,
                    m_callManager,
                    m_sipDialogueManager,
                    SIPRequestAuthenticator.AuthenticateSIPRequest,
                    m_outboundProxy);

                m_rtccCore = new RTCCCore(
                    FireSIPMonitorEvent,
                    m_sipDialogueManager,
                    m_sipSorceryPersistor.SIPDialoguePersistor);
                m_rtccCore.Start();

                m_rateUpdater = new RateBulkUpdater(FireSIPMonitorEvent);
                m_rateUpdater.Start();

                #endregion

                #region Initialise WCF services.

                try
                {
                    if (WCFUtility.DoesWCFServiceExist(typeof(SIPProvisioningWebService).FullName.ToString()))
                    {
                        if (m_sipSorceryPersistor == null)
                        {
                            logger.Warn("Provisioning hosted service could not be started as Persistor object was null.");
                        }
                        else
                        {
                            SIPProviderBindingSynchroniser sipProviderBindingSynchroniser = new SIPProviderBindingSynchroniser(m_sipSorceryPersistor.SIPProviderBindingsPersistor);
                            m_sipSorceryPersistor.SIPProvidersPersistor.Added   += sipProviderBindingSynchroniser.SIPProviderAdded;
                            m_sipSorceryPersistor.SIPProvidersPersistor.Updated += sipProviderBindingSynchroniser.SIPProviderUpdated;
                            m_sipSorceryPersistor.SIPProvidersPersistor.Deleted += sipProviderBindingSynchroniser.SIPProviderDeleted;

                            ProvisioningServiceInstanceProvider instanceProvider = new ProvisioningServiceInstanceProvider(
                                m_sipSorceryPersistor.SIPAccountsPersistor,
                                m_sipSorceryPersistor.SIPDialPlanPersistor,
                                m_sipSorceryPersistor.SIPProvidersPersistor,
                                m_sipSorceryPersistor.SIPProviderBindingsPersistor,
                                m_sipSorceryPersistor.SIPRegistrarBindingPersistor,
                                m_sipSorceryPersistor.SIPDialoguePersistor,
                                m_sipSorceryPersistor.SIPCDRPersistor,
                                m_customerSessionManager,
                                m_sipSorceryPersistor.SIPDomainManager,
                                FireSIPMonitorEvent,
                                0,
                                false);

                            m_sipProvisioningHost = new ServiceHost(typeof(SIPProvisioningWebService));
                            m_sipProvisioningHost.Description.Behaviors.Add(instanceProvider);
                            m_sipProvisioningHost.Open();

                            if (m_sipRegAgentDaemon == null)
                            {
                                m_sipRegAgentDaemon = new SIPRegAgentDaemon(
                                    m_sipSorceryPersistor.SIPProvidersPersistor,
                                    m_sipSorceryPersistor.SIPProviderBindingsPersistor);
                            }

                            logger.Debug("Provisioning hosted service successfully started on " + m_sipProvisioningHost.BaseAddresses[0].AbsoluteUri + ".");
                        }
                    }
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception starting Provisioning hosted service. " + excp.Message);
                }

                try
                {
                    if (WCFUtility.DoesWCFServiceExist(typeof(CrossDomainService).FullName.ToString()))
                    {
                        m_accessPolicyHost = new ServiceHost(typeof(CrossDomainService));
                        m_accessPolicyHost.Open();

                        logger.Debug("CrossDomain hosted service successfully started on " + m_accessPolicyHost.BaseAddresses[0].AbsoluteUri + ".");
                    }
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception starting CrossDomain hosted service. " + excp.Message);
                }

                try
                {
                    if (WCFUtility.DoesWCFServiceExist(typeof(CallManagerServices).FullName.ToString()))
                    {
                        CallManagerServiceInstanceProvider callManagerSvcInstanceProvider = new CallManagerServiceInstanceProvider(m_callManager, m_sipDialogueManager);

                        Uri callManagerBaseAddress = null;
                        if (m_callManagerServiceAddress != null)
                        {
                            logger.Debug("Adding service address to Call Manager Service " + m_callManagerServiceAddress + ".");
                            callManagerBaseAddress = new Uri(m_callManagerServiceAddress);
                        }

                        if (callManagerBaseAddress != null)
                        {
                            m_callManagerSvcHost = new ServiceHost(typeof(CallManagerServices), callManagerBaseAddress);
                        }
                        else
                        {
                            m_callManagerSvcHost = new ServiceHost(typeof(CallManagerServices));
                        }

                        m_callManagerSvcHost.Description.Behaviors.Add(callManagerSvcInstanceProvider);

                        m_callManagerSvcHost.Open();

                        logger.Debug("CallManager hosted service successfully started on " + m_callManagerSvcHost.BaseAddresses[0].AbsoluteUri + ".");
                    }
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception starting CallManager hosted service. " + excp.Message);
                }

                if (WCFUtility.DoesWCFServiceExist(typeof(SIPNotifierService).FullName.ToString()))
                {
                    if (m_sipMonitorPublisher != null)
                    {
                        try
                        {
                            SIPNotifierService notifierService = new SIPNotifierService(m_sipMonitorPublisher, m_customerSessionManager);
                            m_sipNotificationsHost = new ServiceHost(notifierService);

                            m_sipNotificationsHost.Open();

                            logger.Debug("SIPNotificationsService hosted service successfully started on " + m_sipNotificationsHost.BaseAddresses[0].AbsoluteUri + ".");
                        }
                        catch (Exception excp)
                        {
                            logger.Warn("Exception starting SIPNotificationsService hosted service. " + excp.Message);
                        }
                    }
                }

                #endregion
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPAppServerDaemon Start. " + excp.Message);
                throw excp;
            }
        }
コード例 #23
0
        public void Start()
        {
            try
            {
                logger.Debug("pid=" + Process.GetCurrentProcess().Id + ".");
                logger.Debug("os=" + System.Environment.OSVersion + ".");
                logger.Debug("current directory=" + m_currentDirectory + ".");
                logger.Debug("base directory=" + AppDomain.CurrentDomain.BaseDirectory + ".");

                SIPDNSManager.SIPMonitorLogEvent = FireSIPMonitorEvent;
                m_sipSorceryPersistor = new SIPSorceryPersistor(m_storageType, m_connectionString);
                m_customerSessionManager = new CustomerSessionManager(m_storageType, m_connectionString);
                m_cdrDataLayer = new Entities.CDRDataLayer();

                if (m_sipProxyEnabled)
                {
                    m_sipProxyDaemon = new SIPProxyDaemon();
                    m_sipProxyDaemon.Start();

                    if (m_sipProxyDaemon.PublicIPAddress != null)
                    {
                        m_publicIPAddress = m_sipProxyDaemon.PublicIPAddress;
                        DialStringParser.PublicIPAddress = m_sipProxyDaemon.PublicIPAddress;
                        DialPlanScriptFacade.PublicIPAddress = m_sipProxyDaemon.PublicIPAddress;
                        SIPDialogueManager.PublicIPAddress = m_sipProxyDaemon.PublicIPAddress;
                    }
                    else
                    {
                        m_sipProxyDaemon.PublicIPAddressUpdated += (ipAddress) =>
                        {
                            if (ipAddress != null && (m_publicIPAddress == null || ipAddress.ToString() != m_publicIPAddress.ToString()))
                            {
                                m_publicIPAddress = ipAddress;
                                DialStringParser.PublicIPAddress = ipAddress;
                                DialPlanScriptFacade.PublicIPAddress = ipAddress;
                                SIPDialogueManager.PublicIPAddress = ipAddress;
                            }
                        };
                    }
                }

                if (m_sipMonitorEnabled)
                {
                    m_sipMonitorPublisher = new SIPMonitorClientManager(null);
                    m_sipMonitorDaemon = new SIPMonitorDaemon(m_sipMonitorPublisher);
                    m_sipMonitorDaemon.Start();
                }

                if (m_sipRegistrarEnabled)
                {
                    m_sipRegistrarDaemon = new SIPRegistrarDaemon(
                        m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                        m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                        m_sipSorceryPersistor.SIPRegistrarBindingPersistor,
                        SIPRequestAuthenticator.AuthenticateSIPRequest,
                        m_customerSessionManager.CustomerPersistor);
                    m_sipRegistrarDaemon.Start();
                }

                if (m_sipRegAgentEnabled)
                {
                    m_sipRegAgentDaemon = new SIPRegAgentDaemon(
                        m_sipSorceryPersistor.SIPProvidersPersistor,
                        m_sipSorceryPersistor.SIPProviderBindingsPersistor);

                    m_sipRegAgentDaemon.Start();
                }

                if (m_sipNotifierEnabled)
                {
                    m_sipNotifierDaemon = new SIPNotifierDaemon(
                        m_customerSessionManager.CustomerPersistor.Get,
                        m_sipSorceryPersistor.SIPDialoguePersistor.Get,
                        m_sipSorceryPersistor.SIPDialoguePersistor.Get,
                        m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                        m_sipSorceryPersistor.SIPAccountsPersistor,
                        m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Get,
                        m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                        m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Count,
                        SIPRequestAuthenticator.AuthenticateSIPRequest,
                        m_sipMonitorPublisher);
                    //new SIPMonitorUDPSink("127.0.0.1:10003"));
                    m_sipNotifierDaemon.Start();
                }

                if (m_sshServerEnabled)
                {
                    SSHServerDaemon daemon = new SSHServerDaemon(m_customerSessionManager, m_sipMonitorPublisher); // Uses memory to transfer events.
                    //SSHServerDaemon daemon = new SSHServerDaemon(m_customerSessionManager, new SIPMonitorUDPSink("127.0.0.1:10002"));
                    daemon.Start();
                }

                #region Initialise the SIP Application Server and its logging mechanisms including CDRs.

                logger.Debug("Initiating SIP Application Server Agent.");

                // Send events from this process to the monitoring socket.
                if (m_monitorEventLoopbackPort != 0)
                {
                    m_monitorEventWriter = new SIPMonitorEventWriter(m_monitorEventLoopbackPort);
                }

                if (m_cdrDataLayer != null)
                {
                    SIPCDR.CDRCreated += m_cdrDataLayer.Add;
                    SIPCDR.CDRAnswered += m_cdrDataLayer.Update;
                    SIPCDR.CDRHungup += m_cdrDataLayer.Update;
                    SIPCDR.CDRUpdated += m_cdrDataLayer.Update;
                }

                #region Initialise the SIPTransport layers.

                m_sipTransport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine(), true);
                if (m_appServerEndPoint != null)
                {
                    if (m_appServerEndPoint.Protocol == SIPProtocolsEnum.udp)
                    {
                        logger.Debug("Using single SIP transport socket for App Server " + m_appServerEndPoint.ToString() + ".");
                        m_sipTransport.AddSIPChannel(new SIPUDPChannel(m_appServerEndPoint.GetIPEndPoint()));
                    }
                    else if (m_appServerEndPoint.Protocol == SIPProtocolsEnum.tcp)
                    {
                        logger.Debug("Using single SIP transport socket for App Server " + m_appServerEndPoint.ToString() + ".");
                        m_sipTransport.AddSIPChannel(new SIPTCPChannel(m_appServerEndPoint.GetIPEndPoint()));
                    }
                    else
                    {
                        throw new ApplicationException("The SIP End Point of " + m_appServerEndPoint + " cannot be used with the App Server transport layer.");
                    }
                }
                else if (m_sipAppServerSocketsNode != null)
                {
                    m_sipTransport.AddSIPChannel(SIPTransportConfig.ParseSIPChannelsNode(m_sipAppServerSocketsNode));
                }
                else
                {
                    throw new ApplicationException("The SIP App Server could not be started, no SIP sockets have been configured.");
                }

                m_sipTransport.SIPRequestInTraceEvent += LogSIPRequestIn;
                m_sipTransport.SIPRequestOutTraceEvent += LogSIPRequestOut;
                m_sipTransport.SIPResponseInTraceEvent += LogSIPResponseIn;
                m_sipTransport.SIPResponseOutTraceEvent += LogSIPResponseOut;
                m_sipTransport.SIPBadRequestInTraceEvent += LogSIPBadRequestIn;
                m_sipTransport.SIPBadResponseInTraceEvent += LogSIPBadResponseIn;

                #endregion

                m_dialPlanEngine = new DialPlanEngine(
                    m_sipTransport,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                    FireSIPMonitorEvent,
                    m_sipSorceryPersistor,
                    //m_sipSorceryPersistor.SIPAccountsPersistor,
                    //m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Get,
                    //m_sipSorceryPersistor.SIPDialPlanPersistor,
                    //m_sipSorceryPersistor.SIPDialoguePersistor,
                    m_outboundProxy,
                    m_rubyScriptCommonPath,
                    m_dialplanImpersonationUsername,
                    m_dialplanImpersonationPassword,
                    m_maxDialPlanExecutionLimit);

                m_sipDialogueManager = new SIPDialogueManager(
                    m_sipTransport,
                     m_outboundProxy,
                     FireSIPMonitorEvent,
                     m_sipSorceryPersistor.SIPDialoguePersistor,
                     m_sipSorceryPersistor.SIPCDRPersistor,
                     SIPRequestAuthenticator.AuthenticateSIPRequest,
                     m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                     m_sipSorceryPersistor.SIPDomainManager.GetDomain);

                m_callManager = new SIPCallManager(
                     m_sipTransport,
                     m_outboundProxy,
                     FireSIPMonitorEvent,
                     m_sipDialogueManager,
                     m_sipSorceryPersistor.SIPDialoguePersistor,
                     m_sipSorceryPersistor.SIPCDRPersistor,
                     m_dialPlanEngine,
                     m_sipSorceryPersistor.SIPDialPlanPersistor.Get,
                     m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                     m_sipSorceryPersistor.SIPRegistrarBindingPersistor.Get,
                     m_sipSorceryPersistor.SIPProvidersPersistor.Get,
                     m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                     m_customerSessionManager.CustomerPersistor,
                     m_sipSorceryPersistor.SIPDialPlanPersistor,
                     m_traceDirectory,
                     m_monitorCalls,
                     m_dailyCallLimit);
                m_callManager.Start();

                m_appServerCore = new SIPAppServerCore(
                    m_sipTransport,
                    m_sipSorceryPersistor.SIPDomainManager.GetDomain,
                    m_sipSorceryPersistor.SIPAccountsPersistor.Get,
                    FireSIPMonitorEvent,
                    m_callManager,
                    m_sipDialogueManager,
                    SIPRequestAuthenticator.AuthenticateSIPRequest,
                    m_outboundProxy);

                m_rtccCore = new RTCCCore(
                    FireSIPMonitorEvent,
                    m_sipDialogueManager,
                    m_sipSorceryPersistor.SIPDialoguePersistor);
                m_rtccCore.Start();

                m_rateUpdater = new RateBulkUpdater(FireSIPMonitorEvent);
                m_rateUpdater.Start();

                #endregion

                #region Initialise WCF services.

                try
                {
                    if (WCFUtility.DoesWCFServiceExist(typeof(SIPProvisioningWebService).FullName.ToString()))
                    {
                        if (m_sipSorceryPersistor == null)
                        {
                            logger.Warn("Provisioning hosted service could not be started as Persistor object was null.");
                        }
                        else
                        {
                            SIPProviderBindingSynchroniser sipProviderBindingSynchroniser = new SIPProviderBindingSynchroniser(m_sipSorceryPersistor.SIPProviderBindingsPersistor);
                            m_sipSorceryPersistor.SIPProvidersPersistor.Added += sipProviderBindingSynchroniser.SIPProviderAdded;
                            m_sipSorceryPersistor.SIPProvidersPersistor.Updated += sipProviderBindingSynchroniser.SIPProviderUpdated;
                            m_sipSorceryPersistor.SIPProvidersPersistor.Deleted += sipProviderBindingSynchroniser.SIPProviderDeleted;

                            ProvisioningServiceInstanceProvider instanceProvider = new ProvisioningServiceInstanceProvider(
                                m_sipSorceryPersistor.SIPAccountsPersistor,
                                m_sipSorceryPersistor.SIPDialPlanPersistor,
                                m_sipSorceryPersistor.SIPProvidersPersistor,
                                m_sipSorceryPersistor.SIPProviderBindingsPersistor,
                                m_sipSorceryPersistor.SIPRegistrarBindingPersistor,
                                m_sipSorceryPersistor.SIPDialoguePersistor,
                                m_sipSorceryPersistor.SIPCDRPersistor,
                                m_customerSessionManager,
                                m_sipSorceryPersistor.SIPDomainManager,
                                FireSIPMonitorEvent,
                                0,
                                false);

                            m_sipProvisioningHost = new ServiceHost(typeof(SIPProvisioningWebService));
                            m_sipProvisioningHost.Description.Behaviors.Add(instanceProvider);
                            m_sipProvisioningHost.Open();

                            if (m_sipRegAgentDaemon == null)
                            {
                                m_sipRegAgentDaemon = new SIPRegAgentDaemon(
                                    m_sipSorceryPersistor.SIPProvidersPersistor,
                                    m_sipSorceryPersistor.SIPProviderBindingsPersistor);
                            }

                            logger.Debug("Provisioning hosted service successfully started on " + m_sipProvisioningHost.BaseAddresses[0].AbsoluteUri + ".");
                        }
                    }
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception starting Provisioning hosted service. " + excp.Message);
                }

                try
                {
                    if (WCFUtility.DoesWCFServiceExist(typeof(CrossDomainService).FullName.ToString()))
                    {
                        m_accessPolicyHost = new ServiceHost(typeof(CrossDomainService));
                        m_accessPolicyHost.Open();

                        logger.Debug("CrossDomain hosted service successfully started on " + m_accessPolicyHost.BaseAddresses[0].AbsoluteUri + ".");
                    }
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception starting CrossDomain hosted service. " + excp.Message);
                }

                try
                {
                    if (WCFUtility.DoesWCFServiceExist(typeof(CallManagerServices).FullName.ToString()))
                    {
                        CallManagerServiceInstanceProvider callManagerSvcInstanceProvider = new CallManagerServiceInstanceProvider(m_callManager, m_sipDialogueManager);

                        Uri callManagerBaseAddress = null;
                        if (m_callManagerServiceAddress != null)
                        {
                            logger.Debug("Adding service address to Call Manager Service " + m_callManagerServiceAddress + ".");
                            callManagerBaseAddress = new Uri(m_callManagerServiceAddress);
                        }

                        if (callManagerBaseAddress != null)
                        {
                            m_callManagerSvcHost = new ServiceHost(typeof(CallManagerServices), callManagerBaseAddress);
                        }
                        else
                        {
                            m_callManagerSvcHost = new ServiceHost(typeof(CallManagerServices));
                        }

                        m_callManagerSvcHost.Description.Behaviors.Add(callManagerSvcInstanceProvider);

                        m_callManagerSvcHost.Open();

                        logger.Debug("CallManager hosted service successfully started on " + m_callManagerSvcHost.BaseAddresses[0].AbsoluteUri + ".");
                    }
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception starting CallManager hosted service. " + excp.Message);
                }

                if (WCFUtility.DoesWCFServiceExist(typeof(SIPNotifierService).FullName.ToString()))
                {
                    if (m_sipMonitorPublisher != null)
                    {
                        try
                        {
                            SIPNotifierService notifierService = new SIPNotifierService(m_sipMonitorPublisher, m_customerSessionManager);
                            m_sipNotificationsHost = new ServiceHost(notifierService);

                            m_sipNotificationsHost.Open();

                            logger.Debug("SIPNotificationsService hosted service successfully started on " + m_sipNotificationsHost.BaseAddresses[0].AbsoluteUri + ".");
                        }
                        catch (Exception excp)
                        {
                            logger.Warn("Exception starting SIPNotificationsService hosted service. " + excp.Message);
                        }
                    }
                }

                #endregion
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPAppServerDaemon Start. " + excp.Message);
                throw excp;
            }
        }
コード例 #24
0
        public event Func <SIPMonitorEvent, bool> MonitorEventReady; // Not used.

        public SIPMonitorClientManagerHost(ISIPMonitorPublisher publisher)
        {
            m_publisher = publisher;
        }