Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Assets/Talo Game Services/Talo/Runtime/APIs/HealthCheckAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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") { }

Expand All @@ -24,6 +25,12 @@ public HealthCheckStatus GetLastStatus()

public async Task<bool> Ping()
{
var bustCache = lastHealthCheckStatus == HealthCheckStatus.UNKNOWN || Time.realtimeSinceStartup >= nextPingTime;
if (!bustCache)
{
return lastHealthCheckStatus == HealthCheckStatus.OK;
}

var uri = new Uri(baseUrl);

bool success;
Expand Down Expand Up @@ -57,6 +64,8 @@ public async Task<bool> Ping()
}
}

nextPingTime = Time.realtimeSinceStartup + Talo.Settings.debounceTimerSeconds;

return success;
}
}
Expand Down
3 changes: 3 additions & 0 deletions Assets/Talo Game Services/Talo/Runtime/TaloSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}