RE: dsteem playground

You are viewing a single comment's thread from:

dsteem playground

in steemdev •  7 years ago  (edited)

I am relaying the results stream through socket.io-stream. When the socket.io client disconnects, what is the correct way to .close() .disconnect() .destroy() the dsteem client connection? The dsteem stream functions don't appear to have any methods to disconnect or hang-up.

io.on('connection', function(socket) {

    ss(socket).on('ready', function(){
        var client = new dsteem.Client('https://api.steemit.com');
        var opsStream = client.blockchain.getOperationsStream();
        opsStream.pipe(es.map(function(block, callback) {
            ss(socket).emit('sending', block);
            callback(null, util.inspect(block, {colors: true, depth: null}) + '\n')
        }))//.pipe(process.stdout);
    });

    socket.on('disconnect', function(){
        /* 
          how to disconnect the getOperationsStream() ?? 
       */
        console.log('User Disconnected');
    });
});
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Yeah that is a implementation limitation, feel free to open an issue about it. However in your case you don't want to create a new stream for every client that connects, that would be very inefficient. Instead create a proxy stream that you pipe to your connections and unpipe when they disconnect

Also worth noting is that dsteem works in web browsers so if those are your socket clients you can just get the operation stream client side directly