Merge pull request #1420 from ranker-dev/feature/custom-engine-option
Add option to allow the use of URLSessionWebSocketTask in WebSocket client.
This commit is contained in:
commit
61a7f2e936
@ -108,6 +108,9 @@ public enum SocketIOClientOption : ClientOption {
|
|||||||
/// Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs.
|
/// Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs.
|
||||||
case sessionDelegate(URLSessionDelegate)
|
case sessionDelegate(URLSessionDelegate)
|
||||||
|
|
||||||
|
/// If passed `false`, the WebSocket stream will be configured with the useCustomEngine `false`.
|
||||||
|
case useCustomEngine(Bool)
|
||||||
|
|
||||||
/// The version of socket.io being used. This should match the server version. Default is 3.
|
/// The version of socket.io being used. This should match the server version. Default is 3.
|
||||||
case version(SocketIOVersion)
|
case version(SocketIOVersion)
|
||||||
|
|
||||||
@ -160,6 +163,8 @@ public enum SocketIOClientOption : ClientOption {
|
|||||||
description = "sessionDelegate"
|
description = "sessionDelegate"
|
||||||
case .enableSOCKSProxy:
|
case .enableSOCKSProxy:
|
||||||
description = "enableSOCKSProxy"
|
description = "enableSOCKSProxy"
|
||||||
|
case .useCustomEngine:
|
||||||
|
description = "customEngine"
|
||||||
case .version:
|
case .version:
|
||||||
description = "version"
|
description = "version"
|
||||||
}
|
}
|
||||||
@ -213,6 +218,8 @@ public enum SocketIOClientOption : ClientOption {
|
|||||||
value = delegate
|
value = delegate
|
||||||
case let .enableSOCKSProxy(enable):
|
case let .enableSOCKSProxy(enable):
|
||||||
value = enable
|
value = enable
|
||||||
|
case let .useCustomEngine(enable):
|
||||||
|
value = enable
|
||||||
case let.version(versionNum):
|
case let.version(versionNum):
|
||||||
value = versionNum
|
value = versionNum
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,6 +111,9 @@ open class SocketEngine:
|
|||||||
/// The url for WebSockets.
|
/// The url for WebSockets.
|
||||||
public private(set) var urlWebSocket = URL(string: "http://localhost/")!
|
public private(set) var urlWebSocket = URL(string: "http://localhost/")!
|
||||||
|
|
||||||
|
/// When `false`, the WebSocket `stream` will be configured with the useCustomEngine `false`.
|
||||||
|
public private(set) var useCustomEngine = true
|
||||||
|
|
||||||
/// The version of engine.io being used. Default is three.
|
/// The version of engine.io being used. Default is three.
|
||||||
public private(set) var version: SocketIOVersion = .three
|
public private(set) var version: SocketIOVersion = .three
|
||||||
|
|
||||||
@ -307,7 +310,7 @@ open class SocketEngine:
|
|||||||
includingCookies: session?.configuration.httpCookieStorage?.cookies(for: urlPollingWithSid)
|
includingCookies: session?.configuration.httpCookieStorage?.cookies(for: urlPollingWithSid)
|
||||||
)
|
)
|
||||||
|
|
||||||
ws = WebSocket(request: req, certPinner: certPinner, compressionHandler: compress ? WSCompression() : nil)
|
ws = WebSocket(request: req, certPinner: certPinner, compressionHandler: compress ? WSCompression() : nil, useCustomEngine: useCustomEngine)
|
||||||
ws?.callbackQueue = engineQueue
|
ws?.callbackQueue = engineQueue
|
||||||
ws?.delegate = self
|
ws?.delegate = self
|
||||||
|
|
||||||
@ -624,6 +627,8 @@ open class SocketEngine:
|
|||||||
self.compress = true
|
self.compress = true
|
||||||
case .enableSOCKSProxy:
|
case .enableSOCKSProxy:
|
||||||
self.enableSOCKSProxy = true
|
self.enableSOCKSProxy = true
|
||||||
|
case let .useCustomEngine(enable):
|
||||||
|
self.useCustomEngine = enable
|
||||||
case let .version(num):
|
case let .version(num):
|
||||||
version = num
|
version = num
|
||||||
default:
|
default:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user