i got this code example from npm that im using for one of my projects :
const WebSocket = require('ws');
const ws = new WebSocket('ws://www.host.com/path');
ws.on('open', function open() {
ws.send('something');
});
ws.on('message', function incoming(data) {
console.log(data);
});
my issue: after socket is open im sending command message with ws.send('{command:123}') what im expecting is to get the message direct for this command and then i want to send another command and get the message from that new command but separately .
at the moment when im sending command and there is more then one it display only one message but with both of the command responses. so what im trying to accomplish is:
send command receive message do something with that message send another command do something with the new message
i hope that i explained well. thanks