open method
Tries to take the slot for key. Returns true when the caller owns the
open: free always, busy/visible only for a live test (which first
asks the current game to close as superseded). A granted open arms
the watchdog unless direct — the coordinator covers direct games.
Never throws.
Implementation
bool open({
required String key,
bool liveTest = false,
bool direct = false,
void Function(String reason)? onTimeout,
}) {
try {
if (_slot == GameLaunchSlot.free && !_visible) {
_slot = GameLaunchSlot.busy;
_onTimeout = onTimeout;
if (!direct) _armWatchdog(_watchdogMs);
_log.d('Game slot taken (key=$key, liveTest=$liveTest)');
return true;
}
if (liveTest) {
_slot = GameLaunchSlot.replace;
_onTimeout = onTimeout;
if (!direct) _armWatchdog(_watchdogMs);
try {
_closeRequests.add('superseded');
} catch (_) {}
_log.d('Game slot replaced by live test (key=$key)');
return true;
}
_log.d('Game slot busy — open refused (key=$key)');
return false;
} catch (_) {
return false;
}
}