Skip to content

Commit 2fd1b39

Browse files
committed
refactor reconnection logic, split out into new file
1 parent f0fae9e commit 2fd1b39

File tree

12 files changed

+415
-159
lines changed

12 files changed

+415
-159
lines changed

Sources/SwiftOCA/OCF/Errors.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public enum Ocp1Error: Error, Equatable {
3434
case invalidProtocolVersion
3535
case invalidProxyMethodResponse
3636
case invalidSyncValue
37+
case missingKeepalive
3738
case noConnectionDelegate
3839
case noInitialValue
3940
case noMatchingTypeForClass

Sources/SwiftOCA/OCP.1/Backend/Ocp1CFSocketConnection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,14 @@ public class Ocp1CFSocketConnection: Ocp1Connection {
401401
deviceAddress.family
402402
}
403403

404-
override func connectDevice() async throws {
404+
override public func connectDevice() async throws {
405405
socket = try await _CFSocketWrapper(address: deviceAddress, type: type)
406406
try await super.connectDevice()
407407
}
408408

409-
override public func disconnectDevice(clearObjectCache: Bool) async throws {
409+
override public func disconnectDevice() async throws {
410410
socket = nil
411-
try await super.disconnectDevice(clearObjectCache: clearObjectCache)
411+
try await super.disconnectDevice()
412412
}
413413
}
414414

Sources/SwiftOCA/OCP.1/Backend/Ocp1FlyingSocksConnection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public class Ocp1FlyingSocksConnection: Ocp1Connection {
123123
try? asyncSocket?.close()
124124
}
125125

126-
override func connectDevice() async throws {
126+
override public func connectDevice() async throws {
127127
let socket = try Socket(domain: Int32(deviceAddress.family), type: socketType)
128128
try? setSocketOptions(socket)
129129
// also connect UDP sockets to ensure we do not receive unsolicited replies
@@ -135,13 +135,13 @@ public class Ocp1FlyingSocksConnection: Ocp1Connection {
135135
try await super.connectDevice()
136136
}
137137

138-
override public func disconnectDevice(clearObjectCache: Bool) async throws {
138+
override public func disconnectDevice() async throws {
139139
await AsyncSocketPoolMonitor.shared.stop()
140140
if let asyncSocket {
141141
try asyncSocket.close()
142142
self.asyncSocket = nil
143143
}
144-
try await super.disconnectDevice(clearObjectCache: clearObjectCache)
144+
try await super.disconnectDevice()
145145
}
146146

147147
public convenience init(

Sources/SwiftOCA/OCP.1/Backend/Ocp1IORingConnection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class Ocp1IORingConnection: Ocp1Connection {
7979
)
8080
}
8181

82-
override func connectDevice() async throws {
82+
override public func connectDevice() async throws {
8383
let socket = try Socket(
8484
ring: IORing.shared,
8585
domain: deviceAddress.family,
@@ -94,9 +94,9 @@ public class Ocp1IORingConnection: Ocp1Connection {
9494
try await super.connectDevice()
9595
}
9696

97-
override public func disconnectDevice(clearObjectCache: Bool) async throws {
97+
override public func disconnectDevice() async throws {
9898
socket = nil
99-
try await super.disconnectDevice(clearObjectCache: clearObjectCache)
99+
try await super.disconnectDevice()
100100
}
101101

102102
fileprivate func withMappedError<T: Sendable>(

0 commit comments

Comments
 (0)