私はバイナリメッセージを受け取るWebSocketを持っています。WebSocketによって受信されたJavaScriptのBLOBからバイトを読み取る
私は、次の変換機能を思い付いた...
// Convert the buffer to a byte array.
function convert(data, cb) {
// Initialize a new instance of the FileReader class.
var fileReader = new FileReader();
// Called when the read operation is successfully completed.
fileReader.onload = function() {
// Invoke the callback.
cb(new Uint8Array(this.result));
};
// Starts reading the contents of the specified blob.
fileReader.readAsArrayBuffer(data);
}
これは、作業を行いますが、パフォーマンスはひどいです。読み込みバイトを許可する良い方法はありますか?
使用しているブラウザは何ですか? – karthick
Google Chromeは私が使用しているブラウザです。 –
どのタイプが 'データ 'ですか – Esailija