Websocket Binary Data Messages (ArrayBuffer)

As I understand it, the ArrayBufferlength is set only by the constructor and cannot be changed dynamically. So I'm curious if it is possible to use binary messages with websockets to send arraybuffer a specific part, rather than the entire buffer?

+5
source share
2 answers

You can use .slicefor snippet ArrayBuffer: http://jsfiddle.net/rtaB4/21/ .

var inputBuffer = new Uint8Array([0, 1, 2, 3, 4]).buffer;
var outputBuffer = inputBuffer.slice(1, 3);

console.log(outputBuffer.byteLength);       // 2
console.log(new Uint8Array(outputBuffer));  // [1, 2]
+2
source

All Articles