* Delivery heartbeat code with a shared single interval tick * @return {undefined}
()
| 2444 | * @return {undefined} |
| 2445 | */ |
| 2446 | deliverySocketHeartbeat() { |
| 2447 | /* Sockets removed from subscriptions during a manual terminate() |
| 2448 | will no longer be at risk of having functions called on them */ |
| 2449 | for (const endpointId in this.deliverySubscriptions) { |
| 2450 | const ws = this.deliverySubscriptions[endpointId]; |
| 2451 | if (ws.isAlive) { |
| 2452 | ws.isAlive = false; |
| 2453 | if (ws.readyState === WebSocket.OPEN) ws.ping(this.noop); |
| 2454 | } else { |
| 2455 | if (this.Options.verbose) this.Options.log(`Terminating zombie delivery WebSocket: ${ws.endpoint}`); |
| 2456 | if (ws.readyState === WebSocket.OPEN) ws.terminate(); |
| 2457 | } |
| 2458 | } |
| 2459 | } |
| 2460 | |
| 2461 | /** |
| 2462 | * Called when a delivery socket is opened, subscriptions are registered for later reference |