MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / handleMessage

Method handleMessage

packages/event-service/src/client.ts:356–385  ·  view source on GitHub ↗
(data: string)

Source from the content-addressed store, hash-verified

354 if (current <= 1) {
355 this.activeContexts.delete(ctx);
356 released.push(ctx);
357 } else {
358 this.activeContexts.set(ctx, current - 1);
359 }
360 }
361 if (released.length > 0 && this.isConnected()) {
362 const message = {
363 type: 'context.unsubscribe',
364 contexts: released,
365 } satisfies ClientMessage;
366 this.send(message);
367 }
368 }
369
370 onReconnect(handler: () => void): () => void {
371 this.reconnectHandlers.add(handler);
372 return () => {
373 this.reconnectHandlers.delete(handler);
374 };
375 }
376
377 /**
378 * Registers a handler that fires every time the underlying WebSocket
379 * transitions to OPEN — including the very first successful connect.
380 *
381 * If the socket is already connected at call time, the handler is called
382 * synchronously before this method returns, then added to the set so it
383 * also fires on future connect transitions.
384 *
385 * Returns an unsubscribe function. Calling it removes the handler.
386 */
387 onConnected(handler: () => void): () => void {
388 this.connectedHandlers.add(handler);

Callers 1

connectOnceMethod · 0.95

Calls 3

getMethod · 0.65
warnMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected