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

Method getOrCreateSubscriber

app/src/utils/streamManager.ts:193–212  ·  view source on GitHub ↗

* Get or create a subscriber for an agent and stream type. * The subscriber accumulates transcripts independently for each agent.

(agentId: string, type: AudioStreamType)

Source from the content-addressed store, hash-verified

191 * The subscriber accumulates transcripts independently for each agent.
192 */
193 public getOrCreateSubscriber(agentId: string, type: AudioStreamType): TranscriptionSubscriber {
194 const key = this.subscriberKey(agentId, type);
195
196 if (!this.subscribers.has(key)) {
197 const subscriber = new TranscriptionSubscriberImpl(agentId, type);
198 this.subscribers.set(key, subscriber);
199
200 // Register with transcription service to receive pushes
201 const router = TranscriptionRouter.getInstance();
202 const service = router.getActiveService(type);
203 if (service) {
204 service.addSubscriber(subscriber);
205 Logger.debug("StreamManager", `Registered subscriber ${key} with transcription service for ${type}`);
206 } else {
207 Logger.warn("StreamManager", `No transcription service found for ${type} when creating subscriber ${key}`);
208 }
209 }
210
211 return this.subscribers.get(key)!;
212 }
213
214 /**
215 * Get an existing subscriber for an agent and stream type.

Callers 3

pre-processor.tsFile · 0.80
useSubscriberTextFunction · 0.80

Calls 6

subscriberKeyMethod · 0.95
getActiveServiceMethod · 0.80
addSubscriberMethod · 0.80
warnMethod · 0.80
getInstanceMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected