1

I have multiple servers in node js so each server has a socket client to communicate with the main server. when I connect all socket-client to the main server web page then I send a message to one specific client which I select but the message is sent to all connected clients so how to communicate with specific only one client

Nikunj
  • 23
  • 5
  • so your question is just how to send a message to a specific client? – user253751 Apr 07 '22 at 13:00
  • On one page many socket-client connected so I want to send messages to specific client – Nikunj Apr 08 '22 at 06:02
  • how are you currently sending the message? – user253751 Apr 08 '22 at 09:33
  • let host = 'http://' + server.ip_address + ':' + server.port_number; socket = io(host, { transports: ['websocket'] }); var form = document.getElementById('commandForm'); var input = document.getElementById('serverCommand'); form.addEventListener('submit', function (e) { e.preventDefault(); if (input.value) { socket.emit('send command', input.value); input.value = ''; } }); socket.on('send command', function (msg, data) { let item= msg + data; }) – Nikunj Apr 08 '22 at 12:42

0 Answers0