Allow to unsubscribe from ws topic

This commit is contained in:
Stefan Aebischer
2019-09-16 14:35:39 +02:00
parent b6d2803a49
commit 5caa65fedf
2 changed files with 15 additions and 0 deletions

View File

@@ -50,6 +50,17 @@ module.exports = class WebsocketClient extends EventEmitter {
this.ws.send(msgStr);
}
unsubscribe(topics) {
if(!Array.isArray(topics)) topics = [topics];
const msgStr = JSON.stringify({
op: 'unsubscribe',
'args': topics
});
this.ws.send(msgStr);
}
close() {
this.logger.info('Closing connection', {category: 'bybit-ws'});
this.readyState = READY_STATE_CLOSING;