voxeraProactiveRefreshDelay function

Duration? voxeraProactiveRefreshDelay(
  1. int? expiresInSeconds
)

When to renew a user token that lives expiresInSeconds seconds.

At 80% of its life: late enough that a normal room visit renews nothing, early enough that the renewal has a fifth of the lifetime to survive a bad network before anything is refused. A non-positive or missing lifetime yields null — nothing is scheduled on a number the engine did not send.

Implementation

Duration? voxeraProactiveRefreshDelay(int? expiresInSeconds) {
  if (expiresInSeconds == null || expiresInSeconds <= 0) return null;
  final ms = (expiresInSeconds * 1000 * 0.8).round();
  return Duration(milliseconds: ms);
}