@webex/plugin-meetings 3.12.0-next.1 → 3.12.0-next.100

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.
Files changed (235) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +15 -2
  3. package/dist/aiEnableRequest/index.js.map +1 -1
  4. package/dist/breakouts/breakout.js +8 -3
  5. package/dist/breakouts/breakout.js.map +1 -1
  6. package/dist/breakouts/index.js +26 -2
  7. package/dist/breakouts/index.js.map +1 -1
  8. package/dist/common/errors/webex-errors.js +49 -5
  9. package/dist/common/errors/webex-errors.js.map +1 -1
  10. package/dist/config.js +2 -2
  11. package/dist/config.js.map +1 -1
  12. package/dist/constants.js +35 -9
  13. package/dist/constants.js.map +1 -1
  14. package/dist/controls-options-manager/constants.js +11 -1
  15. package/dist/controls-options-manager/constants.js.map +1 -1
  16. package/dist/controls-options-manager/index.js +67 -29
  17. package/dist/controls-options-manager/index.js.map +1 -1
  18. package/dist/controls-options-manager/util.js +91 -0
  19. package/dist/controls-options-manager/util.js.map +1 -1
  20. package/dist/hashTree/constants.js +13 -1
  21. package/dist/hashTree/constants.js.map +1 -1
  22. package/dist/hashTree/hashTreeParser.js +898 -391
  23. package/dist/hashTree/hashTreeParser.js.map +1 -1
  24. package/dist/hashTree/utils.js +42 -0
  25. package/dist/hashTree/utils.js.map +1 -1
  26. package/dist/index.js +7 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/interceptors/dataChannelAuthToken.js +75 -15
  29. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  30. package/dist/interceptors/locusRetry.js +23 -8
  31. package/dist/interceptors/locusRetry.js.map +1 -1
  32. package/dist/interpretation/index.js +10 -1
  33. package/dist/interpretation/index.js.map +1 -1
  34. package/dist/interpretation/interpretation.types.js +7 -0
  35. package/dist/interpretation/interpretation.types.js.map +1 -0
  36. package/dist/interpretation/siLanguage.js +1 -1
  37. package/dist/locus-info/controlsUtils.js +4 -1
  38. package/dist/locus-info/controlsUtils.js.map +1 -1
  39. package/dist/locus-info/index.js +401 -115
  40. package/dist/locus-info/index.js.map +1 -1
  41. package/dist/locus-info/infoUtils.js +36 -5
  42. package/dist/locus-info/infoUtils.js.map +1 -1
  43. package/dist/locus-info/types.js +19 -0
  44. package/dist/locus-info/types.js.map +1 -1
  45. package/dist/media/MediaConnectionAwaiter.js +15 -2
  46. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  47. package/dist/media/index.js +8 -2
  48. package/dist/media/index.js.map +1 -1
  49. package/dist/media/properties.js +1 -0
  50. package/dist/media/properties.js.map +1 -1
  51. package/dist/meeting/in-meeting-actions.js +5 -1
  52. package/dist/meeting/in-meeting-actions.js.map +1 -1
  53. package/dist/meeting/index.js +1444 -772
  54. package/dist/meeting/index.js.map +1 -1
  55. package/dist/meeting/locusMediaRequest.js +229 -82
  56. package/dist/meeting/locusMediaRequest.js.map +1 -1
  57. package/dist/meeting/muteState.js +10 -1
  58. package/dist/meeting/muteState.js.map +1 -1
  59. package/dist/meeting/request.js +5 -2
  60. package/dist/meeting/request.js.map +1 -1
  61. package/dist/meeting/util.js +35 -2
  62. package/dist/meeting/util.js.map +1 -1
  63. package/dist/meeting-info/meeting-info-v2.js +2 -2
  64. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  65. package/dist/meetings/index.js +231 -118
  66. package/dist/meetings/index.js.map +1 -1
  67. package/dist/meetings/meetings.types.js +6 -1
  68. package/dist/meetings/meetings.types.js.map +1 -1
  69. package/dist/meetings/request.js +39 -0
  70. package/dist/meetings/request.js.map +1 -1
  71. package/dist/meetings/util.js +116 -18
  72. package/dist/meetings/util.js.map +1 -1
  73. package/dist/member/index.js +10 -0
  74. package/dist/member/index.js.map +1 -1
  75. package/dist/member/types.js.map +1 -1
  76. package/dist/member/util.js +30 -0
  77. package/dist/member/util.js.map +1 -1
  78. package/dist/members/index.js +101 -43
  79. package/dist/members/index.js.map +1 -1
  80. package/dist/members/util.js +8 -1
  81. package/dist/members/util.js.map +1 -1
  82. package/dist/metrics/constants.js +10 -1
  83. package/dist/metrics/constants.js.map +1 -1
  84. package/dist/multistream/codec/constants.js +63 -0
  85. package/dist/multistream/codec/constants.js.map +1 -0
  86. package/dist/multistream/mediaRequestManager.js +62 -15
  87. package/dist/multistream/mediaRequestManager.js.map +1 -1
  88. package/dist/multistream/receiveSlot.js +9 -0
  89. package/dist/multistream/receiveSlot.js.map +1 -1
  90. package/dist/multistream/sendSlotManager.js +116 -2
  91. package/dist/multistream/sendSlotManager.js.map +1 -1
  92. package/dist/reachability/clusterReachability.js.map +1 -1
  93. package/dist/reachability/index.js +121 -83
  94. package/dist/reachability/index.js.map +1 -1
  95. package/dist/reachability/reachability.types.js +2 -0
  96. package/dist/reachability/reachability.types.js.map +1 -1
  97. package/dist/reachability/util.js +45 -0
  98. package/dist/reachability/util.js.map +1 -1
  99. package/dist/reactions/reactions.type.js.map +1 -1
  100. package/dist/recording-controller/index.js +1 -3
  101. package/dist/recording-controller/index.js.map +1 -1
  102. package/dist/roap/turnDiscovery.js +8 -1
  103. package/dist/roap/turnDiscovery.js.map +1 -1
  104. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  105. package/dist/types/config.d.ts +2 -2
  106. package/dist/types/constants.d.ts +12 -1
  107. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  108. package/dist/types/controls-options-manager/index.d.ts +16 -0
  109. package/dist/types/hashTree/constants.d.ts +2 -0
  110. package/dist/types/hashTree/hashTreeParser.d.ts +146 -17
  111. package/dist/types/hashTree/utils.d.ts +18 -0
  112. package/dist/types/index.d.ts +3 -0
  113. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  114. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  115. package/dist/types/locus-info/index.d.ts +59 -6
  116. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  117. package/dist/types/locus-info/types.d.ts +21 -1
  118. package/dist/types/media/MediaConnectionAwaiter.d.ts +10 -1
  119. package/dist/types/media/properties.d.ts +1 -0
  120. package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
  121. package/dist/types/meeting/index.d.ts +143 -9
  122. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  123. package/dist/types/meeting/request.d.ts +1 -0
  124. package/dist/types/meeting/util.d.ts +9 -0
  125. package/dist/types/meetings/index.d.ts +30 -18
  126. package/dist/types/meetings/meetings.types.d.ts +15 -0
  127. package/dist/types/meetings/request.d.ts +14 -0
  128. package/dist/types/member/index.d.ts +1 -0
  129. package/dist/types/member/types.d.ts +1 -0
  130. package/dist/types/member/util.d.ts +9 -0
  131. package/dist/types/members/index.d.ts +15 -2
  132. package/dist/types/members/util.d.ts +1 -5
  133. package/dist/types/metrics/constants.d.ts +9 -0
  134. package/dist/types/multistream/codec/constants.d.ts +7 -0
  135. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  136. package/dist/types/multistream/sendSlotManager.d.ts +23 -1
  137. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  138. package/dist/types/reachability/index.d.ts +10 -3
  139. package/dist/types/reachability/reachability.types.d.ts +7 -0
  140. package/dist/types/reachability/util.d.ts +17 -0
  141. package/dist/types/reactions/reactions.type.d.ts +3 -0
  142. package/dist/webinar/index.js +485 -234
  143. package/dist/webinar/index.js.map +1 -1
  144. package/package.json +22 -22
  145. package/src/aiEnableRequest/index.ts +16 -0
  146. package/src/breakouts/breakout.ts +3 -1
  147. package/src/breakouts/index.ts +31 -0
  148. package/src/common/errors/webex-errors.ts +50 -3
  149. package/src/config.ts +2 -2
  150. package/src/constants.ts +20 -3
  151. package/src/controls-options-manager/constants.ts +14 -1
  152. package/src/controls-options-manager/index.ts +87 -28
  153. package/src/controls-options-manager/util.ts +81 -1
  154. package/src/hashTree/constants.ts +16 -0
  155. package/src/hashTree/hashTreeParser.ts +596 -204
  156. package/src/hashTree/utils.ts +36 -0
  157. package/src/index.ts +6 -0
  158. package/src/interceptors/dataChannelAuthToken.ts +88 -12
  159. package/src/interceptors/locusRetry.ts +25 -4
  160. package/src/interpretation/index.ts +27 -9
  161. package/src/interpretation/interpretation.types.ts +11 -0
  162. package/src/locus-info/controlsUtils.ts +3 -1
  163. package/src/locus-info/index.ts +415 -136
  164. package/src/locus-info/infoUtils.ts +41 -6
  165. package/src/locus-info/types.ts +25 -1
  166. package/src/media/MediaConnectionAwaiter.ts +21 -4
  167. package/src/media/index.ts +10 -1
  168. package/src/media/properties.ts +1 -0
  169. package/src/meeting/in-meeting-actions.ts +8 -0
  170. package/src/meeting/index.ts +790 -136
  171. package/src/meeting/locusMediaRequest.ts +106 -6
  172. package/src/meeting/muteState.ts +10 -1
  173. package/src/meeting/request.ts +11 -0
  174. package/src/meeting/util.ts +47 -5
  175. package/src/meeting-info/meeting-info-v2.ts +4 -2
  176. package/src/meetings/index.ts +133 -78
  177. package/src/meetings/meetings.types.ts +19 -0
  178. package/src/meetings/request.ts +43 -0
  179. package/src/meetings/util.ts +117 -4
  180. package/src/member/index.ts +10 -0
  181. package/src/member/types.ts +1 -0
  182. package/src/member/util.ts +29 -0
  183. package/src/members/index.ts +70 -7
  184. package/src/members/util.ts +12 -4
  185. package/src/metrics/constants.ts +10 -0
  186. package/src/multistream/codec/constants.ts +58 -0
  187. package/src/multistream/mediaRequestManager.ts +119 -28
  188. package/src/multistream/receiveSlot.ts +18 -0
  189. package/src/multistream/sendSlotManager.ts +97 -3
  190. package/src/reachability/clusterReachability.ts +3 -2
  191. package/src/reachability/index.ts +47 -16
  192. package/src/reachability/reachability.types.ts +11 -0
  193. package/src/reachability/util.ts +36 -0
  194. package/src/reactions/reactions.type.ts +3 -0
  195. package/src/recording-controller/index.ts +1 -2
  196. package/src/roap/turnDiscovery.ts +9 -1
  197. package/src/webinar/index.ts +330 -50
  198. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  199. package/test/unit/spec/breakouts/breakout.ts +9 -3
  200. package/test/unit/spec/breakouts/index.ts +49 -0
  201. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  202. package/test/unit/spec/controls-options-manager/index.js +244 -29
  203. package/test/unit/spec/controls-options-manager/util.js +165 -0
  204. package/test/unit/spec/hashTree/hashTreeParser.ts +1911 -143
  205. package/test/unit/spec/hashTree/utils.ts +125 -1
  206. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +196 -0
  207. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  208. package/test/unit/spec/interpretation/index.ts +26 -4
  209. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  210. package/test/unit/spec/locus-info/index.js +645 -80
  211. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  212. package/test/unit/spec/media/MediaConnectionAwaiter.ts +55 -0
  213. package/test/unit/spec/media/index.ts +92 -0
  214. package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
  215. package/test/unit/spec/meeting/index.js +2261 -109
  216. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  217. package/test/unit/spec/meeting/muteState.js +81 -0
  218. package/test/unit/spec/meeting/request.js +12 -0
  219. package/test/unit/spec/meeting/utils.js +157 -1
  220. package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
  221. package/test/unit/spec/meetings/index.js +366 -39
  222. package/test/unit/spec/meetings/request.js +141 -0
  223. package/test/unit/spec/meetings/utils.js +402 -51
  224. package/test/unit/spec/member/index.js +7 -0
  225. package/test/unit/spec/member/util.js +89 -0
  226. package/test/unit/spec/members/index.js +216 -0
  227. package/test/unit/spec/members/request.js +37 -1
  228. package/test/unit/spec/members/utils.js +63 -0
  229. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  230. package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
  231. package/test/unit/spec/reachability/index.ts +128 -46
  232. package/test/unit/spec/reachability/util.ts +31 -0
  233. package/test/unit/spec/recording-controller/index.js +9 -8
  234. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  235. package/test/unit/spec/webinar/index.ts +516 -30
@@ -34,6 +34,7 @@ import BEHAVIORAL_METRICS from '../metrics/constants';
34
34
  import HashTreeParser, {
35
35
  DataSet,
36
36
  HashTreeMessage,
37
+ LocusInfoUpdate,
37
38
  LocusInfoUpdateType,
38
39
  Metadata,
39
40
  } from '../hashTree/hashTreeParser';
@@ -97,7 +98,7 @@ export type HashTreeParserEntry = {
97
98
  * Gets the replacement information
98
99
  *
99
100
  * @param {any} self - "self" object from Locus DTO
100
- * @param {string} deviceUrl - The URL of the user's device
101
+ * @param {string} deviceUrl - The URL of the specified device
101
102
  * @returns {any} The replace information if available, otherwise undefined
102
103
  */
103
104
  function getReplaceInfoFromSelf(self: any, deviceUrl: string): ReplacesInfo | undefined {
@@ -137,14 +138,15 @@ function findLocusUrlInAnyHashTreeParser(
137
138
  *
138
139
  * @param {HashTreeMessage} message - The hash tree message to find the meeting for
139
140
  * @param {MeetingCollection} meetingCollection - The collection of meetings to search
140
- * @param {string} deviceUrl - The URL of the user's device
141
141
  * @returns {any} The meeting if found, otherwise undefined
142
142
  */
143
143
  export function findMeetingForHashTreeMessage(
144
- message: HashTreeMessage,
145
- meetingCollection: MeetingCollection,
146
- deviceUrl: string
144
+ message: HashTreeMessage | undefined,
145
+ meetingCollection: MeetingCollection
147
146
  ): any {
147
+ if (!message) {
148
+ return undefined;
149
+ }
148
150
  let foundMeeting = findLocusUrlInAnyHashTreeParser(meetingCollection, message.locusUrl);
149
151
 
150
152
  if (foundMeeting) {
@@ -154,7 +156,7 @@ export function findMeetingForHashTreeMessage(
154
156
  // if we haven't found anything, it may mean that message has a new locusUrl
155
157
  // check if it indicates that it replaces some existing current locusUrl (this is indicated in "self")
156
158
  const self = message.locusStateElements?.find((el) => isSelf(el))?.data;
157
- const replaces = getReplaceInfoFromSelf(self, deviceUrl);
159
+ const replaces = getReplaceInfoFromSelf(self, self?.deviceUrl);
158
160
 
159
161
  if (replaces?.locusUrl) {
160
162
  foundMeeting = findLocusUrlInAnyHashTreeParser(meetingCollection, replaces.locusUrl);
@@ -284,6 +286,7 @@ export default class LocusInfo extends EventsScope {
284
286
  hashTreeParsers: Map<string, HashTreeParserEntry>;
285
287
  hashTreeObjectId2ParticipantId: Map<number, string>; // mapping of hash tree object ids to participant ids
286
288
  classicVsHashTreeMismatchMetricCounter = 0;
289
+ private destroyMeetingSuspended = false;
287
290
 
288
291
  /**
289
292
  * Constructor
@@ -516,7 +519,7 @@ export default class LocusInfo extends EventsScope {
516
519
  this.updateControls(locus.controls, locus.self);
517
520
  this.updateLocusUrl(locus.url, ControlsUtils.isMainSessionDTO(locus));
518
521
  this.updateFullState(locus.fullState);
519
- this.updateMeetingInfo(locus.info);
522
+ this.updateMeetingInfo(locus.info, locus.self);
520
523
  this.updateEmbeddedApps(locus.embeddedApps);
521
524
  // self and participants generate sipUrl for 1:1 meeting
522
525
  this.updateSelf(locus.self);
@@ -545,7 +548,7 @@ export default class LocusInfo extends EventsScope {
545
548
  dataSets: Array<DataSet>;
546
549
  locus: any;
547
550
  };
548
- metadata: Metadata;
551
+ metadata: Metadata | null;
549
552
  replacedAt?: string;
550
553
  }): HashTreeParser {
551
554
  const parser = new HashTreeParser({
@@ -553,7 +556,7 @@ export default class LocusInfo extends EventsScope {
553
556
  metadata,
554
557
  webexRequest: this.webex.request.bind(this.webex),
555
558
  locusInfoUpdateCallback: this.updateFromHashTree.bind(this, locusUrl),
556
- debugId: `HT-${locusUrl.split('/').pop().substring(0, 4)}`,
559
+ debugId: `HT-${locusUrl.split('/')?.pop()?.substring(0, 4)}`,
557
560
  excludedDataSets: this.webex.config.meetings.locus?.excludedDataSets,
558
561
  });
559
562
 
@@ -580,6 +583,7 @@ export default class LocusInfo extends EventsScope {
580
583
 
581
584
  /**
582
585
  * @param {Object} data - data to initialize locus info with. It may be from a join or GET /loci response or from a Mercury event that triggers a creation of meeting object
586
+ * @param {Function} [onLocusSynced] - optional callback that will be called at the end of initial setup, when locus info is fully synced. It will be called with the full locus snapshot as an argument (which may be null if we haven't received any full locus DTOs during the initial setup, for example in case we receive only hash tree messages without full locus DTOs)
583
587
  * @returns {undefined}
584
588
  * @memberof LocusInfo
585
589
  */
@@ -599,8 +603,10 @@ export default class LocusInfo extends EventsScope {
599
603
  | {
600
604
  trigger: 'get-loci-response';
601
605
  locus?: LocusDTO;
602
- }
606
+ },
607
+ onLocusSynced?: (locus: LocusDTO) => void
603
608
  ) {
609
+ let initialFullLocus: LocusDTO | null = null;
604
610
  switch (data.trigger) {
605
611
  case 'locus-message':
606
612
  if (data.hashTreeMessage) {
@@ -648,6 +654,7 @@ export default class LocusInfo extends EventsScope {
648
654
  case 'join-response':
649
655
  this.updateLocusCache(data.locus);
650
656
  this.onFullLocus('join response', data.locus, undefined, data.dataSets, data.metadata);
657
+ initialFullLocus = data.locus;
651
658
  break;
652
659
  case 'get-loci-response':
653
660
  if (data.locus?.links?.resources?.visibleDataSets?.url) {
@@ -656,7 +663,7 @@ export default class LocusInfo extends EventsScope {
656
663
  );
657
664
  // first create the HashTreeParser, but don't initialize it with any data yet
658
665
  const hashTreeParser = this.createHashTreeParser({
659
- locusUrl: data.locus.url,
666
+ locusUrl: data.locus.url as string,
660
667
  initialLocus: {
661
668
  locus: null,
662
669
  dataSets: [], // empty, because we don't have them yet
@@ -670,52 +677,99 @@ export default class LocusInfo extends EventsScope {
670
677
  // "classic" Locus case, no hash trees involved
671
678
  this.updateLocusCache(data.locus);
672
679
  this.onFullLocus('classic get-loci-response', data.locus, undefined);
680
+ initialFullLocus = data.locus || null;
673
681
  }
674
682
  }
683
+
684
+ if (onLocusSynced) {
685
+ try {
686
+ onLocusSynced(initialFullLocus || this.getCurrentLocusSnapshot());
687
+ } catch (error) {
688
+ LoggerProxy.logger.warn(
689
+ `Locus-info:index#initialSetup --> onLocusSynced callback failed: ${error}`
690
+ );
691
+ }
692
+ }
693
+
675
694
  // Change it to true after it receives it first locus object
676
695
  this.emitChange = true;
677
696
  }
678
697
 
698
+ /**
699
+ * Builds a full locus DTO snapshot from current internal locus state.
700
+ *
701
+ * @returns {LocusDTO}
702
+ */
703
+ private getCurrentLocusSnapshot(): LocusDTO {
704
+ const locus: Record<string, any> = {};
705
+
706
+ LocusDtoTopLevelKeys.forEach((key) => {
707
+ const value = (this as Record<string, any>)[key];
708
+
709
+ if (value !== undefined && value !== null) {
710
+ locus[key] = cloneDeep(value);
711
+ }
712
+ });
713
+
714
+ if (!Array.isArray(locus.participants)) {
715
+ locus.participants = [];
716
+ }
717
+
718
+ return locus as LocusDTO;
719
+ }
720
+
679
721
  /**
680
722
  * Handles HTTP response from Locus API call.
681
723
  * @param {Meeting} meeting meeting object
682
724
  * @param {LocusApiResponseBody} responseBody body of the http response from Locus API call
683
725
  * @returns {void}
684
726
  */
685
- handleLocusAPIResponse(meeting, responseBody: LocusApiResponseBody): void {
727
+ handleLocusAPIResponse(meeting: any, responseBody: LocusApiResponseBody): void {
686
728
  const isWrapped = 'locus' in responseBody;
687
729
  const locusUrl = isWrapped ? responseBody.locus?.url : responseBody.url;
688
730
  const hashTreeParserEntry = locusUrl && this.hashTreeParsers.get(locusUrl);
689
- if (hashTreeParserEntry) {
690
- if (isWrapped) {
691
- if (!responseBody.dataSets) {
692
- this.sendClassicVsHashTreeMismatchMetric(
693
- meeting,
694
- `expected hash tree dataSets in API response but they are missing`
731
+ const locus = isWrapped
732
+ ? (responseBody as {locus: LocusDTO}).locus
733
+ : (responseBody as LocusDTO);
734
+
735
+ if (this.hashTreeParsers.size > 0) {
736
+ // We are in hash tree mode. Check if we need to create/reactivate a parser for this locusUrl.
737
+ if (!hashTreeParserEntry || hashTreeParserEntry.parser.state === 'stopped') {
738
+ if (!locusUrl) {
739
+ LoggerProxy.logger.warn(
740
+ 'Locus-info:index#handleLocusAPIResponse --> API response has no locusUrl, cannot handle hash tree parser switch'
695
741
  );
696
- // continuing as we can still manage without responseBody.dataSets, but this is very suspicious
742
+
743
+ return;
697
744
  }
698
- LoggerProxy.logger.info(
699
- 'Locus-info:index#handleLocusAPIResponse --> passing Locus API response to HashTreeParser: ',
700
- responseBody
701
- );
745
+
746
+ this.handleHashTreeParserSwitchForAPIResponse(locusUrl, locus);
747
+
748
+ return;
749
+ }
750
+
751
+ // Active parser found - pass the API response to it
752
+ if (isWrapped) {
702
753
  // update the data in our hash trees
703
754
  hashTreeParserEntry.parser.handleLocusUpdate(responseBody);
704
755
  } else {
705
- // LocusDTO without wrapper - pass it through as if it had no dataSets
756
+ // LocusDTO without wrapper - pass it through as if it had no dataSets nor metadata
706
757
  hashTreeParserEntry.parser.handleLocusUpdate({locus: responseBody});
707
758
  }
708
- } else {
709
- if (isWrapped && responseBody.dataSets) {
710
- this.sendClassicVsHashTreeMismatchMetric(
711
- meeting,
712
- `unexpected hash tree dataSets in API response`
713
- );
714
- }
715
- // classic Locus delta
716
- const locus = isWrapped ? responseBody.locus : responseBody;
717
- this.handleLocusDelta(locus, meeting);
759
+
760
+ return;
761
+ }
762
+
763
+ // No hash tree parsers - classic Locus mode
764
+ if (isWrapped && responseBody.dataSets) {
765
+ this.sendClassicVsHashTreeMismatchMetric(
766
+ meeting,
767
+ `unexpected hash tree dataSets in API response`
768
+ );
718
769
  }
770
+
771
+ // classic Locus delta
772
+ this.handleLocusDelta(locus, meeting);
719
773
  }
720
774
 
721
775
  /**
@@ -877,14 +931,22 @@ export default class LocusInfo extends EventsScope {
877
931
  if (!object.data) {
878
932
  // self without data is handled inside HashTreeParser and results in LocusInfoUpdateType.MEETING_ENDED, so we should never get here
879
933
  // all other types info, fullstate, etc - Locus should never send them without data
880
- LoggerProxy.logger.warn(
881
- `Locus-info:index#updateLocusFromHashTreeObject --> received ${type} object without data, this is not expected! version=${object.htMeta.elementId.version}`
934
+ // but we end up with this method being called without the data for them when the main dataset is removed from visible datasets list
935
+ LoggerProxy.logger.info(
936
+ `Locus-info:index#updateLocusFromHashTreeObject --> received ${type} object without data, version=${object.htMeta.elementId.version}`
882
937
  );
883
938
  } else {
884
939
  LoggerProxy.logger.info(
885
940
  `Locus-info:index#updateLocusFromHashTreeObject --> ${type} object updated to version ${object.htMeta.elementId.version}`
886
941
  );
887
- const locusDtoKey = ObjectTypeToLocusKeyMap[type];
942
+
943
+ if (type === ObjectType.self) {
944
+ LoggerProxy.logger.info(
945
+ `Locus-info:index#updateLocusFromHashTreeObject --> self data: removed=${object.data.removed} state=${object.data.state} reason=${object.data.reason}`
946
+ );
947
+ }
948
+
949
+ const locusDtoKey = ObjectTypeToLocusKeyMap[type] as keyof LocusDTO;
888
950
  locus[locusDtoKey] = object.data;
889
951
 
890
952
  /* Hash tree based webinar attendees don't receive a Participant object for themselves from Locus,
@@ -944,6 +1006,114 @@ export default class LocusInfo extends EventsScope {
944
1006
  }
945
1007
  }
946
1008
 
1009
+ /**
1010
+ * Helper that handles the common logic for reactivating a stopped HashTreeParser when
1011
+ * a newer "replaces" is detected. Used by both the message and API response parser switch methods.
1012
+ *
1013
+ * @param {string} callerName - name of the calling method, used in log messages
1014
+ * @param {string} locusUrl - the locus URL of the stopped parser
1015
+ * @param {HashTreeParserEntry} stoppedEntry - the stopped parser entry
1016
+ * @param {ReplacesInfo} replaces - replacement info extracted from self
1017
+ * @param {Function} resumeCallback - callback to invoke after reactivation to resume the parser
1018
+ * @returns {void}
1019
+ */
1020
+ private resumeStoppedParser(
1021
+ callerName: string,
1022
+ locusUrl: string,
1023
+ stoppedEntry: HashTreeParserEntry,
1024
+ replaces: ReplacesInfo | undefined,
1025
+ resumeCallback: () => void
1026
+ ): void {
1027
+ // this check is just for typescript, it should never happen, replaces should always be defined
1028
+ if (!replaces) {
1029
+ LoggerProxy.logger.info(
1030
+ `Locus-info:index#${callerName} --> received data for stopped HashTreeParser with locusUrl ${locusUrl}, but no replaces info provided, so not re-activating the parser`
1031
+ );
1032
+
1033
+ return;
1034
+ }
1035
+
1036
+ if (replaces.replacedAt <= (stoppedEntry.replacedAt || '')) {
1037
+ LoggerProxy.logger.info(
1038
+ `Locus-info:index#${callerName} --> received data for stopped HashTreeParser with locusUrl ${locusUrl}, but replaces info provided is not newer, so not re-activating the parser`
1039
+ );
1040
+
1041
+ return;
1042
+ }
1043
+
1044
+ LoggerProxy.logger.info(
1045
+ `Locus-info:index#${callerName} --> reactivating HashTreeParser for locusUrl=${locusUrl}, which replaces ${replaces.locusUrl}`
1046
+ );
1047
+
1048
+ const replacedEntry = this.hashTreeParsers.get(replaces.locusUrl);
1049
+
1050
+ if (replacedEntry) {
1051
+ replacedEntry.replacedAt = replaces.replacedAt;
1052
+ replacedEntry.parser.stop();
1053
+ } else {
1054
+ LoggerProxy.logger.warn(
1055
+ `Locus-info:index#${callerName} --> the parser that is supposed to be replaced with the currently reactivated parser is not found, locusUrl=${replaces.locusUrl}`
1056
+ );
1057
+ }
1058
+
1059
+ stoppedEntry.initializedFromHashTree = false;
1060
+ this.hashTreeObjectId2ParticipantId.clear();
1061
+
1062
+ resumeCallback();
1063
+ }
1064
+
1065
+ /**
1066
+ * Handles an API response whose locusUrl doesn't match any active HashTreeParser
1067
+ * (either no entry exists, or the existing entry is stopped).
1068
+ * Creates a new parser or reactivates a stopped one using initializeFromGetLociResponse.
1069
+ *
1070
+ * @param {string} locusUrl - the locus URL from the API response
1071
+ * @param {LocusDTO} locus - the locus DTO from the API response
1072
+ * @returns {void}
1073
+ */
1074
+ private handleHashTreeParserSwitchForAPIResponse(locusUrl: string, locus: LocusDTO): void {
1075
+ const entry = this.hashTreeParsers.get(locusUrl);
1076
+
1077
+ const replaces = getReplaceInfoFromSelf(
1078
+ locus.self,
1079
+ // @ts-ignore
1080
+ this.webex.internal.device.url
1081
+ );
1082
+
1083
+ if (!entry) {
1084
+ LoggerProxy.logger.info(
1085
+ `Locus-info:index#handleHashTreeParserSwitchForAPIResponse --> no parser for locusUrl ${locusUrl}, creating a new one`
1086
+ );
1087
+
1088
+ const parser = this.createHashTreeParser({
1089
+ locusUrl,
1090
+ initialLocus: {locus: null, dataSets: []},
1091
+ metadata: null,
1092
+ replacedAt: replaces?.replacedAt,
1093
+ });
1094
+
1095
+ parser.initializeFromGetLociResponse(locus);
1096
+
1097
+ return;
1098
+ }
1099
+
1100
+ if (entry.parser.state !== 'stopped') {
1101
+ LoggerProxy.logger.warn(
1102
+ `Locus-info:index#handleHashTreeParserSwitchForAPIResponse --> unexpected parser state "${entry.parser.state}" for locusUrl ${locusUrl}`
1103
+ );
1104
+
1105
+ return;
1106
+ }
1107
+
1108
+ this.resumeStoppedParser(
1109
+ 'handleHashTreeParserSwitchForAPIResponse',
1110
+ locusUrl,
1111
+ entry,
1112
+ replaces,
1113
+ () => entry.parser.resumeFromApiResponse(locus)
1114
+ );
1115
+ }
1116
+
947
1117
  /**
948
1118
  * Checks if the hash tree message should trigger a switch to a different HashTreeParser
949
1119
  *
@@ -965,7 +1135,7 @@ export default class LocusInfo extends EventsScope {
965
1135
  // but it's buried inside the message, we need to find it and pass it to HashTreeParser constructor
966
1136
  const metadata = message.locusStateElements?.find((el) => isMetadata(el));
967
1137
 
968
- if (metadata?.data?.visibleDataSets?.length > 0) {
1138
+ if (metadata && metadata.data?.visibleDataSets?.length > 0) {
969
1139
  LoggerProxy.logger.info(
970
1140
  `Locus-info:index#handleHashTreeParserSwitch --> no hash tree parser found for locusUrl ${message.locusUrl}, creating a new one`
971
1141
  );
@@ -992,36 +1162,12 @@ export default class LocusInfo extends EventsScope {
992
1162
  if (entry.parser.state === 'stopped') {
993
1163
  // the message matches a stopped parser, we need to check if maybe this is a new "replacement" and we need to re-activate the parser
994
1164
  // this happens when you move from breakout A -> breakout B -> back to breakout A
995
- if (replaces) {
996
- if (replaces.replacedAt > (entry.replacedAt || '')) {
997
- LoggerProxy.logger.info(
998
- `Locus-info:index#handleHashTreeParserSwitch --> resuming a HashTreeParser for locusUrl=${message.locusUrl}, which replaces ${replaces.locusUrl}`
999
- );
1000
- const replacedEntry = this.hashTreeParsers.get(replaces.locusUrl);
1001
-
1002
- if (replacedEntry) {
1003
- replacedEntry.replacedAt = replaces.replacedAt;
1004
- entry.initializedFromHashTree = false;
1005
- this.hashTreeObjectId2ParticipantId.clear();
1006
-
1007
- replacedEntry.parser.stop();
1008
- entry.parser.resume(message);
1009
- } else {
1010
- LoggerProxy.logger.warn(
1011
- `Locus-info:index#handleHashTreeParserSwitch --> the parser that is supposed to be replaced with the currently resumed parser is not found, locusUrl=${replaces.locusUrl}`
1012
- );
1013
- }
1014
- } else {
1015
- LoggerProxy.logger.info(
1016
- `Locus-info:index#handleHashTreeParserSwitch --> received message for stopped HashTreeParser with locusUrl ${message.locusUrl}, but replaces info provided is not newer, so not re-activating the parser`
1017
- );
1018
- }
1019
-
1020
- return true;
1021
- }
1022
-
1023
- LoggerProxy.logger.info(
1024
- `Locus-info:index#handleHashTreeParserSwitch --> received message for stopped HashTreeParser with locusUrl ${message.locusUrl}, but no replaces info provided, so not re-activating the parser`
1165
+ this.resumeStoppedParser(
1166
+ 'handleHashTreeParserSwitch',
1167
+ message.locusUrl,
1168
+ entry,
1169
+ replaces,
1170
+ () => entry.parser.resumeFromMessage(message)
1025
1171
  );
1026
1172
 
1027
1173
  return true;
@@ -1056,7 +1202,27 @@ export default class LocusInfo extends EventsScope {
1056
1202
 
1057
1203
  const entry = this.hashTreeParsers.get(message.locusUrl);
1058
1204
 
1059
- entry.parser.handleMessage(message);
1205
+ // the check is just for typescript, the case of no entry in hashTreeParsers is handled in handleHashTreeParserSwitch() above
1206
+ if (entry) {
1207
+ entry.parser.handleMessage(message);
1208
+ }
1209
+ }
1210
+
1211
+ /**
1212
+ * Triggers a sync of all hash tree datasets for all hash tree parsers associated with this meeting.
1213
+ * The syncs are executed sequentially within each parser.
1214
+ *
1215
+ * @param {Object} [options={}] - Options for syncing
1216
+ * @param {boolean} [options.onlyLLM=false] - Whether to sync only LLM based data sets
1217
+ * @returns {Promise<void>}
1218
+ */
1219
+ async syncAllHashTreeDatasets(options: {onlyLLM?: boolean} = {}): Promise<void> {
1220
+ for (const [, entry] of this.hashTreeParsers) {
1221
+ if (entry.parser) {
1222
+ // eslint-disable-next-line no-await-in-loop
1223
+ await entry.parser.syncAllDatasets(options);
1224
+ }
1225
+ }
1060
1226
  }
1061
1227
 
1062
1228
  /**
@@ -1064,16 +1230,11 @@ export default class LocusInfo extends EventsScope {
1064
1230
  * Updates our locus info based on the data parsed by the hash tree parser.
1065
1231
  *
1066
1232
  * @param {string} locusUrl - the locus URL for which the update is received
1067
- * @param {LocusInfoUpdateType} updateType - The type of update received.
1068
- * @param {Object} [data] - Additional data for the update, if applicable.
1233
+ * @param {LocusInfoUpdate} update - Details about the update.
1069
1234
  * @returns {void}
1070
1235
  */
1071
- private updateFromHashTree(
1072
- locusUrl: string,
1073
- updateType: LocusInfoUpdateType,
1074
- data?: {updatedObjects: HashTreeObject[]}
1075
- ) {
1076
- switch (updateType) {
1236
+ private updateFromHashTree(locusUrl: string, update: LocusInfoUpdate) {
1237
+ switch (update.updateType) {
1077
1238
  case LocusInfoUpdateType.OBJECTS_UPDATED: {
1078
1239
  // initialize our new locus
1079
1240
  let locus: LocusDTO = {
@@ -1087,7 +1248,7 @@ export default class LocusInfo extends EventsScope {
1087
1248
  // first go over all the updates and check what happens with the main locus object
1088
1249
  let locusObjectStateAfterUpdates: LocusObjectStateAfterUpdates =
1089
1250
  LocusObjectStateAfterUpdates.unchanged;
1090
- data.updatedObjects.forEach((object) => {
1251
+ update.updatedObjects.forEach((object) => {
1091
1252
  if (object.htMeta.elementId.type.toLowerCase() === ObjectType.locus) {
1092
1253
  if (locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.updated) {
1093
1254
  // this code doesn't supported it right now,
@@ -1116,6 +1277,14 @@ export default class LocusInfo extends EventsScope {
1116
1277
 
1117
1278
  const hashTreeParserEntry = this.hashTreeParsers.get(locusUrl);
1118
1279
 
1280
+ if (!hashTreeParserEntry) {
1281
+ LoggerProxy.logger.warn(
1282
+ `Locus-info:index#updateFromHashTree --> no HashTreeParser found for locusUrl ${locusUrl} when trying to apply updates from hash tree`
1283
+ );
1284
+
1285
+ return;
1286
+ }
1287
+
1119
1288
  if (!hashTreeParserEntry.initializedFromHashTree) {
1120
1289
  // this is the first time we're getting an update for this locusUrl,
1121
1290
  // so it's probably a move to/from breakout. We need to start from a clean state,
@@ -1124,7 +1293,8 @@ export default class LocusInfo extends EventsScope {
1124
1293
  `Locus-info:index#updateFromHashTree --> first INITIAL update for locusUrl ${locusUrl}, starting from empty state`
1125
1294
  );
1126
1295
  hashTreeParserEntry.initializedFromHashTree = true;
1127
- locus.jsSdkMeta.forceReplaceMembers = true;
1296
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1297
+ locus.jsSdkMeta!.forceReplaceMembers = true;
1128
1298
  } else if (
1129
1299
  // if Locus object is unchanged or removed, we need to keep using the existing locus
1130
1300
  // because the rest of the locusInfo code expects locus to always be present (with at least some of the fields)
@@ -1137,7 +1307,7 @@ export default class LocusInfo extends EventsScope {
1137
1307
  // copy over all of existing locus except participants
1138
1308
  LocusDtoTopLevelKeys.forEach((key) => {
1139
1309
  if (key !== 'participants') {
1140
- locus[key] = cloneDeep(this[key]);
1310
+ (locus as Record<string, any>)[key] = cloneDeep((this as Record<string, any>)[key]);
1141
1311
  }
1142
1312
  });
1143
1313
  } else {
@@ -1145,14 +1315,16 @@ export default class LocusInfo extends EventsScope {
1145
1315
  // (except participants, which need to stay empty - that means "no participant changes")
1146
1316
  Object.values(ObjectTypeToLocusKeyMap).forEach((locusDtoKey) => {
1147
1317
  if (locusDtoKey !== 'participants') {
1148
- locus[locusDtoKey] = cloneDeep(this[locusDtoKey]);
1318
+ (locus as Record<string, any>)[locusDtoKey] = cloneDeep(
1319
+ (this as Record<string, any>)[locusDtoKey]
1320
+ );
1149
1321
  }
1150
1322
  });
1151
1323
  }
1152
1324
 
1153
1325
  LoggerProxy.logger.info(
1154
1326
  `Locus-info:index#updateFromHashTree --> LOCUS object is ${locusObjectStateAfterUpdates}, all updates: ${JSON.stringify(
1155
- data.updatedObjects.map((o) => ({
1327
+ update.updatedObjects.map((o) => ({
1156
1328
  type: o.htMeta.elementId.type,
1157
1329
  id: o.htMeta.elementId.id,
1158
1330
  hasData: !!o.data,
@@ -1160,7 +1332,7 @@ export default class LocusInfo extends EventsScope {
1160
1332
  )}`
1161
1333
  );
1162
1334
  // now apply all the updates from the hash tree onto the locus
1163
- data.updatedObjects.forEach((object) => {
1335
+ update.updatedObjects.forEach((object) => {
1164
1336
  locus = this.updateLocusFromHashTreeObject(object, locus);
1165
1337
  });
1166
1338
 
@@ -1179,6 +1351,21 @@ export default class LocusInfo extends EventsScope {
1179
1351
  );
1180
1352
  this.webex.meetings.destroy(meeting, MEETING_REMOVED_REASON.SELF_REMOVED);
1181
1353
  }
1354
+ break;
1355
+ }
1356
+
1357
+ case LocusInfoUpdateType.LOCUS_NOT_FOUND: {
1358
+ LoggerProxy.logger.info(
1359
+ `Locus-info:index#updateFromHashTree --> received LOCUS_NOT_FOUND for ${locusUrl}, triggering syncMeetings`
1360
+ );
1361
+ this.webex.meetings
1362
+ .syncMeetings({keepOnlyLocusMeetings: false, skipHashTreeSync: true})
1363
+ .catch((syncError) => {
1364
+ LoggerProxy.logger.error(
1365
+ `Locus-info:index#updateFromHashTree --> syncMeetings failed after LOCUS_NOT_FOUND: ${syncError}`
1366
+ );
1367
+ });
1368
+ break;
1182
1369
  }
1183
1370
  }
1184
1371
  }
@@ -1191,11 +1378,17 @@ export default class LocusInfo extends EventsScope {
1191
1378
  */
1192
1379
  parse(meeting: any, data: any) {
1193
1380
  if (this.hashTreeParsers.size > 0) {
1194
- this.handleHashTreeMessage(
1195
- meeting,
1196
- data.eventType,
1197
- data.stateElementsMessage as HashTreeMessage
1198
- );
1381
+ if (data.eventType === LOCUSEVENT.SDK_LOCUS_FROM_SYNC_MEETINGS) {
1382
+ // sync meetings response follows the format of "not wrapped" locus API responses,
1383
+ // so has no dataSets nor Metadata
1384
+ this.handleLocusAPIResponse(meeting, {...data.locus});
1385
+ } else {
1386
+ this.handleHashTreeMessage(
1387
+ meeting,
1388
+ data.eventType,
1389
+ data.stateElementsMessage as HashTreeMessage
1390
+ );
1391
+ }
1199
1392
  } else {
1200
1393
  const {eventType} = data;
1201
1394
 
@@ -1260,16 +1453,16 @@ export default class LocusInfo extends EventsScope {
1260
1453
  * @param {string} debugText string explaining the trigger for this call, added to logs for debugging purposes
1261
1454
  * @param {object} locus locus object
1262
1455
  * @param {object} metadata locus hash trees metadata
1263
- * @param {string} eventType locus event
1264
1456
  * @param {DataSet[]} dataSets
1457
+ * @param {string} eventType locus event
1265
1458
  * @returns {void}
1266
1459
  */
1267
1460
  private onFullLocusWithHashTrees(
1268
1461
  debugText: string,
1269
1462
  locus: any,
1270
1463
  metadata: Metadata,
1271
- eventType?: string,
1272
- dataSets?: Array<DataSet>
1464
+ dataSets: Array<DataSet>,
1465
+ eventType?: string
1273
1466
  ) {
1274
1467
  if (!this.hashTreeParsers.has(locus.url)) {
1275
1468
  LoggerProxy.logger.info(
@@ -1289,7 +1482,8 @@ export default class LocusInfo extends EventsScope {
1289
1482
  metadata,
1290
1483
  });
1291
1484
  // we have a full locus to start with, so we consider Locus info to be "initialized"
1292
- this.hashTreeParsers.get(locus.url).initializedFromHashTree = true;
1485
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1486
+ this.hashTreeParsers.get(locus.url)!.initializedFromHashTree = true;
1293
1487
  this.onFullLocusCommon(locus, eventType);
1294
1488
  } else {
1295
1489
  // in this case the Locus we're getting is not necessarily the full one
@@ -1351,7 +1545,7 @@ export default class LocusInfo extends EventsScope {
1351
1545
  );
1352
1546
  }
1353
1547
  // this is the new hashmap Locus DTO format (only applicable to webinars for now)
1354
- this.onFullLocusWithHashTrees(debugText, locus, metadata, eventType, dataSets);
1548
+ this.onFullLocusWithHashTrees(debugText, locus, metadata, dataSets, eventType);
1355
1549
  } else {
1356
1550
  this.onFullLocusClassic(debugText, locus, eventType);
1357
1551
  }
@@ -1495,7 +1689,7 @@ export default class LocusInfo extends EventsScope {
1495
1689
  * @memberof LocusInfo
1496
1690
  */
1497
1691
  updateLocusInfo(locus) {
1498
- if (locus.self?.reason === 'MOVED' && locus.self?.state === 'LEFT') {
1692
+ if (MeetingsUtil.isSelfMovedOrBreakoutEnded(locus)) {
1499
1693
  // When moved to a breakout session locus sends a message for the previous locus
1500
1694
  // indicating that we have been moved. It isn't helpful to continue parsing this
1501
1695
  // as it gets interpreted as if we have left the call
@@ -1580,8 +1774,19 @@ export default class LocusInfo extends EventsScope {
1580
1774
  options: {
1581
1775
  meetingId: this.meetingId,
1582
1776
  },
1777
+ payload: {
1778
+ eventData: {
1779
+ joinInProgress: this.destroyMeetingSuspended,
1780
+ },
1781
+ },
1583
1782
  });
1584
1783
 
1784
+ if (this.destroyMeetingSuspended) {
1785
+ Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.DESTROY_MEETING_WHILE_SUSPENDED, {
1786
+ meetingId: this.meetingId,
1787
+ reason: 'CALL_INACTIVE',
1788
+ });
1789
+ }
1585
1790
  this.emitScoped(
1586
1791
  {
1587
1792
  file: 'locus-info',
@@ -1606,7 +1811,18 @@ export default class LocusInfo extends EventsScope {
1606
1811
  options: {
1607
1812
  meetingId: this.meetingId,
1608
1813
  },
1814
+ payload: {
1815
+ eventData: {
1816
+ joinInProgress: this.destroyMeetingSuspended,
1817
+ },
1818
+ },
1609
1819
  });
1820
+ if (this.destroyMeetingSuspended) {
1821
+ Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.DESTROY_MEETING_WHILE_SUSPENDED, {
1822
+ meetingId: this.meetingId,
1823
+ reason: 'PARTNER_LEFT',
1824
+ });
1825
+ }
1610
1826
  this.emitScoped(
1611
1827
  {
1612
1828
  file: 'locus-info',
@@ -1633,8 +1849,19 @@ export default class LocusInfo extends EventsScope {
1633
1849
  options: {
1634
1850
  meetingId: this.meetingId,
1635
1851
  },
1852
+ payload: {
1853
+ eventData: {
1854
+ joinInProgress: this.destroyMeetingSuspended,
1855
+ },
1856
+ },
1636
1857
  });
1637
1858
 
1859
+ if (this.destroyMeetingSuspended) {
1860
+ Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.DESTROY_MEETING_WHILE_SUSPENDED, {
1861
+ meetingId: this.meetingId,
1862
+ reason: 'SELF_LEFT',
1863
+ });
1864
+ }
1638
1865
  this.emitScoped(
1639
1866
  {
1640
1867
  file: 'locus-info',
@@ -1648,56 +1875,82 @@ export default class LocusInfo extends EventsScope {
1648
1875
  );
1649
1876
  }
1650
1877
  } else if (this.parsedLocus.fullState?.type === _MEETING_) {
1651
- if (
1652
- this.fullState &&
1653
- (this.fullState.state === LOCUS.STATE.INACTIVE ||
1878
+ if (this.fullState && MeetingsUtil.isWholeMeetingEnded(this.fullState)) {
1879
+ if (this.destroyMeetingSuspended) {
1880
+ LoggerProxy.logger.info(
1881
+ 'Locus-info:index#isMeetingActive --> suppressing DESTROY_MEETING (MEETING_INACTIVE_TERMINATING) because destroyMeeting is suspended'
1882
+ );
1883
+ Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.DESTROY_MEETING_WHILE_SUSPENDED, {
1884
+ meetingId: this.meetingId,
1885
+ reason: 'MEETING_INACTIVE_TERMINATING',
1886
+ });
1887
+ } else {
1888
+ LoggerProxy.logger.warn(
1889
+ 'Locus-info:index#isMeetingActive --> Meeting is ending due to inactive'
1890
+ );
1891
+
1654
1892
  // @ts-ignore
1655
- this.fullState.state === LOCUS.STATE.TERMINATING)
1656
- ) {
1657
- LoggerProxy.logger.warn(
1658
- 'Locus-info:index#isMeetingActive --> Meeting is ending due to inactive or terminating'
1659
- );
1893
+ this.webex.internal.newMetrics.submitClientEvent({
1894
+ name: 'client.call.remote-ended',
1895
+ options: {
1896
+ meetingId: this.meetingId,
1897
+ },
1898
+ });
1660
1899
 
1661
- // @ts-ignore
1662
- this.webex.internal.newMetrics.submitClientEvent({
1663
- name: 'client.call.remote-ended',
1664
- options: {
1665
- meetingId: this.meetingId,
1666
- },
1667
- });
1668
- this.emitScoped(
1669
- {
1670
- file: 'locus-info',
1671
- function: 'isMeetingActive',
1672
- },
1673
- EVENTS.DESTROY_MEETING,
1674
- {
1675
- reason: MEETING_REMOVED_REASON.MEETING_INACTIVE_TERMINATING,
1676
- shouldLeave: false,
1677
- }
1678
- );
1900
+ this.emitScoped(
1901
+ {
1902
+ file: 'locus-info',
1903
+ function: 'isMeetingActive',
1904
+ },
1905
+ EVENTS.DESTROY_MEETING,
1906
+ {
1907
+ reason: MEETING_REMOVED_REASON.MEETING_INACTIVE_TERMINATING,
1908
+ shouldLeave: false,
1909
+ }
1910
+ );
1911
+ }
1679
1912
  }
1680
1913
  // If you are guest and you are removed from the meeting
1681
1914
  // You wont get any further events
1682
1915
  else if (this.parsedLocus.self && this.parsedLocus.self.removed) {
1683
- // Check if we need to send an event
1684
- this.emitScoped(
1685
- {
1686
- file: 'locus-info',
1687
- function: 'isMeetingActive',
1688
- },
1689
- EVENTS.DESTROY_MEETING,
1690
- {
1691
- reason: MEETING_REMOVED_REASON.SELF_REMOVED,
1692
- shouldLeave: false,
1693
- }
1694
- );
1916
+ if (this.destroyMeetingSuspended) {
1917
+ LoggerProxy.logger.info(
1918
+ 'Locus-info:index#isMeetingActive --> suppressing DESTROY_MEETING (SELF_REMOVED) because destroyMeeting is suspended'
1919
+ );
1920
+ Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.DESTROY_MEETING_WHILE_SUSPENDED, {
1921
+ meetingId: this.meetingId,
1922
+ reason: 'SELF_REMOVED',
1923
+ });
1924
+ } else {
1925
+ this.emitScoped(
1926
+ {
1927
+ file: 'locus-info',
1928
+ function: 'isMeetingActive',
1929
+ },
1930
+ EVENTS.DESTROY_MEETING,
1931
+ {
1932
+ reason: MEETING_REMOVED_REASON.SELF_REMOVED,
1933
+ shouldLeave: false,
1934
+ }
1935
+ );
1936
+ }
1695
1937
  }
1696
1938
  } else {
1697
1939
  LoggerProxy.logger.warn('Locus-info:index#isMeetingActive --> Meeting Type is unknown.');
1698
1940
  }
1699
1941
  }
1700
1942
 
1943
+ /**
1944
+ * Suspends or resumes the emission of DESTROY_MEETING events in certain situations.
1945
+ * Used by joinWithMedia to prevent meeting destruction during retry flows.
1946
+ * @param {boolean} suspend - true to suppress, false to resume
1947
+ * @returns {undefined}
1948
+ * @memberof LocusInfo
1949
+ */
1950
+ suspendDestroyMeeting(suspend: boolean) {
1951
+ this.destroyMeetingSuspended = suspend;
1952
+ }
1953
+
1701
1954
  /**
1702
1955
  * checks if the host permissions have changed while in the meeting
1703
1956
  * This would be the case if your role as host or moderator has been updated
@@ -1918,6 +2171,8 @@ export default class LocusInfo extends EventsScope {
1918
2171
  state,
1919
2172
  modifiedBy: current.record.modifiedBy,
1920
2173
  lastModified: current.record.lastModified,
2174
+ modifiedByServiceAppName: current.record.modifiedByServiceAppName,
2175
+ modifiedByServiceAppId: current.record.modifiedByServiceAppId,
1921
2176
  }
1922
2177
  );
1923
2178
  }
@@ -2301,9 +2556,19 @@ export default class LocusInfo extends EventsScope {
2301
2556
  */
2302
2557
  updateMeetingInfo(info: object, self?: object) {
2303
2558
  const roles = self ? SelfUtils.getRoles(self) : this.parsedLocus.self?.roles || [];
2304
- if ((info && !isEqual(this.info, info)) || (!isEqual(this.roles, roles) && info)) {
2305
- const isJoined = SelfUtils.isJoined(self || this.parsedLocus.self);
2306
- const parsedInfo = InfoUtils.getInfos(this.parsedLocus.info, info, roles, isJoined);
2559
+ const isJoined = SelfUtils.isJoined(self || this.parsedLocus.self);
2560
+
2561
+ // The parsed userDisplayHints depend on info, roles and isJoined, so we must recompute
2562
+ // whenever any of them changes. A common case is self transitioning to JOINED via a delta
2563
+ // that doesn't carry an info section - in that case we fall back to the previously stored
2564
+ // info so the hints get reparsed with the new joined state (e.g. VIEW_THE_PARTICIPANT_LIST).
2565
+ const infoToParse = info || this.info;
2566
+ const infoChanged = info && !isEqual(this.info, info);
2567
+ const rolesChanged = !isEqual(this.roles, roles);
2568
+ const isJoinedChanged = SelfUtils.isJoined(this.parsedLocus.self) !== isJoined;
2569
+
2570
+ if (infoToParse && (infoChanged || rolesChanged || isJoinedChanged)) {
2571
+ const parsedInfo = InfoUtils.getInfos(this.parsedLocus.info, infoToParse, roles, isJoined);
2307
2572
 
2308
2573
  if (parsedInfo.updates.isLocked) {
2309
2574
  this.emitScoped(
@@ -2326,7 +2591,7 @@ export default class LocusInfo extends EventsScope {
2326
2591
  );
2327
2592
  }
2328
2593
 
2329
- this.info = info;
2594
+ this.info = infoToParse;
2330
2595
  this.parsedLocus.info = parsedInfo.current;
2331
2596
  // Parses the info and adds necessary values
2332
2597
  this.updateMeeting(parsedInfo.current);
@@ -2587,6 +2852,7 @@ export default class LocusInfo extends EventsScope {
2587
2852
  {
2588
2853
  muted: parsedSelves.current.remoteMuted,
2589
2854
  unmuteAllowed: parsedSelves.current.unmuteAllowed,
2855
+ modifiedBy: parsedSelves.current.modifiedBy ?? null,
2590
2856
  }
2591
2857
  );
2592
2858
  }
@@ -2859,4 +3125,17 @@ export default class LocusInfo extends EventsScope {
2859
3125
  clearMainSessionLocusCache() {
2860
3126
  this.mainSessionLocusCache = null;
2861
3127
  }
3128
+
3129
+ /**
3130
+ * Cleans up all hash tree parsers and clears internal maps.
3131
+ * @returns {void}
3132
+ * @memberof LocusInfo
3133
+ */
3134
+ cleanUp() {
3135
+ this.hashTreeParsers.forEach((entry) => {
3136
+ entry.parser.cleanUp();
3137
+ });
3138
+ this.hashTreeParsers.clear();
3139
+ this.hashTreeObjectId2ParticipantId.clear();
3140
+ }
2862
3141
  }