问题
I am currently stuck at sending a Float32Array via socket.io to another socket.
There is no real code to show, since I am only using socket.emit
and socket.on
.
On the other end of the socket the Float32Array remains as a Object. Here are to pictures from the Float32Array before emiting and the remains after emiting.
Before:
Remains:
If it is not possible to send the Float32Array to another socket, would it be possible to send a Blob to another socket?
Both sockets are Chrome clients. socket.emit
emits to the server and the server emits to every client.
回答1:
Sending in the client:
var array = new Float32Array(...);
socket.emit('data', array.buffer);
Receiving in the client:
socket.on('data', function(data) {
var array = new Float32Array(data);
...
});
I don't think you need to do anything special in the server, just pass along the data that you receive from the first client to the second client.
来源:https://stackoverflow.com/questions/31815262/sending-a-float32array-via-socket-io