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 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 - - diff --git a/Source/SocketEngine.swift b/Source/SocketEngine.swift index 0a690ba..268f10d 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.characters.index(message.startIndex, offsetBy: 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 e4d0c40..2e5a797 100644 --- a/Source/SocketParsable.swift +++ b/Source/SocketParsable.swift @@ -96,14 +96,14 @@ extension SocketParsable { if type == .Error { parser.advance(by: -1) - } - - while parser.hasNext && type != .Error { - if let int = Int(parser.read(length: 1)) { - idString += String(int) - } else { - parser.advance(by: -2) - break + } else { + while parser.hasNext { + if let int = Int(parser.read(length: 1)) { + idString += String(int) + } else { + parser.advance(by: -2) + break + } } } @@ -161,9 +161,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()