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.
 | 
			
		||||
    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.
 | 
			
		||||
    case version(SocketIOVersion)
 | 
			
		||||
 | 
			
		||||
@ -160,6 +163,8 @@ public enum SocketIOClientOption : ClientOption {
 | 
			
		||||
            description = "sessionDelegate"
 | 
			
		||||
        case .enableSOCKSProxy:
 | 
			
		||||
            description = "enableSOCKSProxy"
 | 
			
		||||
        case .useCustomEngine:
 | 
			
		||||
            description = "customEngine"
 | 
			
		||||
        case .version:
 | 
			
		||||
            description = "version"
 | 
			
		||||
        }
 | 
			
		||||
@ -213,6 +218,8 @@ public enum SocketIOClientOption : ClientOption {
 | 
			
		||||
            value = delegate
 | 
			
		||||
        case let .enableSOCKSProxy(enable):
 | 
			
		||||
            value = enable
 | 
			
		||||
        case let .useCustomEngine(enable):
 | 
			
		||||
            value = enable
 | 
			
		||||
        case let.version(versionNum):
 | 
			
		||||
            value = versionNum
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -111,6 +111,9 @@ open class SocketEngine:
 | 
			
		||||
    /// The url for WebSockets.
 | 
			
		||||
    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.
 | 
			
		||||
    public private(set) var version: SocketIOVersion = .three
 | 
			
		||||
 | 
			
		||||
@ -307,7 +310,7 @@ open class SocketEngine:
 | 
			
		||||
            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?.delegate = self
 | 
			
		||||
 | 
			
		||||
@ -624,6 +627,8 @@ open class SocketEngine:
 | 
			
		||||
                self.compress = true
 | 
			
		||||
            case .enableSOCKSProxy:
 | 
			
		||||
                self.enableSOCKSProxy = true
 | 
			
		||||
            case let .useCustomEngine(enable):
 | 
			
		||||
                self.useCustomEngine = enable
 | 
			
		||||
            case let .version(num):
 | 
			
		||||
                version = num
 | 
			
		||||
            default:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user