Logic on disconnect sails.js socket.io

javascript, node.js, sails.js, socket.io

Solution

Starting with Sails v0.9.8, your `config/sockets.js` file will have both `onConnect` and `onDisconnect` methods that give you access both to the connecting/disconnecting socket and the session.

Problem

I am using sails.js with the raw API of socket.io. Now when a user disconnects, I want to inform everyone else. Normally I would do something like: ``` socket.on('disconnect', function () { //disconnect logic }); ``` But I am not sure how I would accomplish this inside of a sails.js controller. Any help would be appreciated.

Original source