close method
void
close()
The surface is gone: fail every in-flight request as closed, pause
the skin, then end every stream. Idempotent.
iOS behavior wins here: a skin awaiting a reply never hangs. (Android
instead leaves in-flight calls unanswered — a hanging skin — because its
answers check closed and return silently.)
Implementation
void close() {
_failPendingAsClosed();
_pushPause();
_closed = true;
final pending = [..._httpInFlight, ..._pendingActionIds]..sort();
_httpInFlight.clear();
_pendingActionIds.clear();
for (final entry in _httpWatchdogs.values) {
try {
_watchdogCancel(entry);
} catch (_) {}
}
_httpWatchdogs.clear();
for (final id in pending) {
_sendSafe(bridgeError(id, GameBridgeError.closed, 'game closed'));
}
try {
_sensors.stopAll();
} catch (_) {}
}