The Free Software Media System - Server Backend & API
reduce socket activity
Luke Pulverenti983b51e0830e
diff --git a/Emby.Dlna/Eventing/EventManager.cs b/Emby.Dlna/Eventing/EventManager.csindex 0516585ae0..99ba74f327 100644--- a/Emby.Dlna/Eventing/EventManager.cs+++ b/Emby.Dlna/Eventing/EventManager.cs@@ -26,9 +26,11 @@ namespace Emby.Dlna.Eventing_logger = logger;}- public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string requestedTimeoutString)+ public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string notificationType, string requestedTimeoutString, string callbackUrl){- var subscription = GetSubscription(subscriptionId, true);+ var subscription = GetSubscription(subscriptionId, false);++ int timeoutSeconds;// Remove logging for now because some devices are sending this very frequently// TODO re-enable with dlna debug logging setting@@ -37,10 +39,18 @@ namespace Emby.Dlna.Eventing// timeout,// subscription.CallbackUrl);- subscription.TimeoutSeconds = ParseTimeout(requestedTimeoutString) ?? 300;- subscription.SubscriptionTime = DateTime.UtcNow;+ if (subscription != null)+ {+ subscription.TimeoutSeconds = ParseTimeout(requestedTimeoutString) ?? 300;+ timeoutSeconds = subscription.TimeoutSeconds;+ subscription.SubscriptionTime = DateTime.UtcNow;+ }+ else+ {+ timeoutSeconds = 300;+ }- return GetEventSubscriptionResponse(subscriptionId, requestedTimeoutString, subscription.TimeoutSeconds);+ return GetEventSubscriptionResponse(subscriptionId, requestedTimeoutString, timeoutSeconds);}public EventSubscriptionResponse CreateEventSubscription(string notificationType, string requestedTimeoutString, string callbackUrl)diff --git a/Emby.Dlna/Service/BaseService.cs b/Emby.Dlna/Service/BaseService.csindex ddc37da095..bc7f01d974 100644--- a/Emby.Dlna/Service/BaseService.cs+++ b/Emby.Dlna/Service/BaseService.cs@@ -24,9 +24,9 @@ namespace Emby.Dlna.Servicereturn EventManager.CancelEventSubscription(subscriptionId);}- public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string timeoutString)+ public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string notificationType, string timeoutString, string callbackUrl){- return EventManager.RenewEventSubscription(subscriptionId, timeoutString);+ return EventManager.RenewEventSubscription(subscriptionId, notificationType, timeoutString, callbackUrl);}public EventSubscriptionResponse CreateEventSubscription(string notificationType, string timeoutString, string callbackUrl)diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.csindex 0d85a977c5..125d9e980f 100644--- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs+++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs@@ -1,5 +1,6 @@using System;using System.Collections.Generic;+using System.Diagnostics;using System.IO;using System.Linq;using System.Text;@@ -24,12 +25,14 @@ namespace Emby.Server.Implementations.IOprivate string _tempPath;private SharpCifsFileSystem _sharpCifsFileSystem;+ private IEnvironmentInfo _environmentInfo;public ManagedFileSystem(ILogger logger, IEnvironmentInfo environmentInfo, string tempPath){Logger = logger;_supportsAsyncFileStreams = true;_tempPath = tempPath;+ _environmentInfo = environmentInfo;// On Linux, this needs to be true or symbolic links are ignoredEnableFileSystemRequestConcat = environmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows &&@@ -1051,7 +1054,25 @@ namespace Emby.Server.Implementations.IOpublic virtual void SetExecutable(string path){+ if (_environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.OSX)+ {+ RunProcess("chmod", "+x \"" + path + "\"", GetDirectoryName(path));+ }+ }+ private void RunProcess(string path, string args, string workingDirectory)+ {+ using (var process = Process.Start(new ProcessStartInfo+ {+ Arguments = args,+ FileName = path,+ CreateNoWindow = true,+ WorkingDirectory = workingDirectory,+ WindowStyle = ProcessWindowStyle.Normal+ }))+ {+ process.WaitForExit();+ }}}}diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.csindex 1804630403..772f2338ac 100644--- a/Emby.Server.Implementations/Updates/InstallationManager.cs+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs@@ -442,11 +442,6 @@ namespace Emby.Server.Implementations.Updates/// <returns>Task{IEnumerable{PackageVersionInfo}}.</returns>public async Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(Version applicationVersion, bool withAutoUpdateEnabled, CancellationToken cancellationToken){- if (!_config.CommonConfiguration.EnableAutoUpdate)- {- return new PackageVersionInfo[] { };- }-var catalog = await GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false);var systemUpdateLevel = GetSystemUpdateLevel();diff --git a/MediaBrowser.Api/Dlna/DlnaServerService.cs b/MediaBrowser.Api/Dlna/DlnaServerService.csindex cbef6e5b3b..6a0cea4df9 100644--- a/MediaBrowser.Api/Dlna/DlnaServerService.cs+++ b/MediaBrowser.Api/Dlna/DlnaServerService.cs@@ -246,7 +246,7 @@ namespace MediaBrowser.Api.Dlnaif (string.IsNullOrEmpty(notificationType)){- return GetSubscriptionResponse(eventManager.RenewEventSubscription(subscriptionId, timeoutString));+ return GetSubscriptionResponse(eventManager.RenewEventSubscription(subscriptionId, notificationType, timeoutString, callback));}return GetSubscriptionResponse(eventManager.CreateEventSubscription(notificationType, timeoutString, callback));diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csprojindex ddb187f3d9..650306ea60 100644--- a/MediaBrowser.Api/MediaBrowser.Api.csproj+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj@@ -40,7 +40,6 @@<Compile Include="..\SharedVersion.cs"><Link>Properties\SharedVersion.cs</Link></Compile>- <Compile Include="BasePeriodicWebSocketListener.cs" /><Compile Include="BrandingService.cs" /><Compile Include="ChannelService.cs" /><Compile Include="Devices\DeviceService.cs" />diff --git a/MediaBrowser.Api/ScheduledTasks/ScheduledTasksWebSocketListener.cs b/MediaBrowser.Api/ScheduledTasks/ScheduledTasksWebSocketListener.csindex ee74ec450c..69ce6a385d 100644--- a/MediaBrowser.Api/ScheduledTasks/ScheduledTasksWebSocketListener.cs+++ b/MediaBrowser.Api/ScheduledTasks/ScheduledTasksWebSocketListener.cs@@ -4,6 +4,7 @@ using MediaBrowser.Model.Tasks;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;+using MediaBrowser.Controller.Net;using MediaBrowser.Model.Threading;namespace MediaBrowser.Api.ScheduledTasksdiff --git a/MediaBrowser.Api/System/ActivityLogWebSocketListener.cs b/MediaBrowser.Api/System/ActivityLogWebSocketListener.csindex c641695dd8..793f745713 100644--- a/MediaBrowser.Api/System/ActivityLogWebSocketListener.cs+++ b/MediaBrowser.Api/System/ActivityLogWebSocketListener.cs@@ -3,6 +3,7 @@ using MediaBrowser.Model.Events;using MediaBrowser.Model.Logging;using System.Collections.Generic;using System.Threading.Tasks;+using MediaBrowser.Controller.Net;using MediaBrowser.Model.Threading;namespace MediaBrowser.Api.Systemdiff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.csindex 5fe386f1ab..1e531ba664 100644--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs@@ -117,7 +117,9 @@ namespace MediaBrowser.Api.UserLibraryIsVirtualItem = false,CollapseBoxSetItems = false,EnableTotalRecordCount = request.EnableTotalRecordCount,- AncestorIds = ancestorIds.ToArray()+ AncestorIds = ancestorIds.ToArray(),+ IncludeItemTypes = request.GetIncludeItemTypes(),+ ExcludeItemTypes = request.GetExcludeItemTypes()});var returnItems = _dtoService.GetBaseItemDtos(itemsResult.Items, options, user);diff --git a/MediaBrowser.Controller/Dlna/IEventManager.cs b/MediaBrowser.Controller/Dlna/IEventManager.csindex 8c91bd889d..3af357a174 100644--- a/MediaBrowser.Controller/Dlna/IEventManager.cs+++ b/MediaBrowser.Controller/Dlna/IEventManager.cs@@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Dlna/// <summary>/// Renews the event subscription./// </summary>- EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string requestedTimeoutString);+ EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string notificationType, string requestedTimeoutString, string callbackUrl);/// <summary>/// Creates the event subscription.diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csprojindex b33993859b..960ff0aa7d 100644--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj@@ -176,6 +176,7 @@<Compile Include="MediaEncoding\MediaStreamSelector.cs" /><Compile Include="Net\AuthenticatedAttribute.cs" /><Compile Include="Net\AuthorizationInfo.cs" />+ <Compile Include="Net\BasePeriodicWebSocketListener.cs" /><Compile Include="Net\IAuthorizationContext.cs" /><Compile Include="Net\IAuthService.cs" /><Compile Include="Net\IHasResultFactory.cs" />diff --git a/MediaBrowser.Api/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cssimilarity index 99%rename from MediaBrowser.Api/BasePeriodicWebSocketListener.csrename to MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.csindex c7a9d97bad..6be94e7e6e 100644--- a/MediaBrowser.Api/BasePeriodicWebSocketListener.cs+++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs@@ -4,12 +4,11 @@ using System.Globalization;using System.Linq;using System.Threading;using System.Threading.Tasks;-using MediaBrowser.Controller.Net;using MediaBrowser.Model.Logging;using MediaBrowser.Model.Net;using MediaBrowser.Model.Threading;-namespace MediaBrowser.Api+namespace MediaBrowser.Controller.Net{/// <summary>/// Starts sending data over a web socket periodically when a message is received, and then stops when a corresponding stop message is received@@ -93,7 +92,7 @@ namespace MediaBrowser.Api{get{- return true;+ return false;}}diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.csindex c855a8d9ba..bb4a98fa86 100644--- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs+++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs@@ -265,7 +265,7 @@ namespace MediaBrowser.WebDashboard.Apibuilder.AppendFormat("window.appMode='{0}';", mode);}- if (string.IsNullOrWhiteSpace(mode))+ else{builder.AppendFormat("window.dashboardVersion='{0}';", version);}