(line: string)
| 329 | } |
| 330 | |
| 331 | protected sendLine(line: string): boolean { |
| 332 | if (!this.ws || this.state !== 'connected') { |
| 333 | logForDebugging('WebSocketTransport: Not connected') |
| 334 | logForDiagnosticsNoPII('info', 'cli_websocket_send_not_connected') |
| 335 | return false |
| 336 | } |
| 337 | |
| 338 | try { |
| 339 | this.ws.send(line) |
| 340 | this.lastActivityTime = Date.now() |
| 341 | return true |
| 342 | } catch (error) { |
| 343 | logForDebugging(`WebSocketTransport: Failed to send: ${error}`, { |
| 344 | level: 'error', |
| 345 | }) |
| 346 | logForDiagnosticsNoPII('error', 'cli_websocket_send_error') |
| 347 | // Don't null this.ws here — let doDisconnect() (via handleConnectionError) |
| 348 | // handle cleanup so listeners are removed before the WS is released. |
| 349 | this.handleConnectionError() |
| 350 | return false |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | /** |
| 355 | * Remove all listeners attached in connect() for the given WebSocket. |
no test coverage detected