Skip to content

Commit 5f55d01

Browse files
committed
don't set state to disconnected multiple times
1 parent d9a2a1c commit 5f55d01

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/SwiftOCA/OCP.1/Ocp1Connection+Connect.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,10 @@ extension Ocp1Connection {
177177
.trace(
178178
"failed to send message: error \(error), new connection state \(connectionState); disconnecting"
179179
)
180-
_updateConnectionState(connectionState)
181-
try await _disconnectDeviceAfterConnectionFailure()
180+
if isConnected {
181+
_updateConnectionState(connectionState)
182+
try await _disconnectDeviceAfterConnectionFailure()
183+
}
182184
}
183185
}
184186

0 commit comments

Comments
 (0)