11 lines
486 B
TypeScript
11 lines
486 B
TypeScript
// Allow a polling cycle plus time for queued RCON requests and delivery.
|
|
export const STATUS_REFRESH_MS = 30_000;
|
|
export const ONLINE_MAX_MS = STATUS_REFRESH_MS + 15_000;
|
|
// The UI clock ticks once per second and can trail a newly arrived report.
|
|
const CLOCK_TOLERANCE_MS = 1_000;
|
|
|
|
export function freshStatusTimestamp(timestamp: string | null, now: number): boolean {
|
|
const age = now - Date.parse(timestamp ?? '');
|
|
return age >= -CLOCK_TOLERANCE_MS && age <= ONLINE_MAX_MS;
|
|
}
|