gpt4 book ai didi

ios - 套接字无法与Starscream连接

转载 作者:行者123 更新时间:2023-11-30 13:26:56 25 4
gpt4 key购买 nike

我正在使用Starscream打开websocket。问题在于它无法在localhost上或与服务器连接。

var socket = WebSocket(url: NSURL(string: "ws://localhost:8080/")!)
self.socket.voipEnabled = true;
socket.delegate = self
socket.connect()
func websocketDidConnect(ws: WebSocket) {
print("websocket is connected")
}

func websocketDidDisconnect(ws: WebSocket, error: NSError?) {
print("websocket is disconnected: \(error?.localizedDescription)")
}

func websocketDidReceiveMessage(ws: WebSocket, text: String) {
print("Received text: \(text)")
}

func websocketDidReceiveData(ws: WebSocket, data: NSData) {
print("Received data: \(data.length)")
}

func websocketDidReceivePong(socket: WebSocket) {
print("Got pong!")
}

@IBAction func writeText(sender: UIBarButtonItem) {
socket.writeString("hello there!")
}

最佳答案

一旦添加self.socket.selfSignedSSL = true,它就开始连接。

关于ios - 套接字无法与Starscream连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37073661/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com