MCPcopy
hub / github.com/redis/node-redis / sendToClient

Method sendToClient

packages/test-utils/lib/proxy/redis-proxy.ts:206–243  ·  view source on GitHub ↗
(connectionId: string, data: Buffer)

Source from the content-addressed store, hash-verified

204 }
205
206 public sendToClient(connectionId: string, data: Buffer): SendResult {
207 const connection = this.connections.get(connectionId);
208 if (!connection) {
209 return {
210 success: false,
211 error: 'Connection not found',
212 connectionId
213 };
214 }
215
216 if (connection.clientSocket.destroyed || !connection.clientSocket.writable) {
217 return {
218 success: false,
219 error: 'Client socket is not writable',
220 connectionId
221 };
222 }
223
224 try {
225 connection.clientSocket.write(data);
226
227 this.log(`Sent ${data.length} bytes to client ${connectionId}`);
228 this.emit('data', connectionId, 'server->client', data);
229
230 return {
231 success: true,
232 connectionId
233 };
234 } catch (error) {
235 const errorMessage = error instanceof Error ? error.message : 'Unknown error';
236 this.log(`Failed to send data to client ${connectionId}: ${errorMessage}`);
237 return {
238 success: false,
239 error: errorMessage,
240 connectionId
241 };
242 }
243 }
244
245 public sendToAllClients(data: Buffer): readonly SendResult[] {
246 const connectionIds = Array.from(this.connections.keys());

Callers 3

sendToAllClientsMethod · 0.95
sendToClientsMethod · 0.95
triggerMigrateMethod · 0.45

Calls 3

logMethod · 0.95
getMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected