Sails 控制器为 ajax 请求返回正确的响应,但是当通过 io.socket 调用时它不起作用。
套接字请求:
io.socket.request({ method: 'get', url: '/example-service/', params: {}, headers:{}}, function(body, JWR){ console.log(JWR); })
例外:
Error: Cannot write to response more than once\n at onlyAllowOneResponse
node_modules/sails/lib/router/res.js:375:11
at MockServerResponse.send_shim [as send]
node_modules/sails/lib/router/res.js:192:7)
浏览器上的套接字响应:
JWR {body: "Not implemented in core yet", headers: Object, statusCode: 501, error: "Not implemented in core yet"}
根据sailsjs 文档请求/响应将自动处理websockets。
我在这里错过了什么吗?对于套接字请求,我是否需要以不同的方式发送响应?