Esempio n. 1
0
        public Server()
        {
#if !DEBUG
            crashHandler = new CrashHandler();
#endif
            HttpMessage.BufferManager = SipMessage.BufferManager = new BufferManagerProxy();

            LoadConfiguration();

            var configuration = SipServerConfigurationSection.GetSection();

            if (configuration.AddToWindowsFirewall)
            {
                AddFirewallException();
            }

            if (BufferManager.IsInitialized() == false)
            {
                BufferManager.Initialize(Math.Min((int)(GetTotalMemoryInBytes() / (1024 * 1024) / 2), 2048));
            }

            if (Directory.Exists(configuration.AccountsPath) == false)
            {
                Directory.CreateDirectory(configuration.AccountsPath);
            }

            var initializer = new Initializer(ConfigurationMonitor_Changed);

            initializer.GetResults(
                out transportLayer,
                out transactionLayer,
                out locationService,
                out wcfService,
                out configurationMonitor,
                out trunkManager,
                out authorization,
                out userz,
                out adUsers,
                out mras,
                out httpServer,
                out accounts,
                out restapi,
                out proxyServerTU);

            if (configuration.IsActiveDirectoryEnabled)
            {
                accounts.ForEach((account) =>
                {
                    SetSpn(@"sip/" + account.DomainName);
                });
            }

            RestapiUriParser.LoadTables(configuration.ExePath);
            XcapUriParser.LoadTables(configuration.ExePath);

            Http.Message.HttpMessageReader.InitializeAsync(
                (ms1) =>
            {
                Sip.Message.SipMessageReader.InitializeAsync(
                    (ms2) =>
                {
                    Tracer.WriteImportant(@"JIT-compilation Http.Message.dll " + (ms1 / 1000).ToString() + ", Sip.Message.dll: " + (ms2 / 1000).ToString() + " seconds.");

                    try
                    {
                        transportLayer.Start();
                        Tracer.WriteImportant(@"Server started.");
                    }
                    catch (Exception ex)
                    {
                        Tracer.WriteException(@"Failed to start Servers Manager.", ex);
                    }

                    Initializer.ConfigureVoipProviders(trunkManager, configuration);
                });
            });
        }
Esempio n. 2
0
        public Server()
        {
#if !DEBUG
			crashHandler = new CrashHandler();
#endif
            HttpMessage.BufferManager = SipMessage.BufferManager = new BufferManagerProxy();

            LoadConfiguration();

            var configuration = SipServerConfigurationSection.GetSection();

            if (configuration.AddToWindowsFirewall)
                AddFirewallException();

            if (BufferManager.IsInitialized() == false)
                BufferManager.Initialize(Math.Min((int)(GetTotalMemoryInBytes() / (1024 * 1024) / 2), 2048));

            if (Directory.Exists(configuration.AccountsPath) == false)
                Directory.CreateDirectory(configuration.AccountsPath);

            var initializer = new Initializer(ConfigurationMonitor_Changed);

            initializer.GetResults(
                out transportLayer,
                out transactionLayer,
                out locationService,
                out wcfService,
                out configurationMonitor,
                out trunkManager,
                out authorization,
                out userz,
                out adUsers,
                out mras,
                out httpServer,
                out accounts,
                out restapi,
                out proxyServerTU);

            if (configuration.IsActiveDirectoryEnabled)
            {
                accounts.ForEach((account) =>
                    {
                        SetSpn(@"sip/" + account.DomainName);
                    });
            }

            RestapiUriParser.LoadTables(configuration.ExePath);
            XcapUriParser.LoadTables(configuration.ExePath);

            Http.Message.HttpMessageReader.InitializeAsync(
                (ms1) =>
                {
                    Sip.Message.SipMessageReader.InitializeAsync(
                        (ms2) =>
                        {
                            Tracer.WriteImportant(@"JIT-compilation Http.Message.dll " + (ms1 / 1000).ToString() + ", Sip.Message.dll: " + (ms2 / 1000).ToString() + " seconds.");

                            try
                            {
                                transportLayer.Start();
                                Tracer.WriteImportant(@"Server started.");
                            }
                            catch (Exception ex)
                            {
                                Tracer.WriteException(@"Failed to start Servers Manager.", ex);
                            }

                            Initializer.ConfigureVoipProviders(trunkManager, configuration);
                        });
                });
        }