From d02fe8894921f67be43f00bfb46965e4b0beef66 Mon Sep 17 00:00:00 2001 From: Sagiv Ofek Date: Mon, 25 Dec 2017 23:52:19 -0500 Subject: [PATCH] add unsubsribe websocket option --- README.md | 9 +++++++++ node.bittrex.api.js | 3 +++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index a956da9..bc386ac 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,15 @@ bittrex.websockets.subscribe(['BTC-ETH','BTC-SC','BTC-ZEN'], function(data, clie }); ``` +#### websockets.unsubscribe +This will close your websocket connection. Please note that by default the websocket client will +try to recoonect so don't forget to set `autoReconnect` to `false`. +```javascript +bittrexApi.options({ websockets: { autoReconnect: false } }); +/... +bittrex.websockets.unsubscribe(); +``` + #### Websocket serviceHandlers example You can override the libraries logic for the following events. Note, this will diff --git a/node.bittrex.api.js b/node.bittrex.api.js index 14bcf0b..b1123c0 100644 --- a/node.bittrex.api.js +++ b/node.bittrex.api.js @@ -321,6 +321,9 @@ var NodeBittrexApi = function() { websocketMarketsCallback = callback; setMessageReceivedWs(); }, force); + }, + unsubscribe: function() { + wsclient.end(); } }, sendCustomRequest: function(request_string, callback, credentials) {