Skip to content

Commit 28cc8ee

Browse files
committed
Don't set configs after connect
1 parent 321bb18 commit 28cc8ee

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Source/SocketIO/Client/SocketIOClient.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,24 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
5454
///
5555
/// **This cannot be set after calling one of the connect methods**.
5656
public var config: SocketIOClientConfiguration {
57-
didSet {
57+
get {
58+
return _config
59+
}
60+
61+
set {
5862
guard status == .notConnected else {
5963
DefaultSocketLogger.Logger.error("Tried setting config after calling connect",
6064
type: SocketIOClient.logType)
6165
return
6266
}
6367

68+
_config = newValue
69+
6470
if socketURL.absoluteString.hasPrefix("https://") {
65-
config.insert(.secure(true))
71+
_config.insert(.secure(true))
6672
}
6773

68-
config.insert(.path("/socket.io/"), replacing: false)
74+
_config.insert(.path("/socket.io/"), replacing: false)
6975
setConfigs()
7076
}
7177
}
@@ -130,6 +136,7 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
130136
private(set) var currentAck = -1
131137
private(set) var reconnectAttempts = -1
132138

139+
private var _config: SocketIOClientConfiguration
133140
private var currentReconnectAttempt = 0
134141
private var reconnecting = false
135142

@@ -140,14 +147,14 @@ open class SocketIOClient : NSObject, SocketIOClientSpec, SocketEngineClient, So
140147
/// - parameter socketURL: The url of the socket.io server.
141148
/// - parameter config: The config for this socket.
142149
public init(socketURL: URL, config: SocketIOClientConfiguration = []) {
143-
self.config = config
150+
self._config = config
144151
self.socketURL = socketURL
145152

146153
if socketURL.absoluteString.hasPrefix("https://") {
147-
self.config.insert(.secure(true))
154+
self._config.insert(.secure(true))
148155
}
149156

150-
self.config.insert(.path("/socket.io/"), replacing: false)
157+
self._config.insert(.path("/socket.io/"), replacing: false)
151158

152159
super.init()
153160

0 commit comments

Comments
 (0)