我正在尝试将一个简单的 iOS 应用程序连接到sails.js API。iOS 应用程序是用 swift 编写的。帆的版本是 0.11
对于网络套接字管理,我使用https://github.com/socketio/socket.io-client-swift
class Communicate: UIViewController {
let socket = SocketIOClient(socketURL: "localhost:2000")
override func viewDidLoad() {
super.viewDidLoad()
self.addHandlers()
self.socket.connect()
}
func addHandlers() {
socket.on("connect") {data, ack in
print("socket connected !") // This is working
self.socket.emit("get", ["url": "/device"]) // I get the sails error
}
}
}
在sails.js 控制台上,我收到以下错误:
verbose: Receiving incoming message from Socket.io: { url: '/device?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=iOS&__sails_io_sdk_language=fr' }
error: Error (SAILS:HOOK:SOCKETS:PARSE_VIRTUAL_REQ):: Failed to parse incoming socket.io request.
details: 'Sails v0.11.x is not compatible with the socket.io/sails.io.js client SDK version you are using (0.9.0). Please see the v0.11 migration guide on http://sailsjs.org for more information.' }
模仿sails.io的行为我可能做错了,但我不知道如何实现。
预先感谢您的帮助。