diff --git a/README.md b/README.md index 38df018..7549222 100644 --- a/README.md +++ b/README.md @@ -88,21 +88,21 @@ Carthage ----------------- Add this line to your `Cartfile`: ``` -github "socketio/socket.io-client-swift" ~> 6.1.5 # Or latest version +github "socketio/socket.io-client-swift" ~> 6.1.6 # Or latest version ``` Run `carthage update --platform ios,macosx`. -CocoaPods 0.36.0 or later (iOS 8+) +CocoaPods 1.0.0 or later ------------------ Create `Podfile` and add `pod 'Socket.IO-Client-Swift'`: ```ruby -source 'https://github.com/CocoaPods/Specs.git' -platform :ios, '8.0' use_frameworks! -pod 'Socket.IO-Client-Swift', '~> 6.1.5' # Or latest version +target 'YourApp' do + pod 'Socket.IO-Client-Swift', '~> 6.1.6' # Or latest version +end ``` Install pods: @@ -121,7 +121,7 @@ import SocketIOClientSwift Objective-C: ```Objective-C -#import +@import SocketIOClientSwift; ``` CocoaSeeds @@ -130,7 +130,7 @@ CocoaSeeds Add this line to your `Seedfile`: ``` -github "socketio/socket.io-client-swift", "v6.1.5", :files => "Source/*.swift" # Or latest version +github "socketio/socket.io-client-swift", "v6.1.6", :files => "Source/*.swift" # Or latest version ``` Run `seed install`. diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index 6e768c1..ae9890b 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.5" + s.version = "6.1.6" 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.5' } + s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v6.1.6' } s.source_files = "Source/**/*.swift" s.requires_arc = true # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files diff --git a/Source/SSLSecurity.swift b/Source/SSLSecurity.swift index eef4481..f319a24 100644 --- a/Source/SSLSecurity.swift +++ b/Source/SSLSecurity.swift @@ -55,7 +55,7 @@ public class SSLSecurity : NSObject { var isReady = false //is the key processing done? var certificates: [NSData]? //the certificates - var pubKeys: [SecKeyRef]? //the public keys + @nonobjc var pubKeys: [SecKeyRef]? //the public keys var usePublicKeys = false //use public keys or certificate validation? /** @@ -240,7 +240,7 @@ public class SSLSecurity : NSObject { - returns: the public keys from the certifcate chain for the trust */ - func publicKeyChainForTrust(trust: SecTrustRef) -> [SecKeyRef] { + @nonobjc func publicKeyChainForTrust(trust: SecTrustRef) -> [SecKeyRef] { let policy = SecPolicyCreateBasicX509() let keys = (0.. [SecKeyRef] in var keys = keys diff --git a/Source/SocketEngine.swift b/Source/SocketEngine.swift index a1f8ca9..96d45dd 100644 --- a/Source/SocketEngine.swift +++ b/Source/SocketEngine.swift @@ -24,7 +24,7 @@ import Foundation -public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWebsocket { +public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePollable, SocketEngineWebsocket { public let emitQueue = dispatch_queue_create("com.socketio.engineEmitQueue", DISPATCH_QUEUE_SERIAL) public let handleQueue = dispatch_queue_create("com.socketio.engineHandleQueue", DISPATCH_QUEUE_SERIAL) public let parseQueue = dispatch_queue_create("com.socketio.engineParseQueue", DISPATCH_QUEUE_SERIAL) @@ -102,6 +102,10 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe forceWebsockets = force case let .Path(path): socketPath = path + + if !socketPath.hasSuffix("/") { + socketPath += "/" + } case let .VoipEnabled(enable): voipEnabled = enable case let .Secure(secure): @@ -117,6 +121,8 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe super.init() + sessionDelegate = sessionDelegate ?? self + (urlPolling, urlWebSocket) = createURLs() } @@ -205,9 +211,7 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe } } - dispatch_async(emitQueue) { - self.doLongPoll(reqPolling) - } + doLongPoll(reqPolling) } private func createURLs() -> (NSURL, NSURL) { @@ -456,7 +460,7 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe invalidated = false session = NSURLSession(configuration: .defaultSessionConfiguration(), delegate: sessionDelegate, - delegateQueue: NSOperationQueue()) + delegateQueue: NSOperationQueue.mainQueue()) sid = "" waitingForPoll = false waitingForPost = false @@ -549,3 +553,11 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe } } } + +extension SocketEngine { + public func URLSession(session: NSURLSession, didBecomeInvalidWithError error: NSError?) { + DefaultSocketLogger.Logger.error("Engine URLSession became invalid", type: "SocketEngine") + + didError("Engine URLSession became invalid") + } +}