Skip to content

Commit bba966a

Browse files
committed
add option for setting WebSocket.voipEnabled
1 parent 0579e7e commit bba966a

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Carthage
6969
-----------------
7070
Add this line to your `Cartfile`:
7171
```
72-
github "socketio/socket.io-client-swift" ~> 4.0.3 # Or latest version
72+
github "socketio/socket.io-client-swift" ~> 4.0.4 # Or latest version
7373
```
7474
7575
Run `carthage update --platform ios,macosx`.
@@ -83,7 +83,7 @@ source 'https://github.com/CocoaPods/Specs.git'
8383
platform :ios, '8.0'
8484
use_frameworks!
8585
86-
pod 'Socket.IO-Client-Swift', '~> 4.0.3' # Or latest version
86+
pod 'Socket.IO-Client-Swift', '~> 4.0.4' # Or latest version
8787
```
8888

8989
Install pods:
@@ -111,7 +111,7 @@ CocoaSeeds
111111
Add this line to your `Seedfile`:
112112

113113
```
114-
github "socketio/socket.io-client-swift", "v4.0.3", :files => "SocketIOClientSwift/*.swift" # Or latest version
114+
github "socketio/socket.io-client-swift", "v4.0.4", :files => "SocketIOClientSwift/*.swift" # Or latest version
115115
```
116116

117117
Run `seed install`.
@@ -143,6 +143,7 @@ case SessionDelegate(NSURLSessionDelegate) // Sets an NSURLSessionDelegate for t
143143
case Path(String) // If the server uses a custom path. ex: `"/swift"`. Default is `""`
144144
case ExtraHeaders([String: String]) // Adds custom headers to the initial request. Default is nil.
145145
case HandleQueue(dispatch_queue_t) // The dispatch queue that handlers are run on. Default is the main queue.
146+
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
146147
```
147148
Methods
148149
-------

Socket.IO-Client-Swift.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Socket.IO-Client-Swift"
3-
s.version = "4.0.3"
3+
s.version = "4.0.4"
44
s.summary = "Socket.IO-client for iOS and OS X"
55
s.description = <<-DESC
66
Socket.IO-client for iOS and OS X.
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
1212
s.author = { "Erik" => "[email protected]" }
1313
s.ios.deployment_target = '8.0'
1414
s.osx.deployment_target = '10.10'
15-
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v4.0.3' }
15+
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v4.0.4' }
1616
s.source_files = "SocketIOClientSwift/**/*.swift"
1717
s.requires_arc = true
1818
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files

SocketIOClientSwift/SocketEngine.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
6363
private var probing = false
6464
private var probeWait = ProbeWaitQueue()
6565
private var session: NSURLSession!
66+
private var voipEnabled = false
6667
private var waitingForPoll = false
6768
private var waitingForPost = false
6869
private var websocketConnected = false
@@ -71,8 +72,9 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
7172
private(set) var polling = true
7273
private(set) var websocket = false
7374

74-
init(client: SocketEngineClient, options: Set<SocketIOClientOption>) {
75+
public init(client: SocketEngineClient, options: Set<SocketIOClientOption>) {
7576
self.client = client
77+
7678
for option in options {
7779
switch option {
7880
case .SessionDelegate(let delegate):
@@ -89,6 +91,8 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
8991
socketPath = path
9092
case .ExtraHeaders(let headers):
9193
extraHeaders = headers
94+
case .VoipEnabled(let enable):
95+
voipEnabled = enable
9296
default:
9397
continue
9498
}
@@ -217,6 +221,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
217221
}
218222

219223
ws?.queue = handleQueue
224+
ws?.voipEnabled = voipEnabled
220225
ws?.delegate = self
221226

222227
if connect {

SocketIOClientSwift/SocketIOClientOption.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public enum SocketIOClientOption: CustomStringConvertible, Hashable {
3939
case Path(String)
4040
case ExtraHeaders([String: String])
4141
case HandleQueue(dispatch_queue_t)
42+
case VoipEnabled(Bool)
4243

4344
public var description: String {
4445
if let label = Mirror(reflecting: self).children.first?.label {
@@ -82,6 +83,8 @@ public enum SocketIOClientOption: CustomStringConvertible, Hashable {
8283
return .ExtraHeaders(value as! [String: String])
8384
case "handleQueue" where value is dispatch_queue_t:
8485
return .HandleQueue(value as! dispatch_queue_t)
86+
case "voipEnabled" where value is Bool:
87+
return .VoipEnabled(value as! Bool)
8588
default:
8689
return nil
8790
}

0 commit comments

Comments
 (0)