Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access sails sockets list from other sails app/node instance #3195

Closed
dakairus opened this issue Aug 31, 2015 · 3 comments
Closed

Access sails sockets list from other sails app/node instance #3195

dakairus opened this issue Aug 31, 2015 · 3 comments

Comments

@dakairus
Copy link

Hi guys, there is a way to access to the sockets list connected to other sails app/node?

I have 2 sails app exactly the same in different ports, the difference with the rest of the guys of #3008 is that I'm not using the pubsub events of publishCreate of publishUpdate to fire the information, because some events are not related to waterline models. I'm appending a list of permissions over every socket based on the user type, so when certain event happen on the app is goes through sails.io.sockets, get the list of the sockets that contains the permission to receive the data of the event and then does a socket.emit to all that sockets of the list (one by one). Obviously in one server instance work fine, the issue is in multi instance, because even setting up redis to store the socket session, seems that I can't get the list of sockets from the other node.

@sgress454
Copy link
Member

You don't need a list of the sockets. You just need them to all join a room , and then broadcast to that room. In this case, each permission type could have its own room, then you just do (for example):

sails.sockets.broadcast('writeAccessPermission', 'someEvent', {foo: 'bar'})

See: http://sailsjs.org/documentation/reference/web-sockets/sails-sockets/sails-sockets-join and http://sailsjs.org/documentation/reference/web-sockets/sails-sockets/sails-sockets-broadcast.

@lucasmonstrox
Copy link

This doesnt work for me :'(

@sgress454
Copy link
Member

Hi @JoaoLucas89, sorry to hear that. If you're having problems with socket broadcasts, please open a new issue with a description (including steps to reproduce) and we'll take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants