MCPcopy Create free account
hub / github.com/Roy3838/Observer / destroySubscribersForAgent

Method destroySubscribersForAgent

app/src/utils/streamManager.ts:222–244  ·  view source on GitHub ↗

* Destroy all subscribers for an agent. * Called when an agent stops.

(agentId: string)

Source from the content-addressed store, hash-verified

220 * Called when an agent stops.
221 */
222 public destroySubscribersForAgent(agentId: string): void {
223 const keysToDelete: string[] = [];
224
225 const router = TranscriptionRouter.getInstance();
226 for (const [key, subscriber] of this.subscribers) {
227 if (key.startsWith(`${agentId}:`)) {
228 // Remove from transcription service
229 const service = router.getActiveService(subscriber.streamType);
230 if (service) {
231 service.removeSubscriber(subscriber);
232 }
233
234 subscriber.destroy();
235 keysToDelete.push(key);
236 }
237 }
238
239 keysToDelete.forEach(key => this.subscribers.delete(key));
240
241 if (keysToDelete.length > 0) {
242 Logger.debug("StreamManager", `Destroyed ${keysToDelete.length} subscriber(s) for agent ${agentId}`);
243 }
244 }
245
246 public addListener(listener: StreamListener): void { this.listeners.add(listener); listener(this.getCurrentState()); }
247 public removeListener(listener: StreamListener): void { this.listeners.delete(listener); }

Callers 4

MCPFunction · 0.80
stopMicFunction · 0.80
startMicFunction · 0.80
stopAgentLoopFunction · 0.80

Calls 7

getActiveServiceMethod · 0.80
removeSubscriberMethod · 0.80
pushMethod · 0.80
deleteMethod · 0.80
destroyMethod · 0.65
getInstanceMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected