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

Method getOrCreateSubscriber

app/src/utils/streamManager.ts:171–190  ·  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

169 * The subscriber accumulates transcripts independently for each agent.
170 */
171 public getOrCreateSubscriber(agentId: string, type: AudioStreamType): TranscriptionSubscriber {
172 const key = this.subscriberKey(agentId, type);
173
174 if (!this.subscribers.has(key)) {
175 const subscriber = new TranscriptionSubscriberImpl(agentId, type);
176 this.subscribers.set(key, subscriber);
177
178 // Register with transcription service to receive pushes
179 const router = TranscriptionRouter.getInstance();
180 const service = router.getActiveService(type);
181 if (service) {
182 service.addSubscriber(subscriber);
183 Logger.debug("StreamManager", `Registered subscriber ${key} with transcription service for ${type}`);
184 } else {
185 Logger.warn("StreamManager", `No transcription service found for ${type} when creating subscriber ${key}`);
186 }
187 }
188
189 return this.subscribers.get(key)!;
190 }
191
192 /**
193 * 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