I'm having trouble using RabbitMQ with my Sails app. I'm unsure of where to place the subscriber code. What I'm trying to do is build a notifications system so that when an administrator approves a user's data request, the user's dashboard will pop a notification similar to how Facebook pops a notification. The problem is, putting the subscriber code in my dashboard controller's display route seems to never grab a published message.
Any advice would be greatly appreciated. Currently using rabbit.js package to connect to RabbitMQ.
<script>
tag that includes the Sails socket client,or in a bootstrapping script like jQuery's$(function(){})
. – RonironicaRequestController
, under thegrant
action, I publish an update when it's executed. In myDashboardController
, under mydisplay
action, I make a call toRequest.find(req.session.user.id, function(err, requests)
and I subscribe usingUser.subscribe(req.socket, requests, ['update']);
. Is this the correct way to place publish/subs? On the view that DashboardController.display renders, do I just need to use io.socket.on("request", function()...) to listen for the publishes? – LysinDashboardController
, you would subscribe usingRequest.subscribe(req, requests, ['update'])
, assuming you only want to hear about updates (and not deletes). In yourRequestController
, publish the update using.publishUpdate
. Then in your view,io.socket.on("request", function()...)
is correct. – Ronironica