aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs
diff options
context:
space:
mode:
authorstefan <stefan@hegedues.at>2018-09-12 19:26:21 +0200
committerstefan <stefan@hegedues.at>2018-09-12 19:26:21 +0200
commit48facb797ed912e4ea6b04b17d1ff190ac2daac4 (patch)
tree8dae77a31670a888d733484cb17dd4077d5444e8 /Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs
parentc32d8656382a0eacb301692e0084377fc433ae9b (diff)
Update to 3.5.2 and .net core 2.1
Diffstat (limited to 'Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs')
-rw-r--r--Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs49
1 files changed, 22 insertions, 27 deletions
diff --git a/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs
index 11e806b0c..97feb32c0 100644
--- a/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs
+++ b/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Common;
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
@@ -61,17 +60,29 @@ namespace Emby.Server.Implementations.EntryPoints
var key = string.Join("_", keys.ToArray(keys.Count)).GetMD5();
- _apps.GetOrAdd(key, guid => GetNewClientInfo(session));
+ ClientInfo info;
+ if (!_apps.TryGetValue(key, out info))
+ {
+ info = new ClientInfo
+ {
+ AppName = session.Client,
+ AppVersion = session.ApplicationVersion,
+ DeviceName = session.DeviceName,
+ DeviceId = session.DeviceId
+ };
+
+ _apps[key] = info;
+
+ if (_config.Configuration.EnableAnonymousUsageReporting)
+ {
+ Task.Run(() => ReportNewSession(info));
+ }
+ }
}
}
- private async void ReportNewSession(ClientInfo client)
+ private async Task ReportNewSession(ClientInfo client)
{
- if (!_config.Configuration.EnableAnonymousUsageReporting)
- {
- return;
- }
-
try
{
await new UsageReporter(_applicationHost, _httpClient, _logger)
@@ -80,25 +91,10 @@ namespace Emby.Server.Implementations.EntryPoints
}
catch (Exception ex)
{
- _logger.ErrorException("Error sending anonymous usage statistics.", ex);
+ //_logger.ErrorException("Error sending anonymous usage statistics.", ex);
}
}
- private ClientInfo GetNewClientInfo(SessionInfo session)
- {
- var info = new ClientInfo
- {
- AppName = session.Client,
- AppVersion = session.ApplicationVersion,
- DeviceName = session.DeviceName,
- DeviceId = session.DeviceId
- };
-
- ReportNewSession(info);
-
- return info;
- }
-
public async void Run()
{
await Task.Delay(5000).ConfigureAwait(false);
@@ -123,14 +119,13 @@ namespace Emby.Server.Implementations.EntryPoints
}
catch (Exception ex)
{
- _logger.ErrorException("Error sending anonymous usage statistics.", ex);
+ //_logger.ErrorException("Error sending anonymous usage statistics.", ex);
}
}
public void Dispose()
{
_sessionManager.SessionStarted -= _sessionManager_SessionStarted;
- GC.SuppressFinalize(this);
}
}
}