MCPcopy Create free account
hub / github.com/RioArisk/claudecode_api_RemoteControl / sendWs

Function sendWs

lib/logger.js:80–93  ·  view source on GitHub ↗
(ws, msg, context = '')

Source from the content-addressed store, hash-verified

78}
79
80function sendWs(ws, msg, context = '') {
81 if (!ws || ws.readyState !== WebSocket.OPEN) return false;
82 ws.send(JSON.stringify(msg));
83 if (msg.type === 'status' || msg.type === 'transcript_ready' || msg.type === 'replay_done' || msg.type === 'turn_state') {
84 const extra = [];
85 if (msg.sessionId !== undefined) extra.push(`session=${msg.sessionId ?? 'null'}`);
86 if (msg.lastSeq !== undefined) extra.push(`lastSeq=${msg.lastSeq}`);
87 if (msg.resumed !== undefined) extra.push(`resumed=${msg.resumed}`);
88 if (msg.phase !== undefined) extra.push(`phase=${msg.phase}`);
89 if (msg.version !== undefined) extra.push(`version=${msg.version}`);
90 log(`Send ${msg.type}${context ? ` (${context})` : ''} -> ${wsLabel(ws)}${extra.length ? ` ${extra.join(' ')}` : ''}`);
91 }
92 return true;
93}
94
95function broadcast(msg) {
96 if (!state.wss) return;

Callers 5

sendTurnStateFunction · 0.85
sendReplayFunction · 0.85
sendInitialMessagesFunction · 0.85
sendAuthOkFunction · 0.85
setupWebSocketServerFunction · 0.85

Calls 2

logFunction · 0.85
wsLabelFunction · 0.85

Tested by

no test coverage detected