I understand that there is no way to easily send and receive floats the same way there is for strings. However, if I setup my websocket like this:
ws = new WebSocket(address);
ws.binaryType = 'blob';
I should be able to convert the incoming bytestrings into floats. Converting floats into bytestrings and sending them on the server side is easy.
The closest thing I could find to an answer was this. However, I found that e.target.result
is undefined. I tried just using e.target
, but the compiler threw a type error that I couldn't figure out how to fix.
There are also questions like this, which convert uint arrays into floats. But if I have something like this
ws.onmessage = function(event){
//do something with event.data
}
I need to understand how to work with event.data
when it isn't just a string like it is here.