diff --git a/Assets/Talo Game Services/Talo/Runtime/APIs/HealthCheckAPI.cs b/Assets/Talo Game Services/Talo/Runtime/APIs/HealthCheckAPI.cs index 246a685..c438d7d 100644 --- a/Assets/Talo Game Services/Talo/Runtime/APIs/HealthCheckAPI.cs +++ b/Assets/Talo Game Services/Talo/Runtime/APIs/HealthCheckAPI.cs @@ -14,6 +14,7 @@ public enum HealthCheckStatus public class HealthCheckAPI : BaseAPI { private HealthCheckStatus lastHealthCheckStatus = HealthCheckStatus.UNKNOWN; + private float nextPingTime; public HealthCheckAPI() : base("v1/health-check") { } @@ -24,6 +25,12 @@ public HealthCheckStatus GetLastStatus() public async Task Ping() { + var bustCache = lastHealthCheckStatus == HealthCheckStatus.UNKNOWN || Time.realtimeSinceStartup >= nextPingTime; + if (!bustCache) + { + return lastHealthCheckStatus == HealthCheckStatus.OK; + } + var uri = new Uri(baseUrl); bool success; @@ -57,6 +64,8 @@ public async Task Ping() } } + nextPingTime = Time.realtimeSinceStartup + Talo.Settings.debounceTimerSeconds; + return success; } } diff --git a/Assets/Talo Game Services/Talo/Runtime/TaloSettings.cs b/Assets/Talo Game Services/Talo/Runtime/TaloSettings.cs index 5a933cf..f81dbc5 100644 --- a/Assets/Talo Game Services/Talo/Runtime/TaloSettings.cs +++ b/Assets/Talo Game Services/Talo/Runtime/TaloSettings.cs @@ -34,5 +34,8 @@ public class TaloSettings : ScriptableObject [Tooltip("If enabled, Talo will automatically cache the player after a successful online identification for use in later offline sessions")] public bool cachePlayerOnIdentify = true; + + [Tooltip("Number of seconds to wait before sending debounced requests (e.g. player updates, save updates and health checks)")] + public float debounceTimerSeconds = 1f; } }