MCPcopy Create free account
hub / github.com/ccxt/node-binance-api / socketHeartbeat

Function socketHeartbeat

deprecated/node-binance-api.js:630–643  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

628 * @return {undefined}
629 */
630 const socketHeartbeat = () => {
631 /* Sockets removed from `subscriptions` during a manual terminate()
632 will no longer be at risk of having functions called on them */
633 for (let endpointId in Binance.subscriptions) {
634 const ws = Binance.subscriptions[endpointId];
635 if (ws.isAlive) {
636 ws.isAlive = false;
637 if (ws.readyState === WebSocket.OPEN) ws.ping(noop);
638 } else {
639 if (Binance.options.verbose) Binance.options.log('Terminating inactive/broken WebSocket: ' + ws.endpoint);
640 if (ws.readyState === WebSocket.OPEN) ws.terminate();
641 }
642 }
643 };
644
645 /**
646 * Called when socket is opened, subscriptions are registered for later reference

Callers

nothing calls this directly

Calls 3

pingMethod · 0.80
logMethod · 0.80
terminateMethod · 0.65

Tested by

no test coverage detected