From 3d47ff469fba4cb33babbaaa43383d9528333287 Mon Sep 17 00:00:00 2001 From: Patrick Childers Date: Mon, 23 May 2016 17:03:51 -0400 Subject: [PATCH 1/5] Fix crash if error contains formatting strings. --- Source/SocketEngine.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/SocketEngine.swift b/Source/SocketEngine.swift index e06a811..fc7ff24 100644 --- a/Source/SocketEngine.swift +++ b/Source/SocketEngine.swift @@ -263,7 +263,7 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe } public func didError(error: String) { - DefaultSocketLogger.Logger.error(error, type: logType) + DefaultSocketLogger.Logger.error("%@", type: logType, args: error) client?.engineDidError(error) disconnect(error) } From ab536e227963513435612287a6a9e51736404feb Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 24 May 2016 11:08:22 -0400 Subject: [PATCH 2/5] bump version --- README.md | 6 +++--- Socket.IO-Client-Swift.podspec | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index de43c9d..056b0f5 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ Carthage ----------------- Add this line to your `Cartfile`: ``` -github "socketio/socket.io-client-swift" ~> 6.1.1 # Or latest version +github "socketio/socket.io-client-swift" ~> 6.1.2 # Or latest version ``` Run `carthage update --platform ios,macosx`. @@ -102,7 +102,7 @@ source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' use_frameworks! -pod 'Socket.IO-Client-Swift', '~> 6.1.1' # Or latest version +pod 'Socket.IO-Client-Swift', '~> 6.1.2' # Or latest version ``` Install pods: @@ -130,7 +130,7 @@ CocoaSeeds Add this line to your `Seedfile`: ``` -github "socketio/socket.io-client-swift", "v6.1.1", :files => "Source/*.swift" # Or latest version +github "socketio/socket.io-client-swift", "v6.1.2", :files => "Source/*.swift" # Or latest version ``` Run `seed install`. diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index 248adc5..ddf7a2d 100644 --- a/Socket.IO-Client-Swift.podspec +++ b/Socket.IO-Client-Swift.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Socket.IO-Client-Swift" s.module_name = "SocketIOClientSwift" - s.version = "6.1.1" + s.version = "6.1.2" s.summary = "Socket.IO-client for iOS and OS X" s.description = <<-DESC Socket.IO-client for iOS and OS X. @@ -14,7 +14,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.10' s.tvos.deployment_target = '9.0' - s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v6.1.1' } + s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v6.1.2' } s.source_files = "Source/**/*.swift" s.requires_arc = true # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files From ee24943c7215c5c7f25ddbc045d9e000585f8b36 Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 24 May 2016 11:26:50 -0400 Subject: [PATCH 3/5] remove ios tests folder --- .../project.pbxproj | 18 -------------- SocketIO-iOSTests/Info.plist | 24 ------------------- 2 files changed, 42 deletions(-) delete mode 100644 SocketIO-iOSTests/Info.plist diff --git a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj index c373933..9f5a682 100644 --- a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj +++ b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj @@ -160,7 +160,6 @@ 572EF21D1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-iOS.h"; sourceTree = ""; }; 572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - 572EF22A1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIOClientSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 572EF23B1B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-Mac.h"; sourceTree = ""; }; @@ -253,7 +252,6 @@ children = ( 5764DF7B1B51F24A004FF46E /* Source */, 572EF21B1B51F16C00EEBB58 /* SocketIO-iOS */, - 572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */, 572EF2391B51F18A00EEBB58 /* SocketIO-Mac */, 572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */, 572EF21A1B51F16C00EEBB58 /* Products */, @@ -290,22 +288,6 @@ name = "Supporting Files"; sourceTree = ""; }; - 572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */ = { - isa = PBXGroup; - children = ( - 572EF2291B51F16C00EEBB58 /* Supporting Files */, - ); - path = "SocketIO-iOSTests"; - sourceTree = ""; - }; - 572EF2291B51F16C00EEBB58 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 572EF22A1B51F16C00EEBB58 /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; 572EF2391B51F18A00EEBB58 /* SocketIO-Mac */ = { isa = PBXGroup; children = ( diff --git a/SocketIO-iOSTests/Info.plist b/SocketIO-iOSTests/Info.plist deleted file mode 100644 index ba72822..0000000 --- a/SocketIO-iOSTests/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - From 0564ded49280e79bdb5704e89e10e70b19f280ee Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 25 May 2016 08:47:50 -0400 Subject: [PATCH 4/5] don't check type on each pass through loop --- Source/SocketParsable.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/SocketParsable.swift b/Source/SocketParsable.swift index b6228e2..0c68765 100644 --- a/Source/SocketParsable.swift +++ b/Source/SocketParsable.swift @@ -96,14 +96,14 @@ extension SocketParsable { if type == .Error { parser.advanceIndexBy(-1) - } - - while parser.hasNext && type != .Error { - if let int = Int(parser.read(1)) { - idString += String(int) - } else { - parser.advanceIndexBy(-2) - break + } else { + while parser.hasNext { + if let int = Int(parser.read(1)) { + idString += String(int) + } else { + parser.advanceIndexBy(-2) + break + } } } From 71f9058723b376dec3e8196d3682ba0714161514 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 30 May 2016 21:42:00 -0400 Subject: [PATCH 5/5] refactors: refactor creating packet string, various other refactors --- Source/SocketEngine.swift | 13 ++--- Source/SocketEnginePollable.swift | 4 +- Source/SocketIOClient.swift | 3 +- Source/SocketPacket.swift | 82 ++++++++----------------------- Source/SocketParsable.swift | 4 +- 5 files changed, 28 insertions(+), 78 deletions(-) diff --git a/Source/SocketEngine.swift b/Source/SocketEngine.swift index e01e3b9..f22f73f 100644 --- a/Source/SocketEngine.swift +++ b/Source/SocketEngine.swift @@ -153,9 +153,8 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe // binary in base64 string let noPrefix = message[message.startIndex.advancedBy(2).. String { - let message: String - - if type == .Ack { - if nsp == "/" { - message = "3\(id)" - } else { - message = "3\(nsp),\(id)" - } - } else { - if nsp == "/" { - message = "6\(binary.count)-\(id)" - } else { - message = "6\(binary.count)-\(nsp),\(id)" - } - } - - return completeMessage(message) - } - - - private func createMessageForEvent() -> String { - let message: String - - if type == .Event { - if nsp == "/" { - if id == -1 { - message = "2" - } else { - message = "2\(id)" - } - } else { - if id == -1 { - message = "2\(nsp)," - } else { - message = "2\(nsp),\(id)" - } - } - } else { - if nsp == "/" { - if id == -1 { - message = "5\(binary.count)-" - } else { - message = "5\(binary.count)-\(id)" - } - } else { - if id == -1 { - message = "5\(binary.count)-\(nsp)," - } else { - message = "5\(binary.count)-\(nsp),\(id)" - } - } - } - - return completeMessage(message) - } - private func createPacketString() -> String { - let str: String + let typeString = String(type.rawValue) + let binaryCountString: String + let nspString: String + let idString: String - if type == .Event || type == .BinaryEvent { - str = createMessageForEvent() + if type == .BinaryEvent || type == .BinaryAck { + binaryCountString = typeString + String(binary.count) + "-" } else { - str = createAck() + binaryCountString = typeString } - return str + if nsp != "/" { + nspString = binaryCountString + nsp + "," + } else { + nspString = binaryCountString + } + + if id != -1 { + idString = nspString + String(id) + } else { + idString = nspString + } + + return completeMessage(idString) } // Called when we have all the binary data for a packet diff --git a/Source/SocketParsable.swift b/Source/SocketParsable.swift index 0c68765..577722a 100644 --- a/Source/SocketParsable.swift +++ b/Source/SocketParsable.swift @@ -162,9 +162,7 @@ extension SocketParsable { } // Should execute event? - guard waitingPackets[waitingPackets.count - 1].addData(data) else { - return - } + guard waitingPackets[waitingPackets.count - 1].addData(data) else { return } let packet = waitingPackets.removeLast()