I create a protocol with this definition.
public protocol URLSessionWebSocketTaskProtocol {
func send(_ message: URLSessionWebSocketTask.Message, completionHandler: @escaping (Error?) -> Void)
func receive(completionHandler: @escaping (Result<URLSessionWebSocketTask.Message, Error>) -> Void)
func sendPing(pongReceiveHandler: @escaping (Error?) -> Void)
func cancel(with closeCode: URLSessionWebSocketTask.CloseCode, reason: Data?)
func resume()
}
and add a conformance like this to URLWebSocketTask
extension URLSessionWebSocketTask: URLSessionWebSocketTaskProtocol {}
then I realize that I need a delegate in the Protocol.
and modified the protocol with this new property .
var delegate: URLSessionTaskDelegate? { get set}
im have some troubles with URLSessionWebSocketTask
confirming to URLSessionWebSocketTaskProtocol
.
Protocol 'URLSessionWebSocketTaskProtocol' requires 'delegate' to be available in iOS 13.0.0 and newer
the minimum target version is iOS 13 but also adding the @available(iOS 13.0, *)
to protocol definition and to extension does not solve the problem.