I've been playing about with Node.js and Websockets recently. I'm getting there with it, however there's an odd issue regarding JSON.stringify (client side).
I like to use JSON.stringify to determine which object properties the server is returning..
So for example, I have the following snippet of code:
ws.onmessage = function(param1) {
alert(JSON.stringify(param1));
}
This displays an alert box of {"isTrusted" : true}
Because of this output, I thought my server wasn't sending a message back to the client. Out of curiousity, I decided to just modify the alert function to
alert(param1.data);
The expected message was there! So my question is why didn't JSON.stringify include a data object when it was evidently there?