Network Reconnection Delay
Nucleic-Session: 4BE3E40C-E939-444C-8AED-93C0AFE13C07 Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
@@ -31,11 +31,18 @@ struct NucleicRemoteApp: App {
|
|||||||
// activity flag current so it only notifies for background transitions.
|
// activity flag current so it only notifies for background transitions.
|
||||||
.onChange(of: scenePhase) { _, phase in
|
.onChange(of: scenePhase) { _, phase in
|
||||||
store.setScenePhaseActive(phase == .active)
|
store.setScenePhaseActive(phase == .active)
|
||||||
if phase == .active {
|
switch phase {
|
||||||
|
case .active:
|
||||||
// Re-plan transports immediately on foreground — the network may have
|
// Re-plan transports immediately on foreground — the network may have
|
||||||
// changed while suspended, so don't wait for a dead socket to notice.
|
// changed while suspended, so don't wait for a dead socket to notice.
|
||||||
store.onForeground()
|
store.onForeground()
|
||||||
Task { await HeartbeatReporter.reportIfDue() }
|
Task { await HeartbeatReporter.reportIfDue() }
|
||||||
|
case .background:
|
||||||
|
// Hold the process (and its live sockets) briefly so a quick app-switch
|
||||||
|
// doesn't drop the connection and force a cold reconnect on return.
|
||||||
|
store.onBackground()
|
||||||
|
default:
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user