[英]How can i get the dataType when Array is castet into an ArrayBuffer?
I have an Array: 我有一个数组:
var dataArray = new Uint16Array(256);
then my array goes over nodeJs to an other pc. 然后我的阵列通过nodeJs转到另一台PC。 (nodejs binaryType = "arraybuffer")
(nodejs binaryType =“ arraybuffer”)
How do I know on the other client that i have to cast to Uint16Array and not Uint8Array? 我如何在另一个客户端上知道必须转换为Uint16Array而不是Uint8Array?
Note: the bit depth and array length is a dynamic value and can change while programm is running. 注意:位深度和数组长度是一个动态值,可以在程序运行时更改。
Thanks :) 谢谢 :)
When transferring data as ArrayBuffer
its just binary buffer data, you need to know with what view you want to access the data with. 当将数据作为
ArrayBuffer
的二进制缓冲区数据传输时,您需要知道要使用哪个视图访问数据。 TypedArrays
are just a view on a binary ArrayBuffer
. TypedArrays
只是二进制ArrayBuffer
上的视图。
There are several ways to handle this: 有几种方法可以解决此问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.