From 17d3e659c11d61b6b296fb56fdb1f82abec1a1e8 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 1 Jul 2016 15:36:06 -0400 Subject: [PATCH 01/13] refactor some serialization into methods --- .../project.pbxproj | 24 +++---- Source/Extensions.swift | 68 +++++++++++++++++++ Source/NSCharacterSet.swift | 31 --------- Source/SocketEngine.swift | 35 ++++------ Source/SocketPacket.swift | 8 +-- Source/SocketParsable.swift | 9 +-- Source/String.swift | 31 --------- 7 files changed, 95 insertions(+), 111 deletions(-) create mode 100644 Source/Extensions.swift delete mode 100644 Source/NSCharacterSet.swift delete mode 100644 Source/String.swift diff --git a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj index 7d543f1..fd05fde 100644 --- a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj +++ b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj @@ -127,12 +127,9 @@ 74BC45AD1D0C6675008CC431 /* SocketClientManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */; }; 74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; }; 74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; }; - CEBA56961CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */; }; - CEBA56971CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */; }; - CEBA56981CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */; }; - CEBA569A1CDA0B8200BA0389 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* String.swift */; }; - CEBA569B1CDA0B8200BA0389 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* String.swift */; }; - CEBA569C1CDA0B8200BA0389 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* String.swift */; }; + CEBA569A1CDA0B8200BA0389 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* Extensions.swift */; }; + CEBA569B1CDA0B8200BA0389 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* Extensions.swift */; }; + CEBA569C1CDA0B8200BA0389 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* Extensions.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -200,8 +197,7 @@ 74B4AD201D09A6190062A523 /* SSLSecurity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSLSecurity.swift; path = Source/WebSocket/SSLSecurity.swift; sourceTree = ""; }; 74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketClientManager.swift; path = Source/SocketClientManager.swift; sourceTree = ""; }; 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketBasicPacketTest.swift; sourceTree = ""; }; - CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NSCharacterSet.swift; path = Source/NSCharacterSet.swift; sourceTree = ""; }; - CEBA56991CDA0B8200BA0389 /* String.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = String.swift; path = Source/String.swift; sourceTree = ""; }; + CEBA56991CDA0B8200BA0389 /* Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Extensions.swift; path = Source/Extensions.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -375,8 +371,7 @@ CEBA569E1CDA0C0C00BA0389 /* utils */ = { isa = PBXGroup; children = ( - CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */, - CEBA56991CDA0B8200BA0389 /* String.swift */, + CEBA56991CDA0B8200BA0389 /* Extensions.swift */, ); name = utils; sourceTree = ""; @@ -616,12 +611,11 @@ files = ( 740CA1221C496EF700CB98F4 /* SocketEngineWebsocket.swift in Sources */, 74171EA51C10CD240062D398 /* SocketIOClientStatus.swift in Sources */, - CEBA569A1CDA0B8200BA0389 /* String.swift in Sources */, + CEBA569A1CDA0B8200BA0389 /* Extensions.swift in Sources */, 74B4AD1D1D09A5D80062A523 /* WebSocket.swift in Sources */, 74171E751C10CD240062D398 /* SocketEngine.swift in Sources */, 74171E691C10CD240062D398 /* SocketAckManager.swift in Sources */, 7420CB791C49629E00956AA4 /* SocketEnginePollable.swift in Sources */, - CEBA56961CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */, 74ABF7771C3991C10078C657 /* SocketIOClientSpec.swift in Sources */, 74171E871C10CD240062D398 /* SocketEngineSpec.swift in Sources */, 74171E631C10CD240062D398 /* SocketAckEmitter.swift in Sources */, @@ -675,11 +669,10 @@ 74B4AD241D09A6450062A523 /* WebSocket.swift in Sources */, 740CA1211C496EF200CB98F4 /* SocketEngineWebsocket.swift in Sources */, 7471CCEA1C39926300364B59 /* SocketIOClientSpec.swift in Sources */, - CEBA569B1CDA0B8200BA0389 /* String.swift in Sources */, + CEBA569B1CDA0B8200BA0389 /* Extensions.swift in Sources */, 74171EA71C10CD240062D398 /* SocketIOClientStatus.swift in Sources */, 74171E771C10CD240062D398 /* SocketEngine.swift in Sources */, 7420CB7A1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */, - CEBA56971CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */, 74171E6B1C10CD240062D398 /* SocketAckManager.swift in Sources */, 74171E891C10CD240062D398 /* SocketEngineSpec.swift in Sources */, 74171E651C10CD240062D398 /* SocketAckEmitter.swift in Sources */, @@ -721,11 +714,10 @@ 74B4AD251D09A6490062A523 /* WebSocket.swift in Sources */, 740CA1201C496EEB00CB98F4 /* SocketEngineWebsocket.swift in Sources */, 7471CCEB1C39926C00364B59 /* SocketIOClientSpec.swift in Sources */, - CEBA569C1CDA0B8200BA0389 /* String.swift in Sources */, + CEBA569C1CDA0B8200BA0389 /* Extensions.swift in Sources */, 74171EA91C10CD240062D398 /* SocketIOClientStatus.swift in Sources */, 74171E791C10CD240062D398 /* SocketEngine.swift in Sources */, 7420CB7B1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */, - CEBA56981CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */, 74171E6D1C10CD240062D398 /* SocketAckManager.swift in Sources */, 74171E8B1C10CD240062D398 /* SocketEngineSpec.swift in Sources */, 74171E671C10CD240062D398 /* SocketAckEmitter.swift in Sources */, diff --git a/Source/Extensions.swift b/Source/Extensions.swift new file mode 100644 index 0000000..6da96fd --- /dev/null +++ b/Source/Extensions.swift @@ -0,0 +1,68 @@ +// +// Extensions.swift +// Socket.IO-Client-Swift +// +// Created by Erik Little on 7/1/2016. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation + +enum JSONError : ErrorType { + case notArray + case notNSDictionary +} + +extension Array where Element: AnyObject { + func toJSON() throws -> NSData { + return try NSJSONSerialization.dataWithJSONObject(self as NSArray, options: NSJSONWritingOptions(rawValue: 0)) + } +} + +extension NSCharacterSet { + class var allowedURLCharacterSet: NSCharacterSet { + return NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet + } +} + +extension String { + func toArray() throws -> [AnyObject] { + guard let stringData = dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) else { return [] } + + guard let array = try NSJSONSerialization.JSONObjectWithData(stringData, options: .MutableContainers) as? [AnyObject] else { + throw JSONError.notArray + } + + return array + } + + func toNSDictionary() throws -> NSDictionary { + let binData = dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)! + + guard let json = try NSJSONSerialization.JSONObjectWithData(binData, options: .AllowFragments) as? NSDictionary else { + throw JSONError.notNSDictionary + } + + return json + } + + func urlEncode() -> String? { + return stringByAddingPercentEncodingWithAllowedCharacters(.allowedURLCharacterSet) + } +} diff --git a/Source/NSCharacterSet.swift b/Source/NSCharacterSet.swift deleted file mode 100644 index 3ccde2c..0000000 --- a/Source/NSCharacterSet.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// NSCharacterSet.swift -// Socket.IO-Client-Swift -// -// Created by Yannick Loriot on 5/4/16. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -import Foundation - -extension NSCharacterSet { - class var allowedURLCharacterSet: NSCharacterSet { - return NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet - } -} diff --git a/Source/SocketEngine.swift b/Source/SocketEngine.swift index c6244e0..8630529 100644 --- a/Source/SocketEngine.swift +++ b/Source/SocketEngine.swift @@ -131,21 +131,17 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe } private func checkAndHandleEngineError(msg: String) { - guard let stringData = msg.dataUsingEncoding(NSUTF8StringEncoding, - allowLossyConversion: false) else { return } - do { - if let dict = try NSJSONSerialization.JSONObjectWithData(stringData, options: .MutableContainers) as? NSDictionary { - guard let error = dict["message"] as? String else { return } - - /* - 0: Unknown transport - 1: Unknown sid - 2: Bad handshake request - 3: Bad request - */ - didError(error) - } + let dict = try msg.toNSDictionary() + guard let error = dict["message"] as? String else { return } + + /* + 0: Unknown transport + 1: Unknown sid + 2: Bad handshake request + 3: Bad request + */ + didError(error) } catch { client?.engineDidError("Got unknown error from server \(msg)") } @@ -363,23 +359,22 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe } private func handleOpen(openData: String) { - let mesData = openData.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)! do { - let json = try NSJSONSerialization.JSONObjectWithData(mesData, - options: NSJSONReadingOptions.AllowFragments) as? NSDictionary - if let sid = json?["sid"] as? String { + let json = try openData.toNSDictionary() + + if let sid = json["sid"] as? String { let upgradeWs: Bool self.sid = sid connected = true - if let upgrades = json?["upgrades"] as? [String] { + if let upgrades = json["upgrades"] as? [String] { upgradeWs = upgrades.contains("websocket") } else { upgradeWs = false } - if let pingInterval = json?["pingInterval"] as? Double, pingTimeout = json?["pingTimeout"] as? Double { + if let pingInterval = json["pingInterval"] as? Double, pingTimeout = json["pingTimeout"] as? Double { self.pingInterval = pingInterval / 1000.0 self.pingTimeout = pingTimeout / 1000.0 } diff --git a/Source/SocketPacket.swift b/Source/SocketPacket.swift index 47bebed..5105333 100644 --- a/Source/SocketPacket.swift +++ b/Source/SocketPacket.swift @@ -94,11 +94,9 @@ struct SocketPacket { } do { - let jsonSend = try NSJSONSerialization.dataWithJSONObject(data, - options: NSJSONWritingOptions(rawValue: 0)) - guard let jsonString = String(data: jsonSend, encoding: NSUTF8StringEncoding) else { - return message + "[]" - } + let jsonSend = try data.toJSON() + + guard let jsonString = String(data: jsonSend, encoding: NSUTF8StringEncoding) else { return message + "[]" } restOfMessage = jsonString } catch { diff --git a/Source/SocketParsable.swift b/Source/SocketParsable.swift index 577722a..47ff845 100644 --- a/Source/SocketParsable.swift +++ b/Source/SocketParsable.swift @@ -126,15 +126,8 @@ extension SocketParsable { // Parses data for events private func parseData(data: String) -> Either { - let stringData = data.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) - do { - if let arr = try NSJSONSerialization.JSONObjectWithData(stringData!, - options: NSJSONReadingOptions.MutableContainers) as? [AnyObject] { - return .Right(arr) - } else { - return .Left("Expected data array") - } + return .Right(try data.toArray()) } catch { return .Left("Error parsing data for packet") } diff --git a/Source/String.swift b/Source/String.swift deleted file mode 100644 index 0e30e8c..0000000 --- a/Source/String.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// String.swift -// Socket.IO-Client-Swift -// -// Created by Yannick Loriot on 5/4/16. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -import Foundation - -extension String { - func urlEncode() -> String? { - return stringByAddingPercentEncodingWithAllowedCharacters(.allowedURLCharacterSet) - } -} From 5840d2b61bf6970de6fc21d40f2c84d3e7ebe9a1 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 1 Jul 2016 15:38:53 -0400 Subject: [PATCH 02/13] refactoring --- Source/Extensions.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/Extensions.swift b/Source/Extensions.swift index 6da96fd..2f1d140 100644 --- a/Source/Extensions.swift +++ b/Source/Extensions.swift @@ -44,7 +44,6 @@ extension NSCharacterSet { extension String { func toArray() throws -> [AnyObject] { guard let stringData = dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) else { return [] } - guard let array = try NSJSONSerialization.JSONObjectWithData(stringData, options: .MutableContainers) as? [AnyObject] else { throw JSONError.notArray } @@ -53,8 +52,7 @@ extension String { } func toNSDictionary() throws -> NSDictionary { - let binData = dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)! - + guard let binData = dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) else { return [:] } guard let json = try NSJSONSerialization.JSONObjectWithData(binData, options: .AllowFragments) as? NSDictionary else { throw JSONError.notNSDictionary } From f00ed17783d2654f11a01528cbe636e10046587d Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 1 Jul 2016 15:42:13 -0400 Subject: [PATCH 03/13] refactors, rename file --- .../project.pbxproj | 24 +++++++------------ ...xtensions.swift => SocketExtensions.swift} | 2 +- Source/SocketPacket.swift | 1 - 3 files changed, 9 insertions(+), 18 deletions(-) rename Source/{Extensions.swift => SocketExtensions.swift} (98%) diff --git a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj index fd05fde..e795864 100644 --- a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj +++ b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj @@ -127,9 +127,9 @@ 74BC45AD1D0C6675008CC431 /* SocketClientManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */; }; 74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; }; 74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; }; - CEBA569A1CDA0B8200BA0389 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* Extensions.swift */; }; - CEBA569B1CDA0B8200BA0389 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* Extensions.swift */; }; - CEBA569C1CDA0B8200BA0389 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* Extensions.swift */; }; + CEBA569A1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */; }; + CEBA569B1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */; }; + CEBA569C1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -197,7 +197,7 @@ 74B4AD201D09A6190062A523 /* SSLSecurity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSLSecurity.swift; path = Source/WebSocket/SSLSecurity.swift; sourceTree = ""; }; 74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketClientManager.swift; path = Source/SocketClientManager.swift; sourceTree = ""; }; 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketBasicPacketTest.swift; sourceTree = ""; }; - CEBA56991CDA0B8200BA0389 /* Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Extensions.swift; path = Source/Extensions.swift; sourceTree = ""; }; + CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketExtensions.swift; path = Source/SocketExtensions.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -344,6 +344,7 @@ 74171E561C10CD240062D398 /* SocketEngineSpec.swift */, 740CA11F1C496EEB00CB98F4 /* SocketEngineWebsocket.swift */, 74171E571C10CD240062D398 /* SocketEventHandler.swift */, + CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */, 74171E591C10CD240062D398 /* SocketIOClient.swift */, 74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */, 74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */, @@ -353,7 +354,6 @@ 74171E5E1C10CD240062D398 /* SocketParsable.swift */, 74171E5F1C10CD240062D398 /* SocketStringReader.swift */, 74171E601C10CD240062D398 /* SocketTypes.swift */, - CEBA569E1CDA0C0C00BA0389 /* utils */, 74B4AD1B1D09A5C30062A523 /* Websocket */, ); name = Source; @@ -368,14 +368,6 @@ name = Websocket; sourceTree = ""; }; - CEBA569E1CDA0C0C00BA0389 /* utils */ = { - isa = PBXGroup; - children = ( - CEBA56991CDA0B8200BA0389 /* Extensions.swift */, - ); - name = utils; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -611,7 +603,7 @@ files = ( 740CA1221C496EF700CB98F4 /* SocketEngineWebsocket.swift in Sources */, 74171EA51C10CD240062D398 /* SocketIOClientStatus.swift in Sources */, - CEBA569A1CDA0B8200BA0389 /* Extensions.swift in Sources */, + CEBA569A1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */, 74B4AD1D1D09A5D80062A523 /* WebSocket.swift in Sources */, 74171E751C10CD240062D398 /* SocketEngine.swift in Sources */, 74171E691C10CD240062D398 /* SocketAckManager.swift in Sources */, @@ -669,7 +661,7 @@ 74B4AD241D09A6450062A523 /* WebSocket.swift in Sources */, 740CA1211C496EF200CB98F4 /* SocketEngineWebsocket.swift in Sources */, 7471CCEA1C39926300364B59 /* SocketIOClientSpec.swift in Sources */, - CEBA569B1CDA0B8200BA0389 /* Extensions.swift in Sources */, + CEBA569B1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */, 74171EA71C10CD240062D398 /* SocketIOClientStatus.swift in Sources */, 74171E771C10CD240062D398 /* SocketEngine.swift in Sources */, 7420CB7A1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */, @@ -714,7 +706,7 @@ 74B4AD251D09A6490062A523 /* WebSocket.swift in Sources */, 740CA1201C496EEB00CB98F4 /* SocketEngineWebsocket.swift in Sources */, 7471CCEB1C39926C00364B59 /* SocketIOClientSpec.swift in Sources */, - CEBA569C1CDA0B8200BA0389 /* Extensions.swift in Sources */, + CEBA569C1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */, 74171EA91C10CD240062D398 /* SocketIOClientStatus.swift in Sources */, 74171E791C10CD240062D398 /* SocketEngine.swift in Sources */, 7420CB7B1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */, diff --git a/Source/Extensions.swift b/Source/SocketExtensions.swift similarity index 98% rename from Source/Extensions.swift rename to Source/SocketExtensions.swift index 2f1d140..74f032b 100644 --- a/Source/Extensions.swift +++ b/Source/SocketExtensions.swift @@ -1,5 +1,5 @@ // -// Extensions.swift +// SocketExtensions.swift // Socket.IO-Client-Swift // // Created by Erik Little on 7/1/2016. diff --git a/Source/SocketPacket.swift b/Source/SocketPacket.swift index 5105333..6326453 100644 --- a/Source/SocketPacket.swift +++ b/Source/SocketPacket.swift @@ -95,7 +95,6 @@ struct SocketPacket { do { let jsonSend = try data.toJSON() - guard let jsonString = String(data: jsonSend, encoding: NSUTF8StringEncoding) else { return message + "[]" } restOfMessage = jsonString From f52607f722328641c3037750c1d140b0be5670ed Mon Sep 17 00:00:00 2001 From: Erik Little Date: Fri, 1 Jul 2016 17:06:37 -0400 Subject: [PATCH 04/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9114c86..1db6a38 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ case ReconnectWait(Int) // Amount of time to wait between reconnects. Default is case SessionDelegate(NSURLSessionDelegate) // Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil. case Secure(Bool) // If the connection should use TLS. Default is false. case Security(SSLSecurity) // Allows you to set which certs are valid. Useful for SSL pinning. -case SelfSigned(Bool) // Sets WebSocket.selfSignedSSL (Don't do this, iOS will yell at you) +case SelfSigned(Bool) // Sets WebSocket.selfSignedSSL. Use this if you're using self-signed certs. case VoipEnabled(Bool) // Only use this option if you're using the client with VoIP services. Changes the way the WebSocket is created. Default is false ``` Methods From 22030e1153230545cb8d9dbe536356027735e7e6 Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 6 Jul 2016 11:19:18 -0400 Subject: [PATCH 05/13] refactors --- Source/SocketAckManager.swift | 2 +- Source/SocketClientManager.swift | 2 +- Source/SocketEnginePollable.swift | 14 +++++--------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Source/SocketAckManager.swift b/Source/SocketAckManager.swift index 972e1da..8143243 100644 --- a/Source/SocketAckManager.swift +++ b/Source/SocketAckManager.swift @@ -24,7 +24,7 @@ import Foundation -private struct SocketAck : Hashable, Equatable { +private struct SocketAck : Hashable { let ack: Int var callback: AckCallback! var hashValue: Int { diff --git a/Source/SocketClientManager.swift b/Source/SocketClientManager.swift index 3cf1c34..ae79179 100644 --- a/Source/SocketClientManager.swift +++ b/Source/SocketClientManager.swift @@ -66,7 +66,7 @@ public final class SocketClientManager : NSObject { return sockets.removeValueForKey(label) } - public func removeSocket(socket socket: SocketIOClient) -> SocketIOClient? { + public func removeSocket(socket: SocketIOClient) -> SocketIOClient? { var returnSocket: SocketIOClient? for (label, dictSocket) in sockets where dictSocket === socket { diff --git a/Source/SocketEnginePollable.swift b/Source/SocketEnginePollable.swift index e8d1718..77dc7f6 100644 --- a/Source/SocketEnginePollable.swift +++ b/Source/SocketEnginePollable.swift @@ -59,6 +59,8 @@ extension SocketEnginePollable { } func createRequestForPostWithPostWait() -> NSURLRequest { + defer { postWait.removeAll(keepCapacity: true) } + var postStr = "" for packet in postWait { @@ -69,18 +71,13 @@ extension SocketEnginePollable { DefaultSocketLogger.Logger.log("Created POST string: %@", type: "SocketEnginePolling", args: postStr) - postWait.removeAll(keepCapacity: false) - let req = NSMutableURLRequest(URL: urlPollingWithSid) + let postData = postStr.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)! addHeaders(req) req.HTTPMethod = "POST" req.setValue("text/plain; charset=UTF-8", forHTTPHeaderField: "Content-Type") - - let postData = postStr.dataUsingEncoding(NSUTF8StringEncoding, - allowLossyConversion: false)! - req.HTTPBody = postData req.setValue(String(postData.length), forHTTPHeaderField: "Content-Length") @@ -88,11 +85,10 @@ extension SocketEnginePollable { } public func doPoll() { - if websocket || waitingForPoll || !connected || closed { - return - } + if websocket || waitingForPoll || !connected || closed { return } waitingForPoll = true + let req = NSMutableURLRequest(URL: urlPollingWithSid) addHeaders(req) From 9cc60ab63d9dfd36f512f54d84af550fdbcaa975 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 14 Jul 2016 18:57:27 -0400 Subject: [PATCH 06/13] hopefully fix race condition in acks --- Source/SocketAckManager.swift | 12 +++++------- Source/SocketIOClient.swift | 10 ++++++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Source/SocketAckManager.swift b/Source/SocketAckManager.swift index 8143243..e229c93 100644 --- a/Source/SocketAckManager.swift +++ b/Source/SocketAckManager.swift @@ -56,19 +56,17 @@ struct SocketAckManager { acks.insert(SocketAck(ack: ack, callback: callback)) } + /// Should be called on handle queue mutating func executeAck(ack: Int, items: [AnyObject]) { let callback = acks.remove(SocketAck(ack: ack)) - - dispatch_async(dispatch_get_main_queue()) { - callback?.callback(items) - } + + callback?.callback(items) } + /// Should be called on handle queue mutating func timeoutAck(ack: Int) { let callback = acks.remove(SocketAck(ack: ack)) - dispatch_async(dispatch_get_main_queue()) { - callback?.callback(["NO ACK"]) - } + callback?.callback(["NO ACK"]) } } diff --git a/Source/SocketIOClient.swift b/Source/SocketIOClient.swift index 70c6f22..a176059 100644 --- a/Source/SocketIOClient.swift +++ b/Source/SocketIOClient.swift @@ -60,6 +60,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable private var reconnecting = false private(set) var currentAck = -1 + // Handle queue also controls access to ackManager private(set) var handleQueue = dispatch_get_main_queue() private(set) var reconnectAttempts = -1 @@ -162,7 +163,10 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable return {[weak self, ack = currentAck] timeout, callback in if let this = self { - this.ackHandlers.addAck(ack, callback: callback) + dispatch_sync(this.handleQueue) { + this.ackHandlers.addAck(ack, callback: callback) + } + this._emit(items, ack: ack) if timeout != 0 { @@ -294,7 +298,9 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable DefaultSocketLogger.Logger.log("Handling ack: %@ with data: %@", type: logType, args: ack, data ?? "") - ackHandlers.executeAck(ack, items: data) + dispatch_async(handleQueue) { + self.ackHandlers.executeAck(ack, items: data) + } } /// Causes an event to be handled. Only use if you know what you're doing. From 8345eae28cdae8774fbe8e55fc337133308a8af4 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 14 Jul 2016 19:25:48 -0400 Subject: [PATCH 07/13] don't stall queues --- Source/SocketAckManager.swift | 12 ++++++++---- Source/SocketIOClient.swift | 10 ++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Source/SocketAckManager.swift b/Source/SocketAckManager.swift index e229c93..682b4f8 100644 --- a/Source/SocketAckManager.swift +++ b/Source/SocketAckManager.swift @@ -57,16 +57,20 @@ struct SocketAckManager { } /// Should be called on handle queue - mutating func executeAck(ack: Int, items: [AnyObject]) { + mutating func executeAck(ack: Int, items: [AnyObject], onQueue: dispatch_queue_t) { let callback = acks.remove(SocketAck(ack: ack)) - callback?.callback(items) + dispatch_async(onQueue) { + callback?.callback(items) + } } /// Should be called on handle queue - mutating func timeoutAck(ack: Int) { + mutating func timeoutAck(ack: Int, onQueue: dispatch_queue_t) { let callback = acks.remove(SocketAck(ack: ack)) - callback?.callback(["NO ACK"]) + dispatch_async(onQueue) { + callback?.callback(["NO ACK"]) + } } } diff --git a/Source/SocketIOClient.swift b/Source/SocketIOClient.swift index a176059..ac5a159 100644 --- a/Source/SocketIOClient.swift +++ b/Source/SocketIOClient.swift @@ -49,6 +49,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable return nsp + "#" + (engine?.sid ?? "") } + private let ackQueue = dispatch_queue_create("com.socketio.ackQueue", DISPATCH_QUEUE_SERIAL) private let emitQueue = dispatch_queue_create("com.socketio.emitQueue", DISPATCH_QUEUE_SERIAL) private let logType = "SocketIOClient" private let parseQueue = dispatch_queue_create("com.socketio.parseQueue", DISPATCH_QUEUE_SERIAL) @@ -163,17 +164,18 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable return {[weak self, ack = currentAck] timeout, callback in if let this = self { - dispatch_sync(this.handleQueue) { + dispatch_sync(this.ackQueue) { this.ackHandlers.addAck(ack, callback: callback) } + this._emit(items, ack: ack) if timeout != 0 { let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC)) - dispatch_after(time, this.handleQueue) { - this.ackHandlers.timeoutAck(ack) + dispatch_after(time, this.ackQueue) { + this.ackHandlers.timeoutAck(ack, onQueue: this.handleQueue) } } } @@ -299,7 +301,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable DefaultSocketLogger.Logger.log("Handling ack: %@ with data: %@", type: logType, args: ack, data ?? "") dispatch_async(handleQueue) { - self.ackHandlers.executeAck(ack, items: data) + self.ackHandlers.executeAck(ack, items: data, onQueue: self.handleQueue) } } From dce28b2dac4be8153790314706640e1f1315bf6e Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 14 Jul 2016 19:26:56 -0400 Subject: [PATCH 08/13] fixes --- Source/SocketIOClient.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/SocketIOClient.swift b/Source/SocketIOClient.swift index ac5a159..ca7fe19 100644 --- a/Source/SocketIOClient.swift +++ b/Source/SocketIOClient.swift @@ -61,7 +61,6 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable private var reconnecting = false private(set) var currentAck = -1 - // Handle queue also controls access to ackManager private(set) var handleQueue = dispatch_get_main_queue() private(set) var reconnectAttempts = -1 @@ -300,7 +299,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable DefaultSocketLogger.Logger.log("Handling ack: %@ with data: %@", type: logType, args: ack, data ?? "") - dispatch_async(handleQueue) { + dispatch_async(ackQueue) { self.ackHandlers.executeAck(ack, items: data, onQueue: self.handleQueue) } } From a9ac86ba3d0f833969aa7296217d51901e5302e1 Mon Sep 17 00:00:00 2001 From: Erik Little Date: Fri, 15 Jul 2016 10:11:05 -0400 Subject: [PATCH 09/13] fix method call --- SocketIO-MacTests/SocketAckManagerTest.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SocketIO-MacTests/SocketAckManagerTest.swift b/SocketIO-MacTests/SocketAckManagerTest.swift index 67315ac..91a2f25 100644 --- a/SocketIO-MacTests/SocketAckManagerTest.swift +++ b/SocketIO-MacTests/SocketAckManagerTest.swift @@ -11,7 +11,7 @@ import XCTest class SocketAckManagerTest: XCTestCase { var ackManager = SocketAckManager() - + func testAddAcks() { let callbackExpection = self.expectationWithDescription("callbackExpection") let itemsArray = ["Hi", "ho"] @@ -19,8 +19,8 @@ class SocketAckManagerTest: XCTestCase { callbackExpection.fulfill() } ackManager.addAck(1, callback: callback) - ackManager.executeAck(1, items: itemsArray) + ackManager.executeAck(1, items: itemsArray, onQueue: dispatch_get_main_queue()) waitForExpectationsWithTimeout(3.0, handler: nil) - + } } From 559fbc0286ebb53a5f88f6c58aac268f6bc26c8c Mon Sep 17 00:00:00 2001 From: Adam Putinski Date: Wed, 13 Jul 2016 06:34:02 -0400 Subject: [PATCH 10/13] Enable APPLICATION_EXTENSION_API_ONLY --- Socket.IO-Client-Swift.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj index e795864..1e7cdca 100644 --- a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj +++ b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj @@ -814,6 +814,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -870,6 +871,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; From e56741b669891e854adaf793fe0ad5a5ee3719bc Mon Sep 17 00:00:00 2001 From: Erik Little Date: Tue, 19 Jul 2016 15:03:03 -0400 Subject: [PATCH 11/13] rename variable --- Source/SocketParsable.swift | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/SocketParsable.swift b/Source/SocketParsable.swift index 47ff845..d5a1b9d 100644 --- a/Source/SocketParsable.swift +++ b/Source/SocketParsable.swift @@ -63,13 +63,13 @@ extension SocketParsable { /// Parses a messsage from the engine. Returning either a string error or a complete SocketPacket func parseString(message: String) -> Either { - var parser = SocketStringReader(message: message) + var reader = SocketStringReader(message: message) - guard let type = SocketPacket.PacketType(rawValue: Int(parser.read(1)) ?? -1) else { + guard let type = SocketPacket.PacketType(rawValue: Int(reader.read(1)) ?? -1) else { return .Left("Invalid packet type") } - if !parser.hasNext { + if !reader.hasNext { return .Right(SocketPacket(type: type, nsp: "/")) } @@ -77,37 +77,37 @@ extension SocketParsable { var placeholders = -1 if type == .BinaryEvent || type == .BinaryAck { - if let holders = Int(parser.readUntilStringOccurence("-")) { + if let holders = Int(reader.readUntilStringOccurence("-")) { placeholders = holders } else { return .Left("Invalid packet") } } - if parser.currentCharacter == "/" { - namespace = parser.readUntilStringOccurence(",") ?? parser.readUntilEnd() + if reader.currentCharacter == "/" { + namespace = reader.readUntilStringOccurence(",") ?? reader.readUntilEnd() } - if !parser.hasNext { + if !reader.hasNext { return .Right(SocketPacket(type: type, nsp: namespace, placeholders: placeholders)) } var idString = "" if type == .Error { - parser.advanceIndexBy(-1) + reader.advanceIndexBy(-1) } else { - while parser.hasNext { - if let int = Int(parser.read(1)) { + while reader.hasNext { + if let int = Int(reader.read(1)) { idString += String(int) } else { - parser.advanceIndexBy(-2) + reader.advanceIndexBy(-2) break } } } - let d = message[parser.currentIndex.advancedBy(1).. Date: Wed, 20 Jul 2016 11:22:05 -0400 Subject: [PATCH 12/13] fix swiftpm --- .../project.pbxproj | 32 +++++++++---------- Source/{WebSocket => }/SSLSecurity.swift | 0 Source/{WebSocket => }/WebSocket.swift | 0 3 files changed, 16 insertions(+), 16 deletions(-) rename Source/{WebSocket => }/SSLSecurity.swift (100%) rename Source/{WebSocket => }/WebSocket.swift (100%) diff --git a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj index 1e7cdca..d005db9 100644 --- a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj +++ b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj @@ -115,13 +115,13 @@ 7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; }; 7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; }; 7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; }; + 749642B51D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */; }; + 749642B61D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */; }; + 749642B71D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */; }; + 749642B81D3FCE5500DD32D1 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B41D3FCE5500DD32D1 /* WebSocket.swift */; }; + 749642B91D3FCE5500DD32D1 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B41D3FCE5500DD32D1 /* WebSocket.swift */; }; + 749642BA1D3FCE5500DD32D1 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B41D3FCE5500DD32D1 /* WebSocket.swift */; }; 74ABF7771C3991C10078C657 /* SocketIOClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */; }; - 74B4AD1D1D09A5D80062A523 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B4AD1C1D09A5D80062A523 /* WebSocket.swift */; }; - 74B4AD211D09A6190062A523 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B4AD201D09A6190062A523 /* SSLSecurity.swift */; }; - 74B4AD221D09A6190062A523 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B4AD201D09A6190062A523 /* SSLSecurity.swift */; }; - 74B4AD231D09A6190062A523 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B4AD201D09A6190062A523 /* SSLSecurity.swift */; }; - 74B4AD241D09A6450062A523 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B4AD1C1D09A5D80062A523 /* WebSocket.swift */; }; - 74B4AD251D09A6490062A523 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B4AD1C1D09A5D80062A523 /* WebSocket.swift */; }; 74BC45AB1D0C6675008CC431 /* SocketClientManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */; }; 74BC45AC1D0C6675008CC431 /* SocketClientManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */; }; 74BC45AD1D0C6675008CC431 /* SocketClientManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */; }; @@ -192,9 +192,9 @@ 74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocketParserTest.swift; sourceTree = ""; }; 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespacePacketTest.swift; sourceTree = ""; }; 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketSideEffectTest.swift; sourceTree = ""; }; + 749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSLSecurity.swift; path = Source/SSLSecurity.swift; sourceTree = ""; }; + 749642B41D3FCE5500DD32D1 /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = Source/WebSocket.swift; sourceTree = ""; }; 74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClientSpec.swift; path = Source/SocketIOClientSpec.swift; sourceTree = ""; }; - 74B4AD1C1D09A5D80062A523 /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = Source/WebSocket/WebSocket.swift; sourceTree = ""; }; - 74B4AD201D09A6190062A523 /* SSLSecurity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSLSecurity.swift; path = Source/WebSocket/SSLSecurity.swift; sourceTree = ""; }; 74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketClientManager.swift; path = Source/SocketClientManager.swift; sourceTree = ""; }; 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketBasicPacketTest.swift; sourceTree = ""; }; CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketExtensions.swift; path = Source/SocketExtensions.swift; sourceTree = ""; }; @@ -362,8 +362,8 @@ 74B4AD1B1D09A5C30062A523 /* Websocket */ = { isa = PBXGroup; children = ( - 74B4AD1C1D09A5D80062A523 /* WebSocket.swift */, - 74B4AD201D09A6190062A523 /* SSLSecurity.swift */, + 749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */, + 749642B41D3FCE5500DD32D1 /* WebSocket.swift */, ); name = Websocket; sourceTree = ""; @@ -604,21 +604,21 @@ 740CA1221C496EF700CB98F4 /* SocketEngineWebsocket.swift in Sources */, 74171EA51C10CD240062D398 /* SocketIOClientStatus.swift in Sources */, CEBA569A1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */, - 74B4AD1D1D09A5D80062A523 /* WebSocket.swift in Sources */, 74171E751C10CD240062D398 /* SocketEngine.swift in Sources */, 74171E691C10CD240062D398 /* SocketAckManager.swift in Sources */, 7420CB791C49629E00956AA4 /* SocketEnginePollable.swift in Sources */, 74ABF7771C3991C10078C657 /* SocketIOClientSpec.swift in Sources */, 74171E871C10CD240062D398 /* SocketEngineSpec.swift in Sources */, 74171E631C10CD240062D398 /* SocketAckEmitter.swift in Sources */, - 74B4AD211D09A6190062A523 /* SSLSecurity.swift in Sources */, 74171EBD1C10CD240062D398 /* SocketStringReader.swift in Sources */, 74171EC31C10CD240062D398 /* SocketTypes.swift in Sources */, 74171EAB1C10CD240062D398 /* SocketLogger.swift in Sources */, 74171E991C10CD240062D398 /* SocketIOClient.swift in Sources */, + 749642B81D3FCE5500DD32D1 /* WebSocket.swift in Sources */, 74171E8D1C10CD240062D398 /* SocketEventHandler.swift in Sources */, 74171E7B1C10CD240062D398 /* SocketEngineClient.swift in Sources */, 74171EB11C10CD240062D398 /* SocketPacket.swift in Sources */, + 749642B51D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */, 74171EB71C10CD240062D398 /* SocketParsable.swift in Sources */, 74171E811C10CD240062D398 /* SocketEnginePacketType.swift in Sources */, 74171E6F1C10CD240062D398 /* SocketAnyEvent.swift in Sources */, @@ -658,7 +658,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 74B4AD241D09A6450062A523 /* WebSocket.swift in Sources */, 740CA1211C496EF200CB98F4 /* SocketEngineWebsocket.swift in Sources */, 7471CCEA1C39926300364B59 /* SocketIOClientSpec.swift in Sources */, CEBA569B1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */, @@ -672,10 +671,11 @@ 74171EC51C10CD240062D398 /* SocketTypes.swift in Sources */, 74171EAD1C10CD240062D398 /* SocketLogger.swift in Sources */, 74171E9B1C10CD240062D398 /* SocketIOClient.swift in Sources */, + 749642B91D3FCE5500DD32D1 /* WebSocket.swift in Sources */, 74171E8F1C10CD240062D398 /* SocketEventHandler.swift in Sources */, 74171E7D1C10CD240062D398 /* SocketEngineClient.swift in Sources */, - 74B4AD221D09A6190062A523 /* SSLSecurity.swift in Sources */, 74171EB31C10CD240062D398 /* SocketPacket.swift in Sources */, + 749642B61D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */, 74171EB91C10CD240062D398 /* SocketParsable.swift in Sources */, 74171E831C10CD240062D398 /* SocketEnginePacketType.swift in Sources */, 74171E711C10CD240062D398 /* SocketAnyEvent.swift in Sources */, @@ -703,7 +703,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 74B4AD251D09A6490062A523 /* WebSocket.swift in Sources */, 740CA1201C496EEB00CB98F4 /* SocketEngineWebsocket.swift in Sources */, 7471CCEB1C39926C00364B59 /* SocketIOClientSpec.swift in Sources */, CEBA569C1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */, @@ -717,10 +716,11 @@ 74171EC71C10CD240062D398 /* SocketTypes.swift in Sources */, 74171EAF1C10CD240062D398 /* SocketLogger.swift in Sources */, 74171E9D1C10CD240062D398 /* SocketIOClient.swift in Sources */, + 749642BA1D3FCE5500DD32D1 /* WebSocket.swift in Sources */, 74171E911C10CD240062D398 /* SocketEventHandler.swift in Sources */, 74171E7F1C10CD240062D398 /* SocketEngineClient.swift in Sources */, - 74B4AD231D09A6190062A523 /* SSLSecurity.swift in Sources */, 74171EB51C10CD240062D398 /* SocketPacket.swift in Sources */, + 749642B71D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */, 74171EBB1C10CD240062D398 /* SocketParsable.swift in Sources */, 74171E851C10CD240062D398 /* SocketEnginePacketType.swift in Sources */, 74171E731C10CD240062D398 /* SocketAnyEvent.swift in Sources */, diff --git a/Source/WebSocket/SSLSecurity.swift b/Source/SSLSecurity.swift similarity index 100% rename from Source/WebSocket/SSLSecurity.swift rename to Source/SSLSecurity.swift diff --git a/Source/WebSocket/WebSocket.swift b/Source/WebSocket.swift similarity index 100% rename from Source/WebSocket/WebSocket.swift rename to Source/WebSocket.swift From f15a6dc4918edd6daa4e8fd120ee6fa731f559c6 Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 20 Jul 2016 11:25:45 -0400 Subject: [PATCH 13/13] 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 1db6a38..38df018 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.4 # Or latest version +github "socketio/socket.io-client-swift" ~> 6.1.5 # 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.4' # Or latest version +pod 'Socket.IO-Client-Swift', '~> 6.1.5' # Or latest version ``` Install pods: @@ -130,7 +130,7 @@ CocoaSeeds Add this line to your `Seedfile`: ``` -github "socketio/socket.io-client-swift", "v6.1.4", :files => "Source/*.swift" # Or latest version +github "socketio/socket.io-client-swift", "v6.1.5", :files => "Source/*.swift" # Or latest version ``` Run `seed install`. diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index a694ffa..6e768c1 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.4" + s.version = "6.1.5" 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.4' } + s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v6.1.5' } s.source_files = "Source/**/*.swift" s.requires_arc = true # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files