BinaryJS 服务器响应

BinaryJS Server Response

给出以下示例:

binaryServer = BinaryServer({port: 9001});

binaryServer.on('connection', function(client) {
  console.log("new connection");


  client.on('stream', function(stream, meta) {
    console.log('new stream');
    strean.on('data', function('data'){
    //(code to store audio in buffers)});

    stream.on('end', function() {
      //end of stream
      //(routine that calls an addon and convert speech to text)
      //****Immediate response to client******
    });
  });
});

现在,我的 objective 是在响应生成后立即发送响应(给客户端)。我正在尝试使用 BinaryJS 执行此操作,但我不明白如何操作。

服务器端:

binaryServer = BinaryServer({port: 9001});

binaryServer.on('connection', function(client) {
  console.log("new connection");


  client.on('stream', function(stream, meta) {
    console.log('new stream');
    strean.on('data', function('data'){
    //(code to store audio in buffers)});

    stream.on('end', function() {
      //end of stream
      //(routine that calls an addon and convert speech to text)
      //****Immediate response to client******
      stream.write(some_variable);<---just do this
    });
  });
});

客户端:

client.on('open', function() {

    Stream = client.createStream("some meta information);
    //(some rotines)
    Stream.on('data', function(data){ ///-->recebe resposta do stream.write()
          console.log("RESULTADO: "+data);
    });
}

);