* Futures heartbeat code with a shared single interval tick * @return {undefined}
()
| 1713 | * @return {undefined} |
| 1714 | */ |
| 1715 | futuresSocketHeartbeat() { |
| 1716 | /* Sockets removed from subscriptions during a manual terminate() |
| 1717 | will no longer be at risk of having functions called on them */ |
| 1718 | for (const endpointId in this.futuresSubscriptions) { |
| 1719 | const ws = this.futuresSubscriptions[endpointId]; |
| 1720 | if (ws.isAlive) { |
| 1721 | ws.isAlive = false; |
| 1722 | if (ws.readyState === WebSocket.OPEN) ws.ping(this.noop); |
| 1723 | } else { |
| 1724 | if (this.Options.verbose) this.Options.log(`Terminating zombie futures WebSocket: ${ws.endpoint}`); |
| 1725 | if (ws.readyState === WebSocket.OPEN) ws.terminate(); |
| 1726 | } |
| 1727 | } |
| 1728 | } |
| 1729 | |
| 1730 | /** |
| 1731 | * Called when a futures socket is opened, subscriptions are registered for later reference |