socket io broadcast to room code example
Example 1: socket io broadcast to room
socket.to(room).broadcast.emit('hi')
Example 2: socket io broadcast to room
socket.to(room).broadcast.emit('hi')
Example 3: socket emit to specific room using nodejs socket.io
io.on('connection', function(socket){ socket.to('some room').emit('some event');});
Example 4: socket emit to specific room using nodejs socket.io
io.on('connection', socket => { socket.on('disconnecting', () => { const rooms = Object.keys(socket.rooms);