Hi, I'm writting a small web application, and using Socket.IO for the communication between my server (in Node.js) and the web app.
When I send JSON data from the server to the client, it works well, and I receive the data correctly in the client and I can work with it. The problem cames when I try to do the reverse way, send an emit with some JSON data. The server appears to don't receive anything. I tried to replace the serviceList[i].name by a string and it works well...
Here is the server's code. I send the JSON result with an emit, and it works well.
Now, in the Web client, I first receive the data (serviceList), but when I try to emit another event with some of that data, the log doesn't show anything (event check-service):
socket.on('DB-Info', function(serviceList){
//Other stuff..... serviceList corresponds to the result emitted by the server...
var service = {
name: serviceList[i].nombre,
url: serviceList[i].url
};
socket.emit('check-service', service);
I don't know if I'm using in the wrong way the JSON object, but I tried multiple ways and I can't solve it. Anyone can help? Thanks!
Hi, I'm writting a small web application, and using Socket.IO for the communication between my server (in Node.js) and the web app.
When I send JSON data from the server to the client, it works well, and I receive the data correctly in the client and I can work with it. The problem cames when I try to do the reverse way, send an emit with some JSON data. The server appears to don't receive anything. I tried to replace the serviceList[i].name by a string and it works well...
Here is the server's code. I send the JSON result with an emit, and it works well.
Now, in the Web client, I first receive the data (serviceList), but when I try to emit another event with some of that data, the log doesn't show anything (event check-service):
I don't know if I'm using in the wrong way the JSON object, but I tried multiple ways and I can't solve it. Anyone can help? Thanks!