@webex/plugin-meetings 3.12.0-next.171 → 3.12.0-next.173
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aiEnableRequest/index.js +1 -1
- package/dist/annotation/index.js +53 -17
- package/dist/annotation/index.js.map +1 -1
- package/dist/breakouts/breakout.js +1 -1
- package/dist/breakouts/index.js +35 -9
- package/dist/breakouts/index.js.map +1 -1
- package/dist/interceptors/dataChannelAuthToken.js +41 -59
- package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
- package/dist/interpretation/index.js +1 -1
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/meeting/index.js +327 -292
- package/dist/meeting/index.js.map +1 -1
- package/dist/meeting/util.js +5 -1
- package/dist/meeting/util.js.map +1 -1
- package/dist/meetings/index.js +4 -1
- package/dist/meetings/index.js.map +1 -1
- package/dist/types/annotation/index.d.ts +19 -0
- package/dist/types/meeting/index.d.ts +46 -12
- package/dist/types/meeting/util.d.ts +3 -1
- package/dist/webinar/index.js +298 -255
- package/dist/webinar/index.js.map +1 -1
- package/package.json +13 -13
- package/src/annotation/index.ts +55 -25
- package/src/breakouts/index.ts +33 -11
- package/src/interceptors/dataChannelAuthToken.ts +48 -77
- package/src/meeting/index.ts +296 -289
- package/src/meeting/util.ts +2 -2
- package/src/meetings/index.ts +2 -1
- package/src/webinar/index.ts +168 -188
- package/test/unit/spec/annotation/index.ts +214 -182
- package/test/unit/spec/breakouts/index.ts +126 -25
- package/test/unit/spec/interceptors/dataChannelAuthToken.ts +81 -99
- package/test/unit/spec/meeting/index.js +939 -705
- package/test/unit/spec/meeting/utils.js +16 -2
- package/test/unit/spec/meetings/index.js +5 -0
- package/test/unit/spec/webinar/index.ts +886 -718
package/src/meeting/util.ts
CHANGED
|
@@ -365,7 +365,7 @@ const MeetingUtil = {
|
|
|
365
365
|
});
|
|
366
366
|
},
|
|
367
367
|
|
|
368
|
-
cleanUp: (meeting) => {
|
|
368
|
+
cleanUp: (meeting, {preserveVoiceaChannel = true}: {preserveVoiceaChannel?: boolean} = {}) => {
|
|
369
369
|
meeting.getWebexObject().internal.device.meetingEnded();
|
|
370
370
|
meeting.stopPeriodicLogUpload();
|
|
371
371
|
|
|
@@ -395,7 +395,7 @@ const MeetingUtil = {
|
|
|
395
395
|
.then(() => meeting.stopKeepAlive())
|
|
396
396
|
.then(() => {
|
|
397
397
|
if (meeting.config?.enableAutomaticLLM) {
|
|
398
|
-
return meeting.cleanupLLMConneciton({throwOnError: false});
|
|
398
|
+
return meeting.cleanupLLMConneciton({throwOnError: false, preserveVoiceaChannel});
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
return undefined;
|
package/src/meetings/index.ts
CHANGED
|
@@ -1492,7 +1492,8 @@ export default class Meetings extends WebexPlugin {
|
|
|
1492
1492
|
* @memberof Meetings
|
|
1493
1493
|
*/
|
|
1494
1494
|
private destroy(meeting: Meeting, reason: object) {
|
|
1495
|
-
MeetingUtil.cleanUp(meeting);
|
|
1495
|
+
MeetingUtil.cleanUp(meeting, {preserveVoiceaChannel: false});
|
|
1496
|
+
|
|
1496
1497
|
// Tear down hash tree parsers here (and not in MeetingUtil.cleanUp) so they survive
|
|
1497
1498
|
// leave/endMeetingForAll to consume the final sentinel END message from Locus.
|
|
1498
1499
|
meeting.locusInfo?.cleanUp();
|
package/src/webinar/index.ts
CHANGED
|
@@ -4,36 +4,25 @@
|
|
|
4
4
|
import {WebexPlugin, config} from '@webex/webex-core';
|
|
5
5
|
import uuid from 'uuid';
|
|
6
6
|
import {get} from 'lodash';
|
|
7
|
+
import type LLMChannel from '@webex/internal-plugin-llm';
|
|
7
8
|
import {
|
|
8
9
|
_ID_,
|
|
10
|
+
EVENT_TRIGGERS,
|
|
9
11
|
HEADERS,
|
|
10
12
|
HTTP_VERBS,
|
|
11
13
|
MEETINGS,
|
|
12
14
|
SELF_ROLES,
|
|
13
15
|
SHARE_STATUS,
|
|
14
16
|
DEFAULT_LARGE_SCALE_WEBINAR_ATTENDEE_SEARCH_LIMIT,
|
|
15
|
-
LLM_PRACTICE_SESSION,
|
|
16
17
|
LOCUS_LLM_EVENT,
|
|
17
18
|
} from '../constants';
|
|
19
|
+
import Trigger from '../common/events/trigger-proxy';
|
|
18
20
|
|
|
19
21
|
import WebinarCollection from './collection';
|
|
20
22
|
import LoggerProxy from '../common/logs/logger-proxy';
|
|
21
23
|
import MeetingUtil from '../meeting/util';
|
|
22
24
|
import {sanitizeParams} from './utils';
|
|
23
25
|
|
|
24
|
-
const PS_LLM_EVENTS = [
|
|
25
|
-
{
|
|
26
|
-
event: `event:relay.event:${LLM_PRACTICE_SESSION}`,
|
|
27
|
-
listenerKey: 'relay',
|
|
28
|
-
handlerKey: 'processRelayEvent',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
event: `${LOCUS_LLM_EVENT}:${LLM_PRACTICE_SESSION}`,
|
|
32
|
-
listenerKey: 'locusLLM',
|
|
33
|
-
handlerKey: 'processLocusLLMEvent',
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
|
|
37
26
|
/**
|
|
38
27
|
* @class Webinar
|
|
39
28
|
*/
|
|
@@ -53,6 +42,21 @@ const Webinar = WebexPlugin.extend({
|
|
|
53
42
|
meetingId: 'string',
|
|
54
43
|
},
|
|
55
44
|
|
|
45
|
+
/**
|
|
46
|
+
* LLM channel for practice session, owned by this webinar instance.
|
|
47
|
+
* @private
|
|
48
|
+
* @type {LLMChannel|undefined}
|
|
49
|
+
*/
|
|
50
|
+
_practiceSessionLLMChannel: undefined as LLMChannel | undefined,
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Pending practice session datachannel token, saved from join response.
|
|
54
|
+
* Used when creating the practice session LLM channel.
|
|
55
|
+
* @private
|
|
56
|
+
* @type {string|undefined}
|
|
57
|
+
*/
|
|
58
|
+
_pendingPracticeSessionDatachannelToken: undefined as string | undefined,
|
|
59
|
+
|
|
56
60
|
/**
|
|
57
61
|
* Calls this to clean up listeners
|
|
58
62
|
* @returns {void}
|
|
@@ -177,67 +181,96 @@ const Webinar = WebexPlugin.extend({
|
|
|
177
181
|
},
|
|
178
182
|
|
|
179
183
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
|
|
183
|
-
|
|
184
|
+
* Returns the practice session LLM channel binding, if connected.
|
|
185
|
+
* @returns {string|undefined}
|
|
186
|
+
*/
|
|
187
|
+
getPracticeSessionBinding() {
|
|
188
|
+
return this._practiceSessionLLMChannel?.getBinding();
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Returns whether the practice session LLM channel is connected.
|
|
193
|
+
* @returns {boolean}
|
|
194
|
+
*/
|
|
195
|
+
isPracticeSessionLLMChannelConnected() {
|
|
196
|
+
return this._practiceSessionLLMChannel?.isConnected() ?? false;
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Returns the practice session LLM channel's locus URL, if available.
|
|
201
|
+
* @returns {string|undefined}
|
|
202
|
+
*/
|
|
203
|
+
getPracticeSessionLocusUrl() {
|
|
204
|
+
return this._practiceSessionLLMChannel?.getLocusUrl();
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Stores the practice session datachannel token for later use when
|
|
209
|
+
* creating the practice session LLM channel.
|
|
210
|
+
* @param {string} token - The datachannel token to store
|
|
211
|
+
* @returns {void}
|
|
212
|
+
*/
|
|
213
|
+
setPracticeSessionDatachannelToken(token: string) {
|
|
214
|
+
this._pendingPracticeSessionDatachannelToken = token;
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Disconnects the practice session LLM channel and cleans up listeners.
|
|
184
219
|
* @returns {Promise<void>}
|
|
185
220
|
*/
|
|
186
221
|
async cleanupPSDataChannel() {
|
|
187
|
-
|
|
188
|
-
this.meetingId,
|
|
189
|
-
LLM_PRACTICE_SESSION
|
|
190
|
-
);
|
|
191
|
-
this.llmListeners = this.llmListeners || {};
|
|
192
|
-
|
|
222
|
+
// Remove pending online listener if any
|
|
193
223
|
if (this._pendingOnlineListener) {
|
|
194
|
-
|
|
195
|
-
|
|
224
|
+
const meeting = this.getValidatedWebinarMeeting();
|
|
225
|
+
meeting?.llmChannel?.off('online', this._pendingOnlineListener);
|
|
196
226
|
this._pendingOnlineListener = null;
|
|
197
227
|
}
|
|
198
228
|
|
|
199
|
-
|
|
200
|
-
// @ts-ignore - Fix type
|
|
201
|
-
const disconnected = await this.webex.internal.llm.disconnectLLM(
|
|
202
|
-
{
|
|
203
|
-
code: 3050,
|
|
204
|
-
reason: 'done (permanent)',
|
|
205
|
-
},
|
|
206
|
-
LLM_PRACTICE_SESSION,
|
|
207
|
-
this.meetingId
|
|
208
|
-
);
|
|
229
|
+
const meeting = this.getValidatedWebinarMeeting();
|
|
209
230
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
} catch (error) {
|
|
216
|
-
// disconnectLLM clears ownership only on success; release a stale owner
|
|
217
|
-
// tag here so other meeting instances can reclaim practice-session LLM.
|
|
218
|
-
if (isOwner) {
|
|
219
|
-
// @ts-ignore - Fix type
|
|
220
|
-
this.webex.internal.llm.setOwnerMeetingId?.(undefined, LLM_PRACTICE_SESSION);
|
|
231
|
+
if (!this._practiceSessionLLMChannel) {
|
|
232
|
+
// Even without PS channel, ensure voicea is bound to main channel
|
|
233
|
+
if (meeting?.voiceaChannel && meeting?.llmChannel) {
|
|
234
|
+
await meeting.voiceaChannel.switchLLMChannel(meeting.llmChannel);
|
|
235
|
+
meeting.startTranscriptionIfNeeded();
|
|
221
236
|
}
|
|
222
237
|
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
try {
|
|
242
|
+
await this._practiceSessionLLMChannel.disconnect({
|
|
243
|
+
code: 3050,
|
|
244
|
+
reason: 'done (permanent)',
|
|
245
|
+
});
|
|
246
|
+
} catch (error) {
|
|
247
|
+
LoggerProxy.logger.error(
|
|
248
|
+
'Webinar:index#cleanupPSDataChannel --> Failed to disconnect practice session LLM channel',
|
|
249
|
+
error
|
|
250
|
+
);
|
|
223
251
|
throw error;
|
|
224
252
|
} finally {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
this.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
for (const {event, listenerKey} of PS_LLM_EVENTS) {
|
|
235
|
-
if (this.llmListeners[listenerKey]) {
|
|
236
|
-
// @ts-ignore - Fix type
|
|
237
|
-
this.webex.internal.llm.off(event, this.llmListeners[listenerKey]);
|
|
238
|
-
this.llmListeners[listenerKey] = null;
|
|
253
|
+
// Remove listeners from the channel
|
|
254
|
+
if (meeting) {
|
|
255
|
+
this._practiceSessionLLMChannel?.off('event:relay.event', meeting.processRelayEvent);
|
|
256
|
+
this._practiceSessionLLMChannel?.off(LOCUS_LLM_EVENT, meeting.processLocusLLMEvent);
|
|
257
|
+
this._practiceSessionLLMChannel?.off('online', meeting.handleLLMOnline);
|
|
258
|
+
|
|
259
|
+
// Switch annotation back to the meeting's default channel
|
|
260
|
+
if (meeting.llmChannel) {
|
|
261
|
+
meeting.annotation.registerChannel(meeting.llmChannel);
|
|
239
262
|
}
|
|
240
263
|
}
|
|
264
|
+
this._practiceSessionLLMChannel = undefined;
|
|
265
|
+
|
|
266
|
+
// Switch voicea to current main channel. Switching after disconnect ensures:
|
|
267
|
+
// - If main channel was replaced during disconnect (concurrent updateLLMConnection),
|
|
268
|
+
// meeting.llmChannel will be the new channel
|
|
269
|
+
// - If the channel is still connecting, switchLLMChannel waits for it to come online
|
|
270
|
+
if (meeting?.voiceaChannel && meeting?.llmChannel) {
|
|
271
|
+
await meeting.voiceaChannel.switchLLMChannel(meeting.llmChannel);
|
|
272
|
+
meeting.startTranscriptionIfNeeded();
|
|
273
|
+
}
|
|
241
274
|
}
|
|
242
275
|
},
|
|
243
276
|
|
|
@@ -256,11 +289,10 @@ const Webinar = WebexPlugin.extend({
|
|
|
256
289
|
return undefined;
|
|
257
290
|
}
|
|
258
291
|
|
|
259
|
-
//
|
|
260
|
-
const cachedToken =
|
|
261
|
-
|
|
262
|
-
this.
|
|
263
|
-
);
|
|
292
|
+
// Check for cached token on the channel or pending token
|
|
293
|
+
const cachedToken =
|
|
294
|
+
this._practiceSessionLLMChannel?.getDatachannelToken() ??
|
|
295
|
+
this._pendingPracticeSessionDatachannelToken;
|
|
264
296
|
|
|
265
297
|
if (cachedToken) {
|
|
266
298
|
return cachedToken;
|
|
@@ -268,18 +300,18 @@ const Webinar = WebexPlugin.extend({
|
|
|
268
300
|
|
|
269
301
|
try {
|
|
270
302
|
const refreshResponse = await meeting.refreshDataChannelToken();
|
|
271
|
-
const {datachannelToken
|
|
303
|
+
const {datachannelToken} = refreshResponse?.body ?? {};
|
|
272
304
|
|
|
273
305
|
if (!datachannelToken) {
|
|
274
306
|
return undefined;
|
|
275
307
|
}
|
|
276
308
|
|
|
277
|
-
//
|
|
278
|
-
this.
|
|
279
|
-
datachannelToken
|
|
280
|
-
|
|
281
|
-
this.
|
|
282
|
-
|
|
309
|
+
// Store token on the channel if it exists, otherwise save for later
|
|
310
|
+
if (this._practiceSessionLLMChannel) {
|
|
311
|
+
this._practiceSessionLLMChannel.setDatachannelToken(datachannelToken);
|
|
312
|
+
} else {
|
|
313
|
+
this._pendingPracticeSessionDatachannelToken = datachannelToken;
|
|
314
|
+
}
|
|
283
315
|
|
|
284
316
|
return datachannelToken;
|
|
285
317
|
} catch (error) {
|
|
@@ -294,22 +326,17 @@ const Webinar = WebexPlugin.extend({
|
|
|
294
326
|
},
|
|
295
327
|
|
|
296
328
|
/**
|
|
297
|
-
* Connects
|
|
298
|
-
*
|
|
329
|
+
* Connects practice session LLM channel. Creates a new channel if needed.
|
|
330
|
+
* Will disconnect if the meeting has ended or is no longer in practice session mode.
|
|
331
|
+
* Waits for the main LLM channel to be connected before connecting practice session.
|
|
299
332
|
* @returns {Promise}
|
|
300
333
|
*/
|
|
301
334
|
async updatePSDataChannel() {
|
|
302
|
-
this.llmListeners = this.llmListeners || {};
|
|
303
|
-
|
|
304
335
|
this._updatePSDataChannelSequence = (this._updatePSDataChannelSequence || 0) + 1;
|
|
305
336
|
const invocationSequence = this._updatePSDataChannelSequence;
|
|
306
337
|
|
|
307
338
|
const meeting = this.getValidatedWebinarMeeting();
|
|
308
339
|
const isPracticeSession = meeting?.isJoined() && this.isJoinPracticeSessionDataChannel();
|
|
309
|
-
const {currentOwner, isOwner} = this.webex.internal.llm.resolveSessionOwnership(
|
|
310
|
-
this.meetingId,
|
|
311
|
-
LLM_PRACTICE_SESSION
|
|
312
|
-
);
|
|
313
340
|
|
|
314
341
|
if (!isPracticeSession) {
|
|
315
342
|
await this.cleanupPSDataChannel();
|
|
@@ -317,61 +344,40 @@ const Webinar = WebexPlugin.extend({
|
|
|
317
344
|
return undefined;
|
|
318
345
|
}
|
|
319
346
|
|
|
320
|
-
if (!isOwner) {
|
|
321
|
-
LoggerProxy.logger.info(
|
|
322
|
-
`Webinar:index#updatePSDataChannel --> skipping; practice-session LLM owned by meeting ${currentOwner}, not ${this.meetingId}`
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
return undefined;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
347
|
// @ts-ignore - Fix type
|
|
329
348
|
const {url = undefined, info: {practiceSessionDatachannelUrl = undefined} = {}} =
|
|
330
349
|
meeting?.locusInfo || {};
|
|
331
350
|
|
|
332
|
-
// @ts-ignore
|
|
333
|
-
let practiceSessionDatachannelToken = this.webex.internal.llm.getDatachannelToken(
|
|
334
|
-
LLM_PRACTICE_SESSION,
|
|
335
|
-
this.meetingId
|
|
336
|
-
);
|
|
337
|
-
|
|
338
|
-
const keepTranscriptionSubscribed = this.webex.internal.voicea.getKeepTranscriptionSubscribed();
|
|
339
|
-
|
|
340
351
|
if (!practiceSessionDatachannelUrl) {
|
|
341
352
|
return undefined;
|
|
342
353
|
}
|
|
343
|
-
|
|
344
|
-
|
|
354
|
+
|
|
355
|
+
// If already connected to same URLs, skip reconnect
|
|
356
|
+
if (this._practiceSessionLLMChannel?.isConnected()) {
|
|
345
357
|
if (
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
// @ts-ignore - Fix type
|
|
349
|
-
practiceSessionDatachannelUrl ===
|
|
350
|
-
this.webex.internal.llm.getDatachannelUrl(LLM_PRACTICE_SESSION)
|
|
358
|
+
url === this._practiceSessionLLMChannel.getLocusUrl() &&
|
|
359
|
+
practiceSessionDatachannelUrl === this._practiceSessionLLMChannel.getDatachannelUrl()
|
|
351
360
|
) {
|
|
352
361
|
return undefined;
|
|
353
362
|
}
|
|
354
|
-
|
|
363
|
+
// URLs changed, disconnect existing channel
|
|
355
364
|
await this.cleanupPSDataChannel();
|
|
356
365
|
}
|
|
357
366
|
|
|
358
|
-
// Ensure the default session
|
|
367
|
+
// Ensure the default session LLM channel is connected before connecting the practice session.
|
|
359
368
|
// Subscribe before checking isConnected() to avoid a race where the 'online' event fires
|
|
360
|
-
// between the check and the subscription —
|
|
361
|
-
if (!this._pendingOnlineListener) {
|
|
369
|
+
// between the check and the subscription — the channel does not replay missed events.
|
|
370
|
+
if (!this._pendingOnlineListener && meeting?.llmChannel) {
|
|
362
371
|
const onDefaultSessionConnected = () => {
|
|
363
372
|
this._pendingOnlineListener = null;
|
|
364
|
-
|
|
365
|
-
this.webex.internal.llm.off('online', onDefaultSessionConnected);
|
|
373
|
+
meeting.llmChannel?.off('online', onDefaultSessionConnected);
|
|
366
374
|
this.updatePSDataChannel();
|
|
367
375
|
};
|
|
368
376
|
this._pendingOnlineListener = onDefaultSessionConnected;
|
|
369
|
-
|
|
370
|
-
this.webex.internal.llm.on('online', onDefaultSessionConnected);
|
|
377
|
+
meeting.llmChannel.on('online', onDefaultSessionConnected);
|
|
371
378
|
}
|
|
372
379
|
|
|
373
|
-
|
|
374
|
-
if (!this.webex.internal.llm.isConnected()) {
|
|
380
|
+
if (!meeting?.llmChannel?.isConnected()) {
|
|
375
381
|
LoggerProxy.logger.info(
|
|
376
382
|
'Webinar:index#updatePSDataChannel --> default session not yet connected, deferring practice session connect.'
|
|
377
383
|
);
|
|
@@ -381,12 +387,16 @@ const Webinar = WebexPlugin.extend({
|
|
|
381
387
|
|
|
382
388
|
// Default session is already connected — cancel the pending listener and proceed
|
|
383
389
|
if (this._pendingOnlineListener) {
|
|
384
|
-
|
|
385
|
-
this.webex.internal.llm.off('online', this._pendingOnlineListener);
|
|
390
|
+
meeting.llmChannel.off('online', this._pendingOnlineListener);
|
|
386
391
|
this._pendingOnlineListener = null;
|
|
387
392
|
}
|
|
388
393
|
|
|
389
|
-
|
|
394
|
+
// Get token from pending or refresh if needed
|
|
395
|
+
let practiceSessionDatachannelToken =
|
|
396
|
+
this._pendingPracticeSessionDatachannelToken ??
|
|
397
|
+
this._practiceSessionLLMChannel?.getDatachannelToken();
|
|
398
|
+
|
|
399
|
+
const refreshedToken = await this.ensurePracticeSessionDatachannelToken(meeting);
|
|
390
400
|
|
|
391
401
|
const latestPracticeSessionDatachannelUrl = get(
|
|
392
402
|
meeting,
|
|
@@ -405,93 +415,63 @@ const Webinar = WebexPlugin.extend({
|
|
|
405
415
|
return undefined;
|
|
406
416
|
}
|
|
407
417
|
|
|
408
|
-
if (
|
|
409
|
-
practiceSessionDatachannelToken =
|
|
418
|
+
if (refreshedToken) {
|
|
419
|
+
practiceSessionDatachannelToken = refreshedToken;
|
|
410
420
|
}
|
|
411
421
|
|
|
412
|
-
|
|
413
|
-
|
|
422
|
+
// Create a new practice session LLM channel
|
|
423
|
+
// @ts-ignore - Fix type
|
|
424
|
+
const psChannel = this.webex.internal.llm.createChannel();
|
|
425
|
+
this._practiceSessionLLMChannel = psChannel;
|
|
414
426
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
`Webinar:index#updatePSDataChannel --> skipping pre-connect owner write; practice-session LLM owned by meeting ${currentOwnerBeforeConnect}, not ${this.meetingId}`
|
|
418
|
-
);
|
|
427
|
+
// Set up refresh handler before registration
|
|
428
|
+
psChannel.setRefreshHandler(() => meeting.refreshDataChannelToken());
|
|
419
429
|
|
|
420
|
-
|
|
430
|
+
// If we have a pending token, store it on the channel
|
|
431
|
+
if (this._pendingPracticeSessionDatachannelToken) {
|
|
432
|
+
psChannel.setDatachannelToken(this._pendingPracticeSessionDatachannelToken);
|
|
433
|
+
this._pendingPracticeSessionDatachannelToken = undefined;
|
|
421
434
|
}
|
|
422
435
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
() => meeting.refreshDataChannelToken(),
|
|
430
|
-
LLM_PRACTICE_SESSION,
|
|
431
|
-
this.meetingId
|
|
432
|
-
);
|
|
433
|
-
// @ts-ignore - Fix type
|
|
434
|
-
this.webex.internal.llm.setOwnerMeetingId?.(this.meetingId, LLM_PRACTICE_SESSION);
|
|
435
|
-
|
|
436
|
-
// @ts-ignore - Fix type
|
|
437
|
-
return this.webex.internal.llm
|
|
438
|
-
.registerAndConnect(
|
|
439
|
-
url,
|
|
440
|
-
practiceSessionDatachannelUrl,
|
|
441
|
-
practiceSessionDatachannelToken,
|
|
442
|
-
LLM_PRACTICE_SESSION
|
|
443
|
-
)
|
|
444
|
-
.then((registerAndConnectResult) => {
|
|
445
|
-
const {currentOwner: currentOwnerAfterConnect, isOwner: isOwnerAfterConnect} =
|
|
446
|
-
this.webex.internal.llm.resolveSessionOwnership(this.meetingId, LLM_PRACTICE_SESSION);
|
|
447
|
-
|
|
448
|
-
if (this.meetingId && isOwnerAfterConnect) {
|
|
449
|
-
// @ts-ignore - Fix type
|
|
450
|
-
this.webex.internal.llm.setOwnerMeetingId?.(this.meetingId, LLM_PRACTICE_SESSION);
|
|
451
|
-
} else {
|
|
452
|
-
LoggerProxy.logger.info(
|
|
453
|
-
`Webinar:index#updatePSDataChannel --> skipping post-connect owner write; practice-session LLM owned by meeting ${currentOwnerAfterConnect}, not ${this.meetingId}`
|
|
454
|
-
);
|
|
455
|
-
}
|
|
436
|
+
return psChannel
|
|
437
|
+
.registerAndConnect(url, practiceSessionDatachannelUrl, practiceSessionDatachannelToken)
|
|
438
|
+
.then(async (registerAndConnectResult) => {
|
|
439
|
+
// Check if this channel is still the current one (race condition guard)
|
|
440
|
+
if (this._practiceSessionLLMChannel !== psChannel) {
|
|
441
|
+
psChannel.disconnect({code: 3050, reason: 'replaced'}).catch(() => {});
|
|
456
442
|
|
|
457
|
-
|
|
458
|
-
// unsubscribe deterministically, even if the meeting can no longer
|
|
459
|
-
// be resolved at cleanup time.
|
|
460
|
-
for (const {event, listenerKey, handlerKey} of PS_LLM_EVENTS) {
|
|
461
|
-
if (this.llmListeners[listenerKey]) {
|
|
462
|
-
// @ts-ignore - Fix type
|
|
463
|
-
this.webex.internal.llm.off(event, this.llmListeners[listenerKey]);
|
|
464
|
-
}
|
|
465
|
-
this.llmListeners[listenerKey] = meeting?.[handlerKey];
|
|
466
|
-
// @ts-ignore - Fix type
|
|
467
|
-
this.webex.internal.llm.on(event, this.llmListeners[listenerKey]);
|
|
443
|
+
return undefined;
|
|
468
444
|
}
|
|
469
|
-
//
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
445
|
+
// Register event listeners on the practice session channel
|
|
446
|
+
psChannel.off('event:relay.event', meeting.processRelayEvent);
|
|
447
|
+
psChannel.on('event:relay.event', meeting.processRelayEvent);
|
|
448
|
+
psChannel.off(LOCUS_LLM_EVENT, meeting.processLocusLLMEvent);
|
|
449
|
+
psChannel.on(LOCUS_LLM_EVENT, meeting.processLocusLLMEvent);
|
|
450
|
+
psChannel.off('online', meeting.handleLLMOnline);
|
|
451
|
+
psChannel.on('online', meeting.handleLLMOnline);
|
|
452
|
+
|
|
453
|
+
// Switch annotation to practice session channel
|
|
454
|
+
meeting.annotation.registerChannel(psChannel);
|
|
455
|
+
|
|
456
|
+
// Switch meeting's voicea channel to use the PS LLM connection.
|
|
457
|
+
// The reconciler pattern preserves caption state and handles all timing.
|
|
458
|
+
// transcription is always initialized (reset to initial shape, never null).
|
|
459
|
+
if (meeting.voiceaChannel) {
|
|
460
|
+
await meeting.voiceaChannel.switchLLMChannel(psChannel);
|
|
461
|
+
meeting.startTranscriptionIfNeeded();
|
|
473
462
|
}
|
|
463
|
+
|
|
474
464
|
LoggerProxy.logger.info(
|
|
475
|
-
|
|
465
|
+
'Webinar:index#updatePSDataChannel --> enabled to receive relay events for practice session!'
|
|
476
466
|
);
|
|
477
467
|
|
|
478
468
|
return Promise.resolve(registerAndConnectResult);
|
|
479
469
|
})
|
|
480
470
|
.catch((error) => {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
} = this.webex.internal.llm.resolveSessionOwnership(this.meetingId, LLM_PRACTICE_SESSION);
|
|
485
|
-
|
|
486
|
-
if (isOwnerAfterRegisterFailure) {
|
|
487
|
-
// @ts-ignore - Fix type
|
|
488
|
-
this.webex.internal.llm.setOwnerMeetingId?.(undefined, LLM_PRACTICE_SESSION);
|
|
489
|
-
} else {
|
|
490
|
-
LoggerProxy.logger.info(
|
|
491
|
-
`Webinar:index#updatePSDataChannel --> skipping failure owner release; practice-session LLM owned by meeting ${currentOwnerAfterRegisterFailure}, not ${this.meetingId}`
|
|
492
|
-
);
|
|
471
|
+
// Clean up the channel on failure, but only if it's still the current one
|
|
472
|
+
if (this._practiceSessionLLMChannel === psChannel) {
|
|
473
|
+
this._practiceSessionLLMChannel = undefined;
|
|
493
474
|
}
|
|
494
|
-
|
|
495
475
|
throw error;
|
|
496
476
|
});
|
|
497
477
|
},
|