MCPcopy Index your code
hub / github.com/codeaashu/claude-code / connect

Method connect

web/lib/api/stream.ts:118–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116 }
117
118 connect(): void {
119 if (this.closed) return;
120
121 this.eventSource = new EventSource(this.url);
122
123 this.eventSource.onopen = () => {
124 this.reconnectAttempts = 0;
125 this.opts.onConnect?.();
126 };
127
128 this.eventSource.onmessage = (e: MessageEvent) => {
129 if (typeof e.data !== "string") return;
130 if (e.data === "[DONE]") return;
131 try {
132 const event = JSON.parse(e.data as string) as StreamEvent;
133 this.opts.onEvent(event);
134 } catch {
135 // skip malformed events
136 }
137 };
138
139 this.eventSource.onerror = () => {
140 this.eventSource?.close();
141 this.eventSource = null;
142 this.opts.onDisconnect?.();
143 this.scheduleReconnect();
144 };
145 }
146
147 disconnect(): void {
148 this.closed = true;

Callers 5

scheduleReconnectMethod · 0.95
startStreamableHTTPFunction · 0.45
startLegacySSEFunction · 0.45
mainFunction · 0.45
vercelApp.tsFile · 0.45

Calls 3

scheduleReconnectMethod · 0.95
parseMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected