diff --git a/README.md b/README.md index a956da9..f68191a 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,11 @@ bittrex.options({ console.log('Market Update for '+ data_for.MarketName, data_for); }); } + }, function(market) { + console.log('bittrex.getOrderBook now to keep in sync') + bittrex.getorderbook({ market : market, depth : 10, type : 'both' }, function( data, err ) { + console.log( data ); + }); }); }, onDisconnect: function() { @@ -213,6 +218,11 @@ bittrex.websockets.subscribe(['BTC-ETH','BTC-SC','BTC-ZEN'], function(data, clie console.log('Market Update for '+ data_for.MarketName, data_for); }); } +}, function(market) { + console.log('bittrex.getOrderBook now to keep in sync') + bittrex.getorderbook({ market : market, depth : 10, type : 'both' }, function( data, err ) { + console.log( data ); + }); }); ``` diff --git a/node.bittrex.api.js b/node.bittrex.api.js index 14bcf0b..1ebabb9 100644 --- a/node.bittrex.api.js +++ b/node.bittrex.api.js @@ -165,6 +165,7 @@ var NodeBittrexApi = function() { var websocketGlobalTickerCallback; var websocketMarkets = []; var websocketMarketsCallback; + var websocketMarketSubscribeDoneCallback; var connectws = function(callback, force) { if (wsclient && !force && callback) { @@ -256,6 +257,9 @@ var NodeBittrexApi = function() { if (result === true) { ((opts.verbose) ? console.log('Subscribed to ' + market) : ''); + if (websocketMarketSubscribeDoneCallback) { + websocketMarketSubscribeDoneCallback(market); + } } }); }); @@ -315,7 +319,8 @@ var NodeBittrexApi = function() { setMessageReceivedWs(); }, force); }, - subscribe: function(markets, callback, force) { + subscribe: function(markets, callback, doneCallback, force) { + websocketMarketSubscribeDoneCallback = doneCallback; connectws(function() { websocketMarkets = markets; websocketMarketsCallback = callback;