我在 swift 中有以下代码用于 web-socket 通信,但是当我构建代码时出现错误。
代码:
import Foundation
import Starscream
class StarscreamWebSocket: WebSocketProvider {
var delegate: WebSocketProviderDelegate?
private let socket: WebSocket
init(url: URL) {
self.socket = WebSocket(url: url)
self.socket.delegate = self
}
func connect() {
self.socket.connect()
}
func send(data: Data) {
self.socket.write(data: data)
}
}
错误:
Cannot invoke initializer for type 'WebSocket' with an argument list of type '(url: URL)'
可能是什么问题呢。