1

I want so stream a lot of ArrayBuffers.

  • Sending Strings from the client to the server and back is no problem!

  • Sending ArrayBuffer to the Server is no Problem

Sending an ArrayBuffer from server to client is not working. I get an empty ArrayBuffer on the client => ArrayBuffer{}

Server:

var server = BinaryServer({port: 9000});
server.on('connection', function(client){
       client.on('stream', function(stream, meta){
       console.log(meta);
            stream.on('data', function(data){
                //console.log(data);
                stream.write(data);
            });
      });  
});

the console.log(data) shows me the filled array, so this works.

Client:

var wsStream = null;
var client = BinaryClient('ws://localhost:9000');
client.on('open', function(){
    wsStream = client.createStream("audio");

    wsStream.on('data', function(data){
          console.log(data);
    });
});

this logs: ArrayBuffer {}

so no data :(

I send the data with: wsStream.write(arrayBuffer);

If i send some array wsStream.write([0,2]); or some string wsStream.write("Hello"); I have no problem and get all my data back.

why is this happening ? thanks :)

2
  • 1
    Found a the solution by setting client.binaryType = "arraybuffer"; Commented May 31, 2014 at 15:39
  • 1
    Cool - reply to yourself and mark as answer! Commented Jun 24, 2014 at 10:17

1 Answer 1

2

Problem solved by setting binaryType to arraybuffer.

var myWebSocket = new WebSocket("ws://127.0.0.1");
myWebSocket.binaryType = "arraybuffer";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.