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

Method socketHeartbeat

src/node-binance-api.ts:1345–1358  ·  view source on GitHub ↗

* Reworked Tuitio's heartbeat code into a shared single interval tick * @return {undefined}

()

Source from the content-addressed store, hash-verified

1343 * @return {undefined}
1344 */
1345 socketHeartbeat() {
1346 /* Sockets removed from `subscriptions` during a manual terminate()
1347 will no longer be at risk of having functions called on them */
1348 for (const endpointId in this.subscriptions) {
1349 const ws = this.subscriptions[endpointId];
1350 if (ws.isAlive) {
1351 ws.isAlive = false;
1352 if (ws.readyState === WebSocket.OPEN) ws.ping(this.noop);
1353 } else {
1354 if (this.Options.verbose) this.Options.log('Terminating inactive/broken WebSocket: ' + ws.endpoint);
1355 if (ws.readyState === WebSocket.OPEN) ws.terminate();
1356 }
1357 }
1358 }
1359
1360 /**
1361 * 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