diff --git a/README.md b/README.md index 69ed99c..23642f2 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Carthage ----------------- Add this line to your `Cartfile`: ``` -github "socketio/socket.io-client-swift" ~> 4.0.3 # Or latest version +github "socketio/socket.io-client-swift" ~> 4.0.4 # Or latest version ``` Run `carthage update --platform ios,macosx`. @@ -83,7 +83,7 @@ source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' use_frameworks! -pod 'Socket.IO-Client-Swift', '~> 4.0.3' # Or latest version +pod 'Socket.IO-Client-Swift', '~> 4.0.4' # Or latest version ``` Install pods: @@ -111,7 +111,7 @@ CocoaSeeds Add this line to your `Seedfile`: ``` -github "socketio/socket.io-client-swift", "v4.0.3", :files => "SocketIOClientSwift/*.swift" # Or latest version +github "socketio/socket.io-client-swift", "v4.0.4", :files => "SocketIOClientSwift/*.swift" # Or latest version ``` Run `seed install`. @@ -143,6 +143,7 @@ case SessionDelegate(NSURLSessionDelegate) // Sets an NSURLSessionDelegate for t case Path(String) // If the server uses a custom path. ex: `"/swift"`. Default is `""` case ExtraHeaders([String: String]) // Adds custom headers to the initial request. Default is nil. case HandleQueue(dispatch_queue_t) // The dispatch queue that handlers are run on. Default is the main queue. +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 ------- diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index 60813b6..4176a4e 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 = "4.0.3" + s.version = "4.0.4" 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 => 'v4.0.3' } + s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v4.0.4' } s.source_files = "SocketIOClientSwift/**/*.swift" s.requires_arc = true # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files diff --git a/SocketIOClientSwift/SocketEngine.swift b/SocketIOClientSwift/SocketEngine.swift index 8cd2980..fe74f27 100644 --- a/SocketIOClientSwift/SocketEngine.swift +++ b/SocketIOClientSwift/SocketEngine.swift @@ -63,6 +63,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate { private var probing = false private var probeWait = ProbeWaitQueue() private var session: NSURLSession! + private var voipEnabled = false private var waitingForPoll = false private var waitingForPost = false private var websocketConnected = false @@ -71,8 +72,9 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate { private(set) var polling = true private(set) var websocket = false - init(client: SocketEngineClient, options: Set) { + public init(client: SocketEngineClient, options: Set) { self.client = client + for option in options { switch option { case .SessionDelegate(let delegate): @@ -89,6 +91,8 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate { socketPath = path case .ExtraHeaders(let headers): extraHeaders = headers + case .VoipEnabled(let enable): + voipEnabled = enable default: continue } @@ -217,6 +221,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate { } ws?.queue = handleQueue + ws?.voipEnabled = voipEnabled ws?.delegate = self if connect { diff --git a/SocketIOClientSwift/SocketIOClientOption.swift b/SocketIOClientSwift/SocketIOClientOption.swift index 11a5b01..7909d96 100644 --- a/SocketIOClientSwift/SocketIOClientOption.swift +++ b/SocketIOClientSwift/SocketIOClientOption.swift @@ -39,6 +39,7 @@ public enum SocketIOClientOption: CustomStringConvertible, Hashable { case Path(String) case ExtraHeaders([String: String]) case HandleQueue(dispatch_queue_t) + case VoipEnabled(Bool) public var description: String { if let label = Mirror(reflecting: self).children.first?.label { @@ -82,6 +83,8 @@ public enum SocketIOClientOption: CustomStringConvertible, Hashable { return .ExtraHeaders(value as! [String: String]) case "handleQueue" where value is dispatch_queue_t: return .HandleQueue(value as! dispatch_queue_t) + case "voipEnabled" where value is Bool: + return .VoipEnabled(value as! Bool) default: return nil }