How to use the to function from socket.io

Find comprehensive JavaScript socket.io.to code examples handpicked from public code repositorys.

53
54
55
56
57
58
59
60
61
    io.emit('getUser', users);

    const us = users.filter(u => u.userId !== userId);
    const con = 'new_user_add';
    for (var i = 0; i < us.length; i++) {
        socket.to(us[i].socketId).emit('new_user_add', con)
    }
})
socket.on('sendMessage', (data) => {
fork icon0
star icon0
watch icon1

+ 29 other calls in file