i have a project and I\'m using socket.io with express ,
so what i need (i tried) is broadcasting a message but from an express action. is this possible i don\'t know ho
You might want to have a look at my socket.io + Express primer. What you want is covered in detail there.
// Send to all connected sockets
io.sockets.send('Hello, World!');
// Send to all sockets in a specified room
io.sockets.in('room').send('Hello, Room!');
Where io
is the value returned by the call to socketio.listen()
. You can place that code anywhere in your application, eg in your app.get
callbacks.