Sails.js socket broadcast from shell script

82 Views Asked by At

I have a Sails app and several Sails Shell scripts run by cron or other external triggers (mostly me typing in the shell). I would like to implement notifications in the browser via builtin Sails socket client, which works but only when sails.sockets.broadcast() is called from a Sails Controller, that is, I was able to run the example from the docs.

I can't succeed to broadcast a message from a shell script or even from sails console --dontLift, it seems that the registered clients are only on the socket that is running on the server and the shell/console instantiates another socket... makes sense but isn't possible to get those clients? Is there any solution to broadcast a message from a Sails shell script to registered browser clients?

Furthermore, can I use Sails socket in a service worker to create push notifications? I understand that socket.io is different from Push, but is somehow feasible?

update

Thanks to @nahanil for pointing to redis, I found this article in the docs Realtime communication in a multi-server (aka "clustered") environment

Thanks! Luca

0

There are 0 best solutions below