mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix ios gateway forced reconnect
This commit is contained in:
@@ -702,6 +702,9 @@ final class GatewayConnectionController {
|
||||
appModel.gatewayStatusText = "Connecting…"
|
||||
Task { [weak self, weak appModel] in
|
||||
guard let self, let appModel else { return }
|
||||
if forceReconnect {
|
||||
await appModel.resetGatewaySessionsForForcedReconnect()
|
||||
}
|
||||
let nodeOptions = await self.makeConnectOptions(stableID: gatewayStableID)
|
||||
let cfg = GatewayConnectConfig(
|
||||
url: url,
|
||||
|
||||
@@ -1939,6 +1939,15 @@ extension NodeAppModel {
|
||||
forceReconnect: forceReconnect)
|
||||
}
|
||||
|
||||
func resetGatewaySessionsForForcedReconnect() async {
|
||||
self.nodeGatewayTask?.cancel()
|
||||
self.nodeGatewayTask = nil
|
||||
self.operatorGatewayTask?.cancel()
|
||||
self.operatorGatewayTask = nil
|
||||
await self.operatorGateway.disconnect()
|
||||
await self.nodeGateway.disconnect()
|
||||
}
|
||||
|
||||
func disconnectGateway() {
|
||||
self.gatewayAutoReconnectEnabled = false
|
||||
self.gatewayPairingPaused = false
|
||||
@@ -4557,6 +4566,10 @@ extension NodeAppModel {
|
||||
self.clearingBootstrapToken(in: config)
|
||||
}
|
||||
|
||||
func _test_hasGatewayLoopTasks() -> (node: Bool, operator: Bool) {
|
||||
(self.nodeGatewayTask != nil, self.operatorGatewayTask != nil)
|
||||
}
|
||||
|
||||
func _test_handleSuccessfulBootstrapGatewayOnboarding() async {
|
||||
await self.handleSuccessfulBootstrapGatewayOnboarding(
|
||||
url: URL(string: "wss://gateway.example")!,
|
||||
|
||||
@@ -235,6 +235,20 @@ import UIKit
|
||||
#expect(appModel.connectedGatewayID == second.stableID)
|
||||
}
|
||||
|
||||
@Test @MainActor func forcedReconnectResetClearsActiveGatewayLoopTasks() async {
|
||||
let appModel = NodeAppModel()
|
||||
defer { appModel.disconnectGateway() }
|
||||
|
||||
appModel.applyGatewayConnectConfig(Self.makeGatewayConnectConfig())
|
||||
#expect(appModel._test_hasGatewayLoopTasks().node)
|
||||
#expect(appModel._test_hasGatewayLoopTasks().operator)
|
||||
|
||||
await appModel.resetGatewaySessionsForForcedReconnect()
|
||||
|
||||
#expect(!appModel._test_hasGatewayLoopTasks().node)
|
||||
#expect(!appModel._test_hasGatewayLoopTasks().operator)
|
||||
}
|
||||
|
||||
@Test @MainActor func loadLastConnectionReadsSavedValues() {
|
||||
let prior = KeychainStore.loadString(service: "ai.openclaw.gateway", account: "lastConnection")
|
||||
defer {
|
||||
|
||||
Reference in New Issue
Block a user