MCPcopy Index your code
hub / github.com/codeaashu/claude-code / sendLine

Method sendLine

src/cli/transports/WebSocketTransport.ts:331–352  ·  view source on GitHub ↗
(line: string)

Source from the content-addressed store, hash-verified

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.

Callers 2

writeMethod · 0.95

Calls 4

handleConnectionErrorMethod · 0.95
logForDebuggingFunction · 0.85
logForDiagnosticsNoPIIFunction · 0.85
sendMethod · 0.65

Tested by

no test coverage detected