The Free Software Media System - Server Backend & API
Updates
BaronGreenback93568be3e7bb
diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.csindex 0b529c10d9..4f7af79263 100644--- a/Emby.Dlna/Main/DlnaEntryPoint.cs+++ b/Emby.Dlna/Main/DlnaEntryPoint.cs@@ -131,69 +131,20 @@ namespace Emby.Dlna.Main{await ((DlnaManager)_dlnaManager).InitProfilesAsync().ConfigureAwait(false);- ReloadComponents();+ await ReloadComponents().ConfigureAwait(false);- _config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;- }-- public void Dispose()- {- DisposeDevicePublisher();- DisposePlayToManager();- DisposeDeviceDiscovery();-- if (_communicationsServer != null)- {- _logger.LogInformation("Disposing SsdpCommunicationsServer");- _communicationsServer.Dispose();- _communicationsServer = null;- }-- ContentDirectory = null;- ConnectionManager = null;- MediaReceiverRegistrar = null;- Current = null;- }-- public async Task StartDevicePublisher(Configuration.DlnaOptions options)- {- if (!options.BlastAliveMessages)- {- return;- }-- if (_publisher != null)- {- return;- }-- try- {- _publisher = new SsdpDevicePublisher(_communicationsServer, _networkManager, OperatingSystem.Name, Environment.OSVersion.VersionString, _config.GetDlnaConfiguration().SendOnlyMatchedHost)- {- LogFunction = LogMessage,- SupportPnpRootDevice = false- };-- await RegisterServerEndpoints().ConfigureAwait(false);-- _publisher.StartBroadcastingAliveMessages(TimeSpan.FromSeconds(options.BlastAliveMessageIntervalSeconds));- }- catch (Exception ex)- {- _logger.LogError(ex, "Error registering endpoint");- }- }+ _config.NamedConfigurationUpdated += OnNamedConfigurationUpdated;+ }- void _config_NamedConfigurationUpdated(object sender, ConfigurationUpdateEventArgs e)+ private async void OnNamedConfigurationUpdated(object sender, ConfigurationUpdateEventArgs e){if (string.Equals(e.Key, "dlna", StringComparison.OrdinalIgnoreCase)){- ReloadComponents();+ await ReloadComponents().ConfigureAwait(false);}}- private async void ReloadComponents()+ private async Task ReloadComponents(){var options = _config.GetDlnaConfiguration();@@ -227,7 +178,7 @@ namespace Emby.Dlna.Mainvar enableMultiSocketBinding = OperatingSystem.Id == OperatingSystemId.Windows ||OperatingSystem.Id == OperatingSystemId.Linux;- _communicationsServer = new SsdpCommunicationsServer(_socketFactory, _networkManager, _logger, enableMultiSocketBinding)+ _communicationsServer = new SsdpCommunicationsServer(_config, _socketFactory, _networkManager, _logger, enableMultiSocketBinding){IsShared = true};@@ -271,6 +222,36 @@ namespace Emby.Dlna.Main}}+ public async Task StartDevicePublisher(Configuration.DlnaOptions options)+ {+ if (!options.BlastAliveMessages)+ {+ return;+ }++ if (_publisher != null)+ {+ return;+ }++ try+ {+ _publisher = new SsdpDevicePublisher(_communicationsServer, _networkManager, OperatingSystem.Name, Environment.OSVersion.VersionString, _config.GetDlnaConfiguration().SendOnlyMatchedHost)+ {+ LogFunction = LogMessage,+ SupportPnpRootDevice = false+ };++ await RegisterServerEndpoints().ConfigureAwait(false);++ _publisher.StartBroadcastingAliveMessages(TimeSpan.FromSeconds(options.BlastAliveMessageIntervalSeconds));+ }+ catch (Exception ex)+ {+ _logger.LogError(ex, "Error registering endpoint");+ }+ }+private async Task RegisterServerEndpoints(){var addresses = await _appHost.GetLocalIpAddresses(CancellationToken.None).ConfigureAwait(false);@@ -418,6 +399,25 @@ namespace Emby.Dlna.Main}}+ public void Dispose()+ {+ DisposeDevicePublisher();+ DisposePlayToManager();+ DisposeDeviceDiscovery();++ if (_communicationsServer != null)+ {+ _logger.LogInformation("Disposing SsdpCommunicationsServer");+ _communicationsServer.Dispose();+ _communicationsServer = null;+ }++ ContentDirectory = null;+ ConnectionManager = null;+ MediaReceiverRegistrar = null;+ Current = null;+ }+public void DisposeDevicePublisher(){if (_publisher != null)