From 2cae405d29193cff075b2176185a2b89f14c1ead Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 26 Mar 2015 13:15:43 -0400 Subject: [PATCH] try and avoid bad engine states --- Socket.IO-Client-Swift.podspec | 4 ++-- SwiftIO/SocketIOClient.swift | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index dc46600..ab5261a 100644 --- a/Socket.IO-Client-Swift.podspec +++ b/Socket.IO-Client-Swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Socket.IO-Client-Swift" - s.version = "1.4.0" + s.version = "1.4.2" s.summary = "Socket.IO-client for Swift" s.description = <<-DESC Socket.IO-client for Swift. @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.author = { "Erik" => "nuclear.ace@gmail.com" } s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.10' - s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v1.4.0' } + s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v1.4.2' } s.source_files = "SwiftIO/**/*.swift" s.requires_arc = true # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files diff --git a/SwiftIO/SocketIOClient.swift b/SwiftIO/SocketIOClient.swift index 5e0119a..144925b 100644 --- a/SwiftIO/SocketIOClient.swift +++ b/SwiftIO/SocketIOClient.swift @@ -118,16 +118,18 @@ public class SocketIOClient: NSObject, SocketEngineClient { } super.init() - - self.engine = SocketEngine(client: self, - forcePolling: self.forcePolling, - withCookies: self.cookies) } public convenience init(socketURL:String, options:NSDictionary?) { self.init(socketURL: socketURL, opts: options) } + private func addEngine() { + self.engine = SocketEngine(client: self, + forcePolling: self.forcePolling, + withCookies: self.cookies) + } + /** Closes the socket. Only reopen the same socket if you know what you're doing. Will turn off automatic reconnects. @@ -150,6 +152,7 @@ public class SocketIOClient: NSObject, SocketEngineClient { self._closed = false } + self.addEngine() self.engine?.open() } @@ -165,6 +168,7 @@ public class SocketIOClient: NSObject, SocketEngineClient { self.params = params self.paramConnect = true + self.addEngine() self.engine?.open(opts: params) }