diff --git a/apps/PlayniteWebPlugin/src/Models/Release.cs b/apps/PlayniteWebPlugin/src/Models/Release.cs index 6e415a5f5..dc2e71bdd 100755 --- a/apps/PlayniteWebPlugin/src/Models/Release.cs +++ b/apps/PlayniteWebPlugin/src/Models/Release.cs @@ -6,6 +6,13 @@ namespace PlayniteWeb.Models { + public enum RunState + { + Running, + Installed, + Uninstalled + } + public class Release : IIdentifiable { private readonly Playnite.SDK.Models.Game game; @@ -23,6 +30,25 @@ public Release(Playnite.SDK.Models.Game game, Platform platform) this.platform = platform; } + [DontSerialize] + public RunState RunState + { + get + { + if (game.IsRunning) + { + return RunState.Running; + } + else if (game.IsInstalled) + { + return RunState.Installed; + } + else + { + return RunState.Uninstalled; + } + } + } public int? ProcessId { get; set; } public Guid Id => game.Id; public string Name => game.Name; diff --git a/apps/PlayniteWebPlugin/src/PlayniteWeb.cs b/apps/PlayniteWebPlugin/src/PlayniteWeb.cs index 98a5441bc..daa61decc 100755 --- a/apps/PlayniteWebPlugin/src/PlayniteWeb.cs +++ b/apps/PlayniteWebPlugin/src/PlayniteWeb.cs @@ -285,7 +285,7 @@ public override void OnApplicationStopped(OnApplicationStoppedEventArgs args) private void Subscriber_OnRestartRelease(object sender, Release e) { this.Subscriber_OnStopRelease(sender, e); - this.Subscriber_OnStartRelease(sender, e); + Task.Delay(3000).ContinueWith(t => this.Subscriber_OnStartRelease(sender, e)); } private void Subscriber_OnStopRelease(object sender, Release e) @@ -295,6 +295,11 @@ private void Subscriber_OnStopRelease(object sender, Release e) return; } + if (e.RunState != RunState.Running) + { + return; + } + try { var gameProcess = Process.GetProcessById(e.ProcessId.Value); @@ -392,7 +397,11 @@ private void Subscriber_OnStartRelease(object sender, Release release) if (!isPcPlatform(release.Platform)) { return; + } + if (release.RunState == RunState.Running) + { + return; } if (!release.IsInstalled)