MCPcopy Create free account
hub / github.com/modem-dev/hunk / sendSnapshotUpdates

Function sendSnapshotUpdates

scripts/daemon-memory-check.ts:383–403  ·  view source on GitHub ↗
(
  sockets: WebSocket[],
  sessionIds: string[],
  updatesPerSession: number,
  options: CliOptions,
)

Source from the content-addressed store, hash-verified

381}
382
383async function sendSnapshotUpdates(
384 sockets: WebSocket[],
385 sessionIds: string[],
386 updatesPerSession: number,
387 options: CliOptions,
388) {
389 for (let updateIndex = 1; updateIndex <= updatesPerSession; updateIndex += 1) {
390 for (let sessionIndex = 0; sessionIndex < sockets.length; sessionIndex += 1) {
391 sockets[sessionIndex]!.send(
392 JSON.stringify({
393 type: "snapshot",
394 sessionId: sessionIds[sessionIndex],
395 snapshot: makeSnapshot(sessionIds[sessionIndex]!, updateIndex, options),
396 }),
397 );
398 }
399 }
400
401 // Give the daemon event loop one turn to process the burst before API reads sample the state.
402 await Bun.sleep(0);
403}
404
405async function postSessionApi(port: number, body: Record<string, unknown>) {
406 const response = await fetch(`http://127.0.0.1:${port}${HUNK_SESSION_API_PATH}`, {

Callers 1

mainFunction · 0.85

Calls 2

makeSnapshotFunction · 0.85
sendMethod · 0.65

Tested by

no test coverage detected