emit to specific socket id in room socket io code example

Example 1: socket io emit to socket id

io.to(socketid).emit('message', 'for your eyes only');

Example 2: socket emit to specific room using nodejs socket.io

io.on('connection', function(socket){  socket.to('some room').emit('some event');});

Example 3: socket emit to specific room using nodejs socket.io

io.on('connection', socket => {  socket.on('say to someone', (id, msg) => {    socket.to(id).emit('my message', msg);  });});

Example 4: socket emit to specific room using nodejs socket.io

io.to('room1').to('room2').to('room3').emit('some event');