* Get or create a subscriber for an agent and stream type. * The subscriber accumulates transcripts independently for each agent.
(agentId: string, type: AudioStreamType)
| 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. |
no test coverage detected