访问/处理ArrayBuffer@http客户端(websocket连接,JavaScript)
我有一个websocket连接 •节点服务器(+socket.io) •浏览器 从服务器向浏览器发送消息(来自Arduino的Udp消息) 结果:没有数据打印到浏览器 问题:我做错了什么?我还尝试了其他数据视图,但没有成功。它快把我逼疯了。请帮忙访问/处理ArrayBuffer@http客户端(websocket连接,JavaScript),javascript,arraybuffer,Javascript,Arraybuffer,我有一个websocket连接 •节点服务器(+socket.io) •浏览器 从服务器向浏览器发送消息(来自Arduino的Udp消息) 结果:没有数据打印到浏览器 问题:我做错了什么?我还尝试了其他数据视图,但没有成功。它快把我逼疯了。请帮忙 udpSocket.on("message", function (msg, rinfo) { for (i = 0; i < msg.length; i++) { co
udpSocket.on("message", function (msg, rinfo) {
for (i = 0; i < msg.length; i++) {
console.log(msg.readInt8(i));
}
console.log("");
io.sockets.emit('message', msg);
});
socket.on('message', function(message) {
document.getElementById("ko1").innerHTML = message;
})
<p> Arduino sends: </p>
<p id="ko1"> <br>
socket.on('message', function(message) {
var uint8 = new Uint8Array(message);
document.getElementById("ko1").innerHTML = uint8[0];
})