user3134962 user3134962 - 1 year ago 116
Javascript Question

Logic on disconnect sails.js

I am using sails.js with the raw API of 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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download