Sunday, 2 April 2017

Node.js BinaryServer: Send a message to the client on stream end?

I'm using a node.js BinaryServer for streaming binary data and I want a callback event from the server, after the client calls for the .Stream.end() function.

I can't seem to understand - How can I send a message or some kind of notification when the node.js server actually closes the stream connection ?

Node JS:

server.on('connection', function(client) {

    client.on('stream', function (stream, meta) {

        stream.on('end', function () {
            fileWriter.end();
            // <--- I want to send an event to the client here
        });
    });

});

client JS:

client = new BinaryClient(nodeURL);
window.Stream = client.createStream({ metaData });
....
window.Stream.end();
//  <--- I want to recieve the callback message



via Koby Douek

No comments:

Post a Comment