socket io send message to specific socket code example
Example 1: How to send a message to a particular client with socket.io
io.sockets.in('[email protected]').emit('new_msg', {msg: 'hello'});
Example 2: socket io send command over socket
const socket = new WebSocket('ws://localhost:3000');socket.onopen(() => { socket.send('Hello!');});socket.onmessage(data => { console.log(data);});