add option for setting WebSocket.voipEnabled

This commit is contained in:
Erik 2015-10-21 20:51:19 -04:00
parent 0579e7ec19
commit bba966a125
4 changed files with 15 additions and 6 deletions

View File

@ -69,7 +69,7 @@ Carthage
----------------- -----------------
Add this line to your `Cartfile`: 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`. Run `carthage update --platform ios,macosx`.
@ -83,7 +83,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0' platform :ios, '8.0'
use_frameworks! 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: Install pods:
@ -111,7 +111,7 @@ CocoaSeeds
Add this line to your `Seedfile`: 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`. 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 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 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 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 Methods
------- -------

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "Socket.IO-Client-Swift" 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.summary = "Socket.IO-client for iOS and OS X"
s.description = <<-DESC s.description = <<-DESC
Socket.IO-client for iOS and OS X. 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.author = { "Erik" => "nuclear.ace@gmail.com" }
s.ios.deployment_target = '8.0' s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10' 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.source_files = "SocketIOClientSwift/**/*.swift"
s.requires_arc = true s.requires_arc = true
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files

View File

@ -63,6 +63,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
private var probing = false private var probing = false
private var probeWait = ProbeWaitQueue() private var probeWait = ProbeWaitQueue()
private var session: NSURLSession! private var session: NSURLSession!
private var voipEnabled = false
private var waitingForPoll = false private var waitingForPoll = false
private var waitingForPost = false private var waitingForPost = false
private var websocketConnected = false private var websocketConnected = false
@ -71,8 +72,9 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
private(set) var polling = true private(set) var polling = true
private(set) var websocket = false private(set) var websocket = false
init(client: SocketEngineClient, options: Set<SocketIOClientOption>) { public init(client: SocketEngineClient, options: Set<SocketIOClientOption>) {
self.client = client self.client = client
for option in options { for option in options {
switch option { switch option {
case .SessionDelegate(let delegate): case .SessionDelegate(let delegate):
@ -89,6 +91,8 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
socketPath = path socketPath = path
case .ExtraHeaders(let headers): case .ExtraHeaders(let headers):
extraHeaders = headers extraHeaders = headers
case .VoipEnabled(let enable):
voipEnabled = enable
default: default:
continue continue
} }
@ -217,6 +221,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
} }
ws?.queue = handleQueue ws?.queue = handleQueue
ws?.voipEnabled = voipEnabled
ws?.delegate = self ws?.delegate = self
if connect { if connect {

View File

@ -39,6 +39,7 @@ public enum SocketIOClientOption: CustomStringConvertible, Hashable {
case Path(String) case Path(String)
case ExtraHeaders([String: String]) case ExtraHeaders([String: String])
case HandleQueue(dispatch_queue_t) case HandleQueue(dispatch_queue_t)
case VoipEnabled(Bool)
public var description: String { public var description: String {
if let label = Mirror(reflecting: self).children.first?.label { if let label = Mirror(reflecting: self).children.first?.label {
@ -82,6 +83,8 @@ public enum SocketIOClientOption: CustomStringConvertible, Hashable {
return .ExtraHeaders(value as! [String: String]) return .ExtraHeaders(value as! [String: String])
case "handleQueue" where value is dispatch_queue_t: case "handleQueue" where value is dispatch_queue_t:
return .HandleQueue(value as! dispatch_queue_t) return .HandleQueue(value as! dispatch_queue_t)
case "voipEnabled" where value is Bool:
return .VoipEnabled(value as! Bool)
default: default:
return nil return nil
} }