-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace Elympics.Editor.Models.UsageStatistics | ||
{ | ||
[Serializable] | ||
internal class PlayRequest | ||
{ | ||
public string gameId; | ||
public string mode; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Elympics.Editor.Models.UsageStatistics | ||
{ | ||
public static class Routes | ||
{ | ||
public const string Base = "hello"; | ||
|
||
public const string Start = "start"; | ||
public const string Play = "play"; | ||
public const string Stop = "stop"; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace Elympics.Editor.Models.UsageStatistics | ||
{ | ||
[Serializable] | ||
internal class StartRequest | ||
{ | ||
public string gameId; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace Elympics.Editor.Models.UsageStatistics | ||
{ | ||
[Serializable] | ||
internal class StopRequest | ||
{ | ||
public string gameId; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Globalization; | ||
using Plugins.Elympics.Plugins.ParrelSync; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Elympics.Editor.Communication.UsageStatistics | ||
{ | ||
[InitializeOnLoad] | ||
internal static class UsageStatisticsSender | ||
{ | ||
private const string SessionStartKey = "Elympics/SessionStart"; | ||
private static readonly TimeSpan ComparisonEpsilon = TimeSpan.FromMinutes(1); | ||
|
||
static UsageStatisticsSender() | ||
{ | ||
if (ElympicsClonesManager.IsClone()) | ||
return; | ||
OnAssemblyReload(); | ||
EditorApplication.quitting += OnQuitting; | ||
} | ||
|
||
private static void OnAssemblyReload() | ||
{ | ||
var currentSessionStart = DateTime.UtcNow - TimeSpan.FromSeconds(EditorApplication.timeSinceStartup); | ||
if (!HasBeenRestarted(currentSessionStart)) | ||
return; | ||
ElympicsWebIntegration.PostStartEvent(); | ||
PlayerPrefs.SetString(SessionStartKey, currentSessionStart.ToString("o", CultureInfo.InvariantCulture)); | ||
} | ||
|
||
private static bool HasBeenRestarted(DateTime currentSessionStart) | ||
{ | ||
var serializedSessionStart = PlayerPrefs.GetString(SessionStartKey) ?? ""; | ||
if (!DateTime.TryParse(serializedSessionStart, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, | ||
out var savedSessionStart)) | ||
return true; | ||
if (savedSessionStart - currentSessionStart > ComparisonEpsilon) | ||
return true; // something's wrong - should reset | ||
return currentSessionStart - savedSessionStart > ComparisonEpsilon; | ||
} | ||
|
||
private static void OnQuitting() => ElympicsWebIntegration.PostStopEvent(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Elympics | ||
namespace Elympics.Editor | ||
{ | ||
internal partial class ElympicsGameConfigEditor | ||
{ | ||
|