I'm a bit stuck :/ I don't know how to initialize a variable inside an anonymous function, called when the websocket receives a message from the server. Is there a way to use the received the message received outside the function? There is a way to do that:
// Very simplified code:
var x;
socket.onmessage = function (e) {
x = messageReceived;
}
console.log(x) // print the message received.
I hope somebody can help me :)