I am trying to send data of type ArrayBuffer in json to my server using socket.io like this:
socket.emit('record', {
name: myUsername + '.wav',
data: data //arraybuffer
});
On server side, when i receive 'record' event in socket, I get the data from JSON and save it in name file like this:
socket.on('record', function(message){
var fileWriter = new wav.FileWriter(message.name, {
channels: 1,
sampleRate: 48000,
bitDepth: 16
});
message.data.pipe(fileWriter);
});
I am using require('wav') & require('stream') package from npm. The problem is that my server crashes on message.data.pipe(fileWriter);
with this error:
TypeError: message.data.pipe is not a function
What am I doing wrong? Can't i send ArrayBuffer like this in socket.io?
.pipe()
chained to the stream instance, not theArrayBuffer
message.data
– guest271314