How to use sails.io.js version 0.11.3 in node server

I would like to create a chat application in my project based on sailjs, How and where can I configure the socket and related settings on the server? I got a sample project from this repository, but it uses v0.10 sails, and I need to use v0.11.3 sails, but v0.11.3 has a lot of changes when using a socket in a Nodejs script, for example, we cannot use onConnect , as it is deprecated .

I tried this example but did not work with sail v0.11.3 https://github.com/sgress454/sailsChat

This is the code I made, but I don’t know where I should put it, it doesn’t work when I put this in the sockets.js file in the configuration directory

// 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, eg: io.socket.disconnect(); // (note that there is no callback argument to the `.disconnect` method) }); 

Please help me with this.

0
source share
1 answer

The problem was resolved after using the main repository in this link

https://github.com/balderdashy/sailsChat

0
source share

All Articles