I have set up socket.io (1.3.5) in my clustered express (4.11) app and have this working (in my main app.js file)
io.on('connection', function (socket) {
io.emit('message', 'ja');
});
This, console logs out in the browser and works fine. Here's what I want to do:
I want to emit a message when an action has been performed on the server side, to notify the user that there is something new to see.
I am passing the io object in to my routes module, so that I have access to it within my routes.
When I try this:
router.post('/entries.json',(req, res, next) => {
io.emit('message', 'nein')
});
I don't get any errors, it just fails silently. I feel like its something fairly fundamental that I'm just not seeing. What can I do to make this work?
You're calling the wrong method, try this: