From 9b9becebae995adef3435ba9f2c3ddaf3cc43f1e Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 5 Aug 2015 06:14:44 -0400 Subject: [PATCH 1/7] bump version --- README.md | 4 ++-- Socket.IO-Client-Swift.podspec | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a66216b..3994f4a 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Carthage ----------------- Add this line to your `Cartfile`: ``` -github "socketio/socket.io-client-swift" ~> 2.4.0 # Or latest version +github "socketio/socket.io-client-swift" ~> 2.4.1 # Or latest version ``` Run `carthage update`. @@ -79,7 +79,7 @@ source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' use_frameworks! -pod 'Socket.IO-Client-Swift', '~> 2.4.0' # Or latest version +pod 'Socket.IO-Client-Swift', '~> 2.4.1' # Or latest version ``` Install pods: diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index 5ff6cbe..3987b1f 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.4.0" + s.version = "2.4.1" 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.4.0' } + s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v2.4.1' } s.source_files = "SocketIOClientSwift/**/*.swift" s.requires_arc = true # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files From 8bde261acbb0cf5db10745e09de1dc88be42cfff Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 5 Aug 2015 12:25:37 -0400 Subject: [PATCH 2/7] fix socketio/socket.io-client-swift#137 --- SocketIOClientSwift/SocketIOClient.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SocketIOClientSwift/SocketIOClient.swift b/SocketIOClientSwift/SocketIOClient.swift index d7ff0c5..e55f8d1 100644 --- a/SocketIOClientSwift/SocketIOClient.swift +++ b/SocketIOClientSwift/SocketIOClient.swift @@ -46,7 +46,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient public let socketURL:String public let handleAckQueue = dispatch_queue_create("handleAckQueue", DISPATCH_QUEUE_SERIAL) - public let handleQueue: dispatch_queue_t! + public let handleQueue: dispatch_queue_attr_t! public let emitQueue = dispatch_queue_create("emitQueue", DISPATCH_QUEUE_SERIAL) public var closed:Bool { return _closed From c38412cae69035065d6e871fb70934663d61b7f3 Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 5 Aug 2015 12:27:46 -0400 Subject: [PATCH 3/7] bump version --- README.md | 4 ++-- Socket.IO-Client-Swift.podspec | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3994f4a..25ccaa2 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Carthage ----------------- Add this line to your `Cartfile`: ``` -github "socketio/socket.io-client-swift" ~> 2.4.1 # Or latest version +github "socketio/socket.io-client-swift" ~> 2.4.2 # Or latest version ``` Run `carthage update`. @@ -79,7 +79,7 @@ source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' use_frameworks! -pod 'Socket.IO-Client-Swift', '~> 2.4.1' # Or latest version +pod 'Socket.IO-Client-Swift', '~> 2.4.2' # Or latest version ``` Install pods: diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index 3987b1f..b20853b 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.4.1" + s.version = "2.4.2" 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.4.1' } + s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v2.4.2' } s.source_files = "SocketIOClientSwift/**/*.swift" s.requires_arc = true # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files From 0fd8a9540bd78280a9ad775fac5cfed1d778e671 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 10 Aug 2015 11:00:01 -0400 Subject: [PATCH 4/7] don't remove engine --- SocketIOClientSwift/SocketIOClient.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/SocketIOClientSwift/SocketIOClient.swift b/SocketIOClientSwift/SocketIOClient.swift index e55f8d1..aeb65ae 100644 --- a/SocketIOClientSwift/SocketIOClient.swift +++ b/SocketIOClientSwift/SocketIOClient.swift @@ -163,7 +163,6 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient _connected = false _reconnecting = false engine?.close(fast: fast) - engine = nil } /** From 6ee1daeaf7dfb710efba36fd590d551aa1dc7ab9 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 17 Aug 2015 00:09:04 -0400 Subject: [PATCH 5/7] fix bug in websocket library --- SocketIOClientSwift/WebSocket.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SocketIOClientSwift/WebSocket.swift b/SocketIOClientSwift/WebSocket.swift index 810f1b4..2fdb8f2 100644 --- a/SocketIOClientSwift/WebSocket.swift +++ b/SocketIOClientSwift/WebSocket.swift @@ -495,7 +495,7 @@ public class WebSocket : NSObject, NSStreamDelegate { dataLength = UInt64(bytes[0].bigEndian) offset += sizeof(UInt16) } - if bufferLen < offset { + if bufferLen < offset || UInt64(bufferLen - offset) < dataLength { fragBuffer = NSData(bytes: buffer, length: bufferLen) return } From 46cea36df795b8418eb7d8957f721129b0b8f044 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 17 Aug 2015 00:15:39 -0400 Subject: [PATCH 6/7] bump version --- README.md | 4 ++-- Socket.IO-Client-Swift.podspec | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 25ccaa2..b985e03 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Carthage ----------------- Add this line to your `Cartfile`: ``` -github "socketio/socket.io-client-swift" ~> 2.4.2 # Or latest version +github "socketio/socket.io-client-swift" ~> 2.4.3 # Or latest version ``` Run `carthage update`. @@ -79,7 +79,7 @@ source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' use_frameworks! -pod 'Socket.IO-Client-Swift', '~> 2.4.2' # Or latest version +pod 'Socket.IO-Client-Swift', '~> 2.4.3' # Or latest version ``` Install pods: diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index b20853b..ed772a2 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.4.2" + s.version = "2.4.3" 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.4.2' } + s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v2.4.3' } s.source_files = "SocketIOClientSwift/**/*.swift" s.requires_arc = true # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files From 17426c14320b485670e2e3e45c1fa2264b261177 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 31 Aug 2015 09:22:56 -0400 Subject: [PATCH 7/7] fix socketio/socket.io-client-swift#152 --- SocketIOClientSwift/SocketEngine.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/SocketIOClientSwift/SocketEngine.swift b/SocketIOClientSwift/SocketEngine.swift index f26f050..6a2b306 100644 --- a/SocketIOClientSwift/SocketEngine.swift +++ b/SocketIOClientSwift/SocketEngine.swift @@ -414,17 +414,25 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient { if let json = NSJSONSerialization.JSONObjectWithData(mesData, options: NSJSONReadingOptions.AllowFragments, error: &err) as? NSDictionary, sid = json["sid"] as? String { + let upgradeWs: Bool + self.sid = sid _connected = true - if !forcePolling && !forceWebsockets { - createWebsocket(andConnect: true) + if let upgrades = json["upgrades"] as? [String] { + upgradeWs = upgrades.filter {$0 == "websocket"}.count != 0 + } else { + upgradeWs = false } if let pingInterval = json["pingInterval"] as? Double, pingTimeout = json["pingTimeout"] as? Double { self.pingInterval = pingInterval / 1000.0 self.pingTimeout = pingTimeout / 1000.0 } + + if !forcePolling && !forceWebsockets && upgradeWs { + createWebsocket(andConnect: true) + } } else { client?.didError("Engine failed to handshake") return