MCPcopy Create free account
hub / github.com/Noumena-Network/code / sendLine

Method sendLine

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

Source from the content-addressed store, hash-verified

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.

Callers 2

writeMethod · 0.95

Calls 4

handleConnectionErrorMethod · 0.95
logForDiagnosticsNoPIIFunction · 0.85
logForDebuggingFunction · 0.50
sendMethod · 0.45

Tested by

no test coverage detected