首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在节点服务器中使用sails.io.js版本0.11.3

如何在节点服务器中使用sails.io.js版本0.11.3
EN

Stack Overflow用户
提问于 2016-05-10 05:13:36
回答 1查看 535关注 0票数 0

我想在基于水手的项目中创建一个聊天应用程序,如何在服务器上配置套接字和相关设置?我从这个存储库中获得了一个示例项目,但它使用的是sails v0.10,我需要使用sails v0.11.3,但是v0.11.3在Nodejs脚本中使用套接字时有很多更改,例如,我们不能使用onConnect,因为它是不推荐使用的。

我试过这个例子,但没有使用SEALV0.11.3 https://github.com/sgress454/sailsChat

这是我已经完成的代码,但是我不知道我应该把它放在哪里,当我把它放在sockets.js文件中时,它不能工作。

代码语言:javascript
复制
// Set some options:
// (you have to specify the host and port of the Sails backend when using this library from Node.js)
io.sails.url = 'http://localhost:9002';
// ...
    io.socket.on('connect', function socketConnected() {
        console.log('connect..');
    });
// Send a GET request to `http://localhost:1337/hello`:
io.socket.get('/hello', function serverResponded (body, JWR) {
  // body === JWR.body
  console.log('Sails responded with: ', body);
  console.log('with headers: ', JWR.headers);
  console.log('and with status code: ', JWR.statusCode);

  // When you are finished with `io.socket`, or any other sockets you connect manually,
  // you should make sure and disconnect them, e.g.:
  io.socket.disconnect();

  // (note that there is no callback argument to the `.disconnect` method)
});

请给我带路。

EN

回答 1

Stack Overflow用户

发布于 2016-05-10 14:14:21

在此链接中使用主存储库后,问题已得到解决。

https://github.com/balderdashy/sailsChat

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37129766

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档