I'm sending JSON via a websocket, but some of the created messages are empty.
function chVol(vol){
var send = {};
send["payload"] = {};
send["payload"]["volume"] = vol;
ws.send(JSON.stringify(send));
}
If vol has the value 0 or 1, the messages are correct and at some other values of vol, too. I'm changing vol with a slider and when I'm logging JSON.stringify(send) all messages are correct, but not when
ws.onmessage = function (e) {
data = JSON.parse(e.data);
console.log(data);
};
is called. Any ideas what is going on here?
onmessageis for incoming messages, it won't log outgoing messages you sent using.send(). Is that the confusion?