private void ConfigurationMonitor_Changed(object sender, EventArgs e) { var errors = SipServerConfigurationSection.LoadSection(); if (errors.Count > 0) { // log errors! } else { var configuration = SipServerConfigurationSection.GetSection(); Tracer.Configure(configuration.TracingPath, configuration.IsTracingEnabled); wcfService.AdministratorPassword = configuration.AdministratorPassword; restapi.AdministratorPassword = configuration.AdministratorPassword; if (adUsers != null) { adUsers.Group = configuration.ActiveDirectoryGroup; } authorization.IsEnabled = configuration.IsAuthorizationEnabled; trunkManager.Clear(); Initializer.ConfigureVoipProviders(trunkManager, configuration); Initializer.ConfigureMras(mras, configuration); httpServer.WwwPath = configuration.WwwPath; transportLayer.ChangeSettings(configuration.WebSocketResponseFrame); proxyServerTU.IsOfficeSIPFiletransferEnabled = configuration.IsOfficeSIPFiletransferEnabled; } }
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); }); }); }