public Service(SIPAppServerDaemon daemon) { this.CanShutdown = true; this.CanStop = true; m_daemon = daemon; }
static void Main(string[] args) { bool isConsole = false; try { // Get DateTime.ToString() to use a format ot ToString("o") instead of ToString("G"). CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone(); culture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd"; culture.DateTimeFormat.LongTimePattern = "THH:mm:ss.fffffffzzz"; Thread.CurrentThread.CurrentCulture = culture; m_serverStorageType = (AppState.GetConfigSetting(m_storageTypeKey) != null) ? StorageTypesConverter.GetStorageType(AppState.GetConfigSetting(m_storageTypeKey)) : StorageTypes.Unknown; m_serverStorageConnStr = AppState.GetConfigSetting(m_connStrKey); bool monitorCalls = true; if (m_serverStorageType == StorageTypes.Unknown || m_serverStorageConnStr.IsNullOrBlank()) { throw new ApplicationException("The SIP Application Service cannot start with no persistence settings specified."); } // Need to force the System.Data.Entity assembly to load before a dialplan instantiation. The assembly will fail to load if // requested from the Dynamic Language Runtime which is what happens if the first time it's requested is in an IronRuby dialplan. using (SIPSorceryAppEntities appEntities = new SIPSorceryAppEntities()) { logger.Debug("Lookups count=" + (from lookup in appEntities.SIPDialplanLookups select lookup).Count() + ", forcing entity framework assemblies to load."); } //if (args != null && args.Length > 0) //{ isConsole = true; Console.WriteLine("SIP App Server starting"); logger.Debug("SIP App Server Console starting..."); string sipSocket = null; string callManagerSvcAddress = null; foreach (string arg in args) { if (arg.StartsWith("-sip:")) { sipSocket = arg.Substring(5); } else if (arg.StartsWith("-cms:")) { callManagerSvcAddress = arg.Substring(5); } else if (arg.StartsWith("-hangupcalls:")) { monitorCalls = Convert.ToBoolean(arg.Substring(13)); } } SIPAppServerDaemon daemon = null; if (sipSocket.IsNullOrBlank() || callManagerSvcAddress.IsNullOrBlank()) { daemon = new SIPAppServerDaemon(m_serverStorageType, m_serverStorageConnStr); } else { daemon = new SIPAppServerDaemon(m_serverStorageType, m_serverStorageConnStr, SIPEndPoint.ParseSIPEndPoint(sipSocket), callManagerSvcAddress, monitorCalls); } Thread daemonThread = new Thread(new ThreadStart(daemon.Start)); daemonThread.Start(); m_proxyUp.WaitOne(); //} //else //{ // logger.Debug("SIP App Server Windows Service Starting..."); // System.ServiceProcess.ServiceBase[] ServicesToRun; // SIPAppServerDaemon daemon = new SIPAppServerDaemon(m_serverStorageType, m_serverStorageConnStr); // ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service(daemon) }; // System.ServiceProcess.ServiceBase.Run(ServicesToRun); //} } catch (Exception excp) { Console.WriteLine("Exception SIP App Server Main. " + excp.Message); if (isConsole) { Console.WriteLine("press any key to exit..."); Console.ReadLine(); } } }
static void Main(string[] args) { bool isConsole = false; try { // Get DateTime.ToString() to use a format ot ToString("o") instead of ToString("G"). CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone(); culture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd"; culture.DateTimeFormat.LongTimePattern = "THH:mm:ss.fffffffzzz"; Thread.CurrentThread.CurrentCulture = culture; m_serverStorageType = (AppState.GetConfigSetting(m_storageTypeKey) != null) ? StorageTypesConverter.GetStorageType(AppState.GetConfigSetting(m_storageTypeKey)) : StorageTypes.Unknown; m_serverStorageConnStr = AppState.GetConfigSetting(m_connStrKey); bool monitorCalls = true; if (m_serverStorageType == StorageTypes.Unknown || m_serverStorageConnStr.IsNullOrBlank()) { throw new ApplicationException("The SIP Application Service cannot start with no persistence settings specified."); } // Need to force the System.Data.Entity assembly to load before a dialplan instantiation. The assembly will fail to load if // requested from the Dynamic Language Runtime which is what happens if the first time it's requested is in an IronRuby dialplan. using (SIPSorceryEntities appEntities = new SIPSorceryEntities()) { logger.Debug("Lookups count=" + (from lookup in appEntities.SIPDialplanLookups select lookup).Count() + ", forcing entity framework assemblies to load."); } //if (args != null && args.Length > 0) //{ isConsole = true; Console.WriteLine("SIP App Server starting"); logger.Debug("SIP App Server Console starting..."); string sipSocket = null; string callManagerSvcAddress = null; foreach (string arg in args) { if (arg.StartsWith("-sip:")) { sipSocket = arg.Substring(5); } else if (arg.StartsWith("-cms:")) { callManagerSvcAddress = arg.Substring(5); } else if (arg.StartsWith("-hangupcalls:")) { monitorCalls = Convert.ToBoolean(arg.Substring(13)); } } SIPAppServerDaemon daemon = null; if (sipSocket.IsNullOrBlank() || callManagerSvcAddress.IsNullOrBlank()) { daemon = new SIPAppServerDaemon(m_serverStorageType, m_serverStorageConnStr); } else { daemon = new SIPAppServerDaemon(m_serverStorageType, m_serverStorageConnStr, SIPEndPoint.ParseSIPEndPoint(sipSocket), callManagerSvcAddress, monitorCalls); } Thread daemonThread = new Thread(new ThreadStart(daemon.Start)); daemonThread.Start(); m_proxyUp.WaitOne(); //} //else //{ // logger.Debug("SIP App Server Windows Service Starting..."); // System.ServiceProcess.ServiceBase[] ServicesToRun; // SIPAppServerDaemon daemon = new SIPAppServerDaemon(m_serverStorageType, m_serverStorageConnStr); // ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service(daemon) }; // System.ServiceProcess.ServiceBase.Run(ServicesToRun); //} } catch (Exception excp) { Console.WriteLine("Exception SIP App Server Main. " + excp.Message); if (isConsole) { Console.WriteLine("press any key to exit..."); Console.ReadLine(); } } }