MCPcopy Create free account
hub / github.com/backnotprop/plannotator / start

Function start

packages/server/external-annotations.ts:93–115  ·  view source on GitHub ↗
(controller)

Source from the content-addressed store, hash-verified

91
92 const stream = new ReadableStream({
93 start(controller) {
94 ctrl = controller;
95
96 // Send current state as snapshot
97 const snapshot: ExternalAnnotationEvent<StorableAnnotation> = {
98 type: "snapshot",
99 annotations: store.getAll(),
100 };
101 controller.enqueue(encoder.encode(serializeSSEEvent(snapshot)));
102
103 subscribers.add(controller);
104
105 // Heartbeat to keep connection alive
106 heartbeatTimer = setInterval(() => {
107 try {
108 controller.enqueue(encoder.encode(HEARTBEAT_COMMENT));
109 } catch {
110 // Stream closed
111 if (heartbeatTimer) clearInterval(heartbeatTimer);
112 subscribers.delete(controller);
113 }
114 }, HEARTBEAT_INTERVAL_MS);
115 },
116 cancel() {
117 if (heartbeatTimer) clearInterval(heartbeatTimer);
118 subscribers.delete(ctrl);

Callers

nothing calls this directly

Calls 4

serializeSSEEventFunction · 0.90
getAllMethod · 0.80
addMethod · 0.80
deleteMethod · 0.80

Tested by

no test coverage detected