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