Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logic on disconnect sails.js socket.io

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.

like image 804
RMK147 Avatar asked Feb 13 '23 22:02

RMK147


1 Answers

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.

like image 149
sgress454 Avatar answered Feb 16 '23 12:02

sgress454