From ca3f3e810d94b2415d629c7b27a679e520d8d6f2 Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 24 Jun 2015 06:51:47 -0400 Subject: [PATCH 1/2] fix socketio/socket.io-client-swift#97 --- SocketIOClientSwift/SocketEngine.swift | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/SocketIOClientSwift/SocketEngine.swift b/SocketIOClientSwift/SocketEngine.swift index 28593da..f288d28 100644 --- a/SocketIOClientSwift/SocketEngine.swift +++ b/SocketIOClientSwift/SocketEngine.swift @@ -40,11 +40,11 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient { private var fastUpgrade = false private var forcePolling = false private var forceWebsockets = false - private var pingInterval:Int? + private var pingInterval:Double? private var pingTimer:NSTimer? - private var pingTimeout = 0 { + private var pingTimeout = 0.0 { didSet { - pongsMissedMax = pingTimeout / (pingInterval ?? 25) + pongsMissedMax = Int(pingTimeout / (pingInterval ?? 25)) } } private var pongsMissed = 0 @@ -404,9 +404,9 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient { createWebsocket(andConnect: true) } - if let pingInterval = json["pingInterval"] as? Int, pingTimeout = json["pingTimeout"] as? Int { - self.pingInterval = pingInterval / 1000 - self.pingTimeout = pingTimeout / 1000 + if let pingInterval = json["pingInterval"] as? Double, pingTimeout = json["pingTimeout"] as? Double { + self.pingInterval = pingInterval / 1000.0 + self.pingTimeout = pingTimeout / 1000.0 } } else { client?.didError("Engine failed to handshake") @@ -650,8 +650,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient { pingTimer?.invalidate() dispatch_async(dispatch_get_main_queue()) {[weak self] in if let this = self { - this.pingTimer = NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(this.pingInterval!), - target: this, + this.pingTimer = NSTimer.scheduledTimerWithTimeInterval(this.pingInterval!, target: this, selector: Selector("sendPing"), userInfo: nil, repeats: true) } } From d8f65c28046f4b7e7be7fe4672cd8ccee009d9a7 Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 24 Jun 2015 06:52:24 -0400 Subject: [PATCH 2/2] bump version --- Socket.IO-Client-Swift.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index 53353f0..b2e4519 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 = "2.3.5" + s.version = "2.3.6" s.summary = "Socket.IO-client for iOS and OS X" s.description = <<-DESC Socket.IO-client for iOS and OS X. @@ -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 => 'v2.3.5' } + s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v2.3.6' } s.source_files = "SocketIOClientSwift/**/*.swift" s.requires_arc = true # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files