(line: string)
| 341 | } |
| 342 | |
| 343 | protected sendLine(line: string): boolean { |
| 344 | if (!this.ws || this.state !== 'connected') { |
| 345 | logForDebugging('WebSocketTransport: Not connected') |
| 346 | logForDiagnosticsNoPII('info', 'cli_websocket_send_not_connected') |
| 347 | return false |
| 348 | } |
| 349 | |
| 350 | try { |
| 351 | this.ws.send(line) |
| 352 | this.lastActivityTime = Date.now() |
| 353 | return true |
| 354 | } catch (error) { |
| 355 | logForDebugging(`WebSocketTransport: Failed to send: ${error}`, { |
| 356 | level: 'error', |
| 357 | }) |
| 358 | logForDiagnosticsNoPII('error', 'cli_websocket_send_error') |
| 359 | // Don't null this.ws here — let doDisconnect() (via handleConnectionError) |
| 360 | // handle cleanup so listeners are removed before the WS is released. |
| 361 | this.handleConnectionError() |
| 362 | return false |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /** |
| 367 | * Remove all listeners attached in connect() for the given WebSocket. |
no test coverage detected