()
| 647 | } |
| 648 | |
| 649 | private startPingTimer(): void { |
| 650 | this.pingTimer = setInterval(() => { |
| 651 | if (this.closed) return; |
| 652 | this.send(buildPing()); |
| 653 | |
| 654 | if (this.pongTimer) clearTimeout(this.pongTimer); |
| 655 | this.pongTimer = setTimeout(() => { |
| 656 | if (this.closed) return; |
| 657 | this.logger.warn('pong timeout — terminating socket'); |
| 658 | try { |
| 659 | this.socket.terminate(); |
| 660 | } catch { |
| 661 | |
| 662 | } |
| 663 | }, this.pongTimeoutMs); |
| 664 | this.pongTimer.unref?.(); |
| 665 | }, this.pingIntervalMs); |
| 666 | this.pingTimer.unref?.(); |
| 667 | } |
| 668 | |
| 669 | private onPong(): void { |
| 670 | if (this.pongTimer) { |
no test coverage detected