I have the following server-side code that performs the function of invoking a new socket connection.
var io = require('socket.io').listen(80); io.sockets.on('connection', function (socket) { socket.broadcast.emit('user connected'); });
now I have another module that accepts a vacation request and wants to broadcast all open sockets. How can I do that?
Can I use broadcast without a socket? as
io.broadcast.emit('user connected');
Edit is more like this?
io.sockets.broadcast.to('m1').emit('user message', 'from', 'msg');
source share