Skip to content

Commit 2cae405

Browse files
committed
try and avoid bad engine states
1 parent f008f11 commit 2cae405

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Socket.IO-Client-Swift.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Socket.IO-Client-Swift"
3-
s.version = "1.4.0"
3+
s.version = "1.4.2"
44
s.summary = "Socket.IO-client for Swift"
55
s.description = <<-DESC
66
Socket.IO-client for Swift.
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
1212
s.author = { "Erik" => "[email protected]" }
1313
s.ios.deployment_target = '8.0'
1414
s.osx.deployment_target = '10.10'
15-
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v1.4.0' }
15+
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v1.4.2' }
1616
s.source_files = "SwiftIO/**/*.swift"
1717
s.requires_arc = true
1818
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files

SwiftIO/SocketIOClient.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,18 @@ public class SocketIOClient: NSObject, SocketEngineClient {
118118
}
119119

120120
super.init()
121-
122-
self.engine = SocketEngine(client: self,
123-
forcePolling: self.forcePolling,
124-
withCookies: self.cookies)
125121
}
126122

127123
public convenience init(socketURL:String, options:NSDictionary?) {
128124
self.init(socketURL: socketURL, opts: options)
129125
}
130126

127+
private func addEngine() {
128+
self.engine = SocketEngine(client: self,
129+
forcePolling: self.forcePolling,
130+
withCookies: self.cookies)
131+
}
132+
131133
/**
132134
Closes the socket. Only reopen the same socket if you know what you're doing.
133135
Will turn off automatic reconnects.
@@ -150,6 +152,7 @@ public class SocketIOClient: NSObject, SocketEngineClient {
150152
self._closed = false
151153
}
152154

155+
self.addEngine()
153156
self.engine?.open()
154157
}
155158

@@ -165,6 +168,7 @@ public class SocketIOClient: NSObject, SocketEngineClient {
165168
self.params = params
166169
self.paramConnect = true
167170

171+
self.addEngine()
168172
self.engine?.open(opts: params)
169173
}
170174

0 commit comments

Comments
 (0)