Answer the question
In order to leave comments, you need to log in
How to send Binary Message via Websocket?
Through which command can you send information so that the browser receives the following?
Answer the question
In order to leave comments, you need to log in
it turns out that we first convert String to Bin with this function:
function str2ab(str) {
var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
var bufView = new Uint16Array(buf);
for (var i=0, strLen=str.length; i < strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}
ws.binaryType = 'arraybuffer';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question