Skip to content
This repository was archived by the owner on Nov 2, 2020. It is now read-only.

Commit 68c438d

Browse files
Adding default reconnection configs, adapting tests with new improvements
1 parent 3ae1a86 commit 68c438d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Sources/CWSReconnection.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ extension CWSReconnection {
4848
return self.mAutoReconnect
4949
}
5050

51-
open func setReconnection(autoReconnect: Bool, reconnectionIntervalMin: Double, reconnectionIntervalMax: Double, reconnectionAttempts: Int) {
51+
open func setReconnection(autoReconnect: Bool, reconnectionIntervalMin: Double? = nil, reconnectionIntervalMax: Double? = nil, reconnectionAttempts: Int? = nil) {
5252
self.mAutoReconnect = autoReconnect
53-
self.mReconnectionIntervalMin = reconnectionIntervalMin
54-
self.mReconnectionIntervalMax = reconnectionIntervalMax
55-
self.mReconnectionAttempts = reconnectionAttempts
53+
self.mReconnectionIntervalMin = reconnectionIntervalMin ?? self.mReconnectionIntervalMin
54+
self.mReconnectionIntervalMax = reconnectionIntervalMax ?? self.mReconnectionIntervalMax
55+
self.mReconnectionAttempts = reconnectionAttempts ?? self.mReconnectionAttempts
5656
}
5757

5858
open func reconnect() {

Sources/ClusterWS.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ extension ClusterWS {
104104
self.mWebSocket?.close(closeCode == nil ? 1000 : closeCode!, reason: reason == nil ? "" : reason!)
105105
}
106106

107-
public func setReconnection(autoReconnect: Bool, reconnectionIntervalMin: Double, reconnectionIntervalMax: Double, reconnectionAttempts: Int) {
107+
public func setReconnection(autoReconnect: Bool, reconnectionIntervalMin: Double? = nil, reconnectionIntervalMax: Double? = nil, reconnectionAttempts: Int? = nil) {
108108
self.mReconnection.setReconnection(autoReconnect: autoReconnect, reconnectionIntervalMin: reconnectionIntervalMin, reconnectionIntervalMax: reconnectionIntervalMax, reconnectionAttempts: reconnectionAttempts)
109109
}
110110

Tests/CWSChannelTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CWSChannelTests: XCTestCase {
1616
super.setUp()
1717
// Put setup code here. This method is called before the invocation of each test method in the class.
1818
self.webSocket = ClusterWS(url: "wss://localhost:8080")
19-
self.webSocket.setReconnection(autoReconnect: true, reconnectionIntervalMin: 1.0, reconnectionIntervalMax: 5.0, reconnectionAttempts: 2)
19+
self.webSocket.setReconnection(autoReconnect: true)
2020
}
2121

2222
override func tearDown() {

Tests/ClusterWSTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ClusterWSTests: XCTestCase {
1616
super.setUp()
1717
// Put setup code here. This method is called before the invocation of each test method in the class.
1818
self.webSocket = ClusterWS(url: "wss://localhost:8080")
19-
self.webSocket.setReconnection(autoReconnect: true, reconnectionIntervalMin: 1.0, reconnectionIntervalMax: 5.0, reconnectionAttempts: 2)
19+
self.webSocket.setReconnection(autoReconnect: true)
2020
}
2121

2222
override func tearDown() {

0 commit comments

Comments
 (0)