@webex/plugin-meetings 3.12.0-task-refactor.1 → 3.12.0-webex-services-ready.2

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 (302) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +197 -0
  3. package/dist/aiEnableRequest/index.js.map +1 -0
  4. package/dist/aiEnableRequest/utils.js +36 -0
  5. package/dist/aiEnableRequest/utils.js.map +1 -0
  6. package/dist/annotation/index.js +14 -5
  7. package/dist/annotation/index.js.map +1 -1
  8. package/dist/breakouts/breakout.js +8 -3
  9. package/dist/breakouts/breakout.js.map +1 -1
  10. package/dist/breakouts/index.js +26 -2
  11. package/dist/breakouts/index.js.map +1 -1
  12. package/dist/common/errors/webex-errors.js +49 -5
  13. package/dist/common/errors/webex-errors.js.map +1 -1
  14. package/dist/config.js +9 -3
  15. package/dist/config.js.map +1 -1
  16. package/dist/constants.js +59 -10
  17. package/dist/constants.js.map +1 -1
  18. package/dist/controls-options-manager/constants.js +11 -1
  19. package/dist/controls-options-manager/constants.js.map +1 -1
  20. package/dist/controls-options-manager/index.js +67 -29
  21. package/dist/controls-options-manager/index.js.map +1 -1
  22. package/dist/controls-options-manager/util.js +91 -0
  23. package/dist/controls-options-manager/util.js.map +1 -1
  24. package/dist/hashTree/constants.js +34 -0
  25. package/dist/hashTree/constants.js.map +1 -0
  26. package/dist/hashTree/hashTree.js +533 -0
  27. package/dist/hashTree/hashTree.js.map +1 -0
  28. package/dist/hashTree/hashTreeParser.js +2068 -36
  29. package/dist/hashTree/hashTreeParser.js.map +1 -1
  30. package/dist/hashTree/types.js +13 -3
  31. package/dist/hashTree/types.js.map +1 -1
  32. package/dist/hashTree/utils.js +111 -0
  33. package/dist/hashTree/utils.js.map +1 -0
  34. package/dist/index.js +18 -2
  35. package/dist/index.js.map +1 -1
  36. package/dist/interceptors/constant.js +12 -0
  37. package/dist/interceptors/constant.js.map +1 -0
  38. package/dist/interceptors/dataChannelAuthToken.js +350 -0
  39. package/dist/interceptors/dataChannelAuthToken.js.map +1 -0
  40. package/dist/interceptors/index.js +7 -0
  41. package/dist/interceptors/index.js.map +1 -1
  42. package/dist/interceptors/locusRetry.js +23 -8
  43. package/dist/interceptors/locusRetry.js.map +1 -1
  44. package/dist/interceptors/locusRouteToken.js +27 -5
  45. package/dist/interceptors/locusRouteToken.js.map +1 -1
  46. package/dist/interceptors/utils.js +27 -0
  47. package/dist/interceptors/utils.js.map +1 -0
  48. package/dist/interpretation/index.js +11 -2
  49. package/dist/interpretation/index.js.map +1 -1
  50. package/dist/interpretation/interpretation.types.js +7 -0
  51. package/dist/interpretation/interpretation.types.js.map +1 -0
  52. package/dist/interpretation/siLanguage.js +1 -1
  53. package/dist/locus-info/controlsUtils.js +11 -4
  54. package/dist/locus-info/controlsUtils.js.map +1 -1
  55. package/dist/locus-info/index.js +896 -277
  56. package/dist/locus-info/index.js.map +1 -1
  57. package/dist/locus-info/infoUtils.js +36 -5
  58. package/dist/locus-info/infoUtils.js.map +1 -1
  59. package/dist/locus-info/selfUtils.js +1 -0
  60. package/dist/locus-info/selfUtils.js.map +1 -1
  61. package/dist/locus-info/types.js +19 -0
  62. package/dist/locus-info/types.js.map +1 -1
  63. package/dist/media/MediaConnectionAwaiter.js +72 -3
  64. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  65. package/dist/media/index.js +8 -2
  66. package/dist/media/index.js.map +1 -1
  67. package/dist/media/properties.js +5 -2
  68. package/dist/media/properties.js.map +1 -1
  69. package/dist/meeting/in-meeting-actions.js +11 -1
  70. package/dist/meeting/in-meeting-actions.js.map +1 -1
  71. package/dist/meeting/index.js +2075 -1096
  72. package/dist/meeting/index.js.map +1 -1
  73. package/dist/meeting/locusMediaRequest.js +229 -82
  74. package/dist/meeting/locusMediaRequest.js.map +1 -1
  75. package/dist/meeting/muteState.js +10 -1
  76. package/dist/meeting/muteState.js.map +1 -1
  77. package/dist/meeting/request.js +55 -2
  78. package/dist/meeting/request.js.map +1 -1
  79. package/dist/meeting/request.type.js.map +1 -1
  80. package/dist/meeting/util.js +168 -5
  81. package/dist/meeting/util.js.map +1 -1
  82. package/dist/meeting-info/meeting-info-v2.js +2 -2
  83. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  84. package/dist/meetings/index.js +369 -173
  85. package/dist/meetings/index.js.map +1 -1
  86. package/dist/meetings/meetings.types.js +6 -1
  87. package/dist/meetings/meetings.types.js.map +1 -1
  88. package/dist/meetings/request.js +39 -0
  89. package/dist/meetings/request.js.map +1 -1
  90. package/dist/meetings/util.js +127 -25
  91. package/dist/meetings/util.js.map +1 -1
  92. package/dist/member/index.js +20 -0
  93. package/dist/member/index.js.map +1 -1
  94. package/dist/member/types.js.map +1 -1
  95. package/dist/member/util.js +40 -0
  96. package/dist/member/util.js.map +1 -1
  97. package/dist/members/index.js +101 -43
  98. package/dist/members/index.js.map +1 -1
  99. package/dist/members/util.js +8 -1
  100. package/dist/members/util.js.map +1 -1
  101. package/dist/metrics/constants.js +11 -1
  102. package/dist/metrics/constants.js.map +1 -1
  103. package/dist/multistream/codec/constants.js +63 -0
  104. package/dist/multistream/codec/constants.js.map +1 -0
  105. package/dist/multistream/mediaRequestManager.js +64 -68
  106. package/dist/multistream/mediaRequestManager.js.map +1 -1
  107. package/dist/multistream/receiveSlot.js +9 -0
  108. package/dist/multistream/receiveSlot.js.map +1 -1
  109. package/dist/multistream/remoteMediaManager.js +11 -0
  110. package/dist/multistream/remoteMediaManager.js.map +1 -1
  111. package/dist/multistream/sendSlotManager.js +116 -2
  112. package/dist/multistream/sendSlotManager.js.map +1 -1
  113. package/dist/reachability/clusterReachability.js +171 -18
  114. package/dist/reachability/clusterReachability.js.map +1 -1
  115. package/dist/reachability/index.js +142 -94
  116. package/dist/reachability/index.js.map +1 -1
  117. package/dist/reachability/reachability.types.js +2 -0
  118. package/dist/reachability/reachability.types.js.map +1 -1
  119. package/dist/reachability/reachabilityPeerConnection.js +1 -1
  120. package/dist/reachability/reachabilityPeerConnection.js.map +1 -1
  121. package/dist/reachability/util.js +45 -0
  122. package/dist/reachability/util.js.map +1 -1
  123. package/dist/reactions/reactions.type.js.map +1 -1
  124. package/dist/reconnection-manager/index.js +0 -1
  125. package/dist/reconnection-manager/index.js.map +1 -1
  126. package/dist/recording-controller/index.js +1 -3
  127. package/dist/recording-controller/index.js.map +1 -1
  128. package/dist/types/aiEnableRequest/index.d.ts +5 -0
  129. package/dist/types/aiEnableRequest/utils.d.ts +2 -0
  130. package/dist/types/common/browser-detection.d.ts +1 -0
  131. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  132. package/dist/types/common/events/events-scope.d.ts +1 -0
  133. package/dist/types/common/events/events.d.ts +1 -0
  134. package/dist/types/config.d.ts +7 -2
  135. package/dist/types/constants.d.ts +35 -1
  136. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  137. package/dist/types/controls-options-manager/index.d.ts +16 -0
  138. package/dist/types/hashTree/constants.d.ts +11 -0
  139. package/dist/types/hashTree/hashTree.d.ts +136 -0
  140. package/dist/types/hashTree/hashTreeParser.d.ts +392 -14
  141. package/dist/types/hashTree/types.d.ts +20 -0
  142. package/dist/types/hashTree/utils.d.ts +40 -0
  143. package/dist/types/index.d.ts +4 -0
  144. package/dist/types/interceptors/constant.d.ts +5 -0
  145. package/dist/types/interceptors/dataChannelAuthToken.d.ts +43 -0
  146. package/dist/types/interceptors/index.d.ts +2 -1
  147. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  148. package/dist/types/interceptors/locusRouteToken.d.ts +2 -0
  149. package/dist/types/interceptors/utils.d.ts +1 -0
  150. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  151. package/dist/types/locus-info/index.d.ts +116 -51
  152. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  153. package/dist/types/locus-info/types.d.ts +48 -12
  154. package/dist/types/media/MediaConnectionAwaiter.d.ts +20 -2
  155. package/dist/types/media/properties.d.ts +3 -1
  156. package/dist/types/meeting/in-meeting-actions.d.ts +10 -0
  157. package/dist/types/meeting/index.d.ts +196 -15
  158. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  159. package/dist/types/meeting/request.d.ts +17 -1
  160. package/dist/types/meeting/request.type.d.ts +5 -0
  161. package/dist/types/meeting/util.d.ts +40 -0
  162. package/dist/types/meeting-info/util.d.ts +1 -0
  163. package/dist/types/meeting-info/utilv2.d.ts +1 -0
  164. package/dist/types/meetings/index.d.ts +34 -20
  165. package/dist/types/meetings/meetings.types.d.ts +15 -0
  166. package/dist/types/meetings/request.d.ts +14 -0
  167. package/dist/types/member/index.d.ts +2 -0
  168. package/dist/types/member/types.d.ts +5 -4
  169. package/dist/types/member/util.d.ts +14 -0
  170. package/dist/types/members/index.d.ts +15 -2
  171. package/dist/types/members/util.d.ts +1 -5
  172. package/dist/types/metrics/constants.d.ts +10 -0
  173. package/dist/types/multistream/codec/constants.d.ts +7 -0
  174. package/dist/types/multistream/mediaRequestManager.d.ts +20 -26
  175. package/dist/types/multistream/sendSlotManager.d.ts +23 -1
  176. package/dist/types/reachability/clusterReachability.d.ts +33 -6
  177. package/dist/types/reachability/index.d.ts +10 -3
  178. package/dist/types/reachability/reachability.types.d.ts +7 -0
  179. package/dist/types/reachability/util.d.ts +17 -0
  180. package/dist/types/reactions/reactions.type.d.ts +4 -0
  181. package/dist/types/recording-controller/util.d.ts +5 -5
  182. package/dist/types/roap/index.d.ts +1 -1
  183. package/dist/types/webinar/utils.d.ts +6 -0
  184. package/dist/webinar/index.js +585 -164
  185. package/dist/webinar/index.js.map +1 -1
  186. package/dist/webinar/utils.js +25 -0
  187. package/dist/webinar/utils.js.map +1 -0
  188. package/package.json +26 -24
  189. package/src/aiEnableRequest/README.md +84 -0
  190. package/src/aiEnableRequest/index.ts +186 -0
  191. package/src/aiEnableRequest/utils.ts +25 -0
  192. package/src/annotation/index.ts +27 -7
  193. package/src/breakouts/breakout.ts +3 -1
  194. package/src/breakouts/index.ts +31 -0
  195. package/src/common/errors/webex-errors.ts +50 -3
  196. package/src/config.ts +7 -2
  197. package/src/constants.ts +49 -3
  198. package/src/controls-options-manager/constants.ts +14 -1
  199. package/src/controls-options-manager/index.ts +87 -28
  200. package/src/controls-options-manager/util.ts +81 -1
  201. package/src/hashTree/constants.ts +26 -0
  202. package/src/hashTree/hashTree.ts +480 -0
  203. package/src/hashTree/hashTreeParser.ts +1911 -29
  204. package/src/hashTree/types.ts +24 -1
  205. package/src/hashTree/utils.ts +98 -0
  206. package/src/index.ts +14 -1
  207. package/src/interceptors/constant.ts +6 -0
  208. package/src/interceptors/dataChannelAuthToken.ts +246 -0
  209. package/src/interceptors/index.ts +2 -1
  210. package/src/interceptors/locusRetry.ts +25 -4
  211. package/src/interceptors/locusRouteToken.ts +22 -5
  212. package/src/interceptors/utils.ts +16 -0
  213. package/src/interpretation/index.ts +29 -11
  214. package/src/interpretation/interpretation.types.ts +11 -0
  215. package/src/locus-info/controlsUtils.ts +20 -1
  216. package/src/locus-info/index.ts +958 -250
  217. package/src/locus-info/infoUtils.ts +41 -6
  218. package/src/locus-info/selfUtils.ts +1 -0
  219. package/src/locus-info/types.ts +51 -12
  220. package/src/media/MediaConnectionAwaiter.ts +62 -5
  221. package/src/media/index.ts +10 -1
  222. package/src/media/properties.ts +4 -1
  223. package/src/meeting/in-meeting-actions.ts +20 -0
  224. package/src/meeting/index.ts +1025 -146
  225. package/src/meeting/locusMediaRequest.ts +106 -6
  226. package/src/meeting/muteState.ts +10 -1
  227. package/src/meeting/request.ts +53 -0
  228. package/src/meeting/request.type.ts +6 -0
  229. package/src/meeting/util.ts +207 -7
  230. package/src/meeting-info/meeting-info-v2.ts +4 -2
  231. package/src/meetings/index.ts +307 -132
  232. package/src/meetings/meetings.types.ts +19 -0
  233. package/src/meetings/request.ts +43 -0
  234. package/src/meetings/util.ts +127 -13
  235. package/src/member/index.ts +20 -0
  236. package/src/member/types.ts +1 -0
  237. package/src/member/util.ts +41 -0
  238. package/src/members/index.ts +70 -7
  239. package/src/members/util.ts +12 -4
  240. package/src/metrics/constants.ts +11 -0
  241. package/src/multistream/codec/constants.ts +58 -0
  242. package/src/multistream/mediaRequestManager.ts +117 -76
  243. package/src/multistream/receiveSlot.ts +18 -0
  244. package/src/multistream/remoteMediaManager.ts +13 -0
  245. package/src/multistream/sendSlotManager.ts +97 -3
  246. package/src/reachability/clusterReachability.ts +156 -29
  247. package/src/reachability/index.ts +62 -17
  248. package/src/reachability/reachability.types.ts +11 -0
  249. package/src/reachability/reachabilityPeerConnection.ts +3 -1
  250. package/src/reachability/util.ts +36 -0
  251. package/src/reactions/reactions.type.ts +4 -0
  252. package/src/reconnection-manager/index.ts +0 -1
  253. package/src/recording-controller/index.ts +1 -2
  254. package/src/webinar/index.ts +448 -11
  255. package/src/webinar/utils.ts +16 -0
  256. package/test/unit/spec/aiEnableRequest/index.ts +1067 -0
  257. package/test/unit/spec/aiEnableRequest/utils.ts +130 -0
  258. package/test/unit/spec/annotation/index.ts +69 -7
  259. package/test/unit/spec/breakouts/breakout.ts +9 -3
  260. package/test/unit/spec/breakouts/index.ts +49 -0
  261. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  262. package/test/unit/spec/controls-options-manager/index.js +244 -29
  263. package/test/unit/spec/controls-options-manager/util.js +165 -0
  264. package/test/unit/spec/hashTree/hashTree.ts +721 -0
  265. package/test/unit/spec/hashTree/hashTreeParser.ts +5328 -0
  266. package/test/unit/spec/hashTree/utils.ts +264 -0
  267. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +406 -0
  268. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  269. package/test/unit/spec/interceptors/locusRouteToken.ts +44 -0
  270. package/test/unit/spec/interceptors/utils.ts +75 -0
  271. package/test/unit/spec/interpretation/index.ts +26 -4
  272. package/test/unit/spec/locus-info/controlsUtils.js +222 -52
  273. package/test/unit/spec/locus-info/index.js +2000 -171
  274. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  275. package/test/unit/spec/media/MediaConnectionAwaiter.ts +96 -1
  276. package/test/unit/spec/media/index.ts +92 -0
  277. package/test/unit/spec/media/properties.ts +12 -3
  278. package/test/unit/spec/meeting/in-meeting-actions.ts +12 -2
  279. package/test/unit/spec/meeting/index.js +2925 -209
  280. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  281. package/test/unit/spec/meeting/muteState.js +81 -0
  282. package/test/unit/spec/meeting/request.js +82 -0
  283. package/test/unit/spec/meeting/utils.js +595 -27
  284. package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
  285. package/test/unit/spec/meetings/index.js +1214 -75
  286. package/test/unit/spec/meetings/request.js +141 -0
  287. package/test/unit/spec/meetings/utils.js +453 -52
  288. package/test/unit/spec/member/index.js +35 -4
  289. package/test/unit/spec/member/util.js +154 -27
  290. package/test/unit/spec/members/index.js +216 -0
  291. package/test/unit/spec/members/request.js +37 -1
  292. package/test/unit/spec/members/utils.js +63 -0
  293. package/test/unit/spec/multistream/mediaRequestManager.ts +503 -122
  294. package/test/unit/spec/multistream/remoteMediaManager.ts +30 -0
  295. package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
  296. package/test/unit/spec/reachability/clusterReachability.ts +125 -1
  297. package/test/unit/spec/reachability/index.ts +154 -49
  298. package/test/unit/spec/reachability/util.ts +31 -0
  299. package/test/unit/spec/reconnection-manager/index.js +4 -8
  300. package/test/unit/spec/recording-controller/index.js +9 -8
  301. package/test/unit/spec/webinar/index.ts +837 -39
  302. package/test/unit/spec/webinar/utils.ts +39 -0
@@ -18,6 +18,7 @@ import {
18
18
  CALL_REMOVED_REASON,
19
19
  RECORDING_STATE,
20
20
  Enum,
21
+ SELF_ROLES,
21
22
  } from '../constants';
22
23
 
23
24
  import InfoUtils from './infoUtils';
@@ -33,12 +34,16 @@ import BEHAVIORAL_METRICS from '../metrics/constants';
33
34
  import HashTreeParser, {
34
35
  DataSet,
35
36
  HashTreeMessage,
36
- HashTreeObject,
37
- isSelf,
37
+ LocusInfoUpdate,
38
38
  LocusInfoUpdateType,
39
+ Metadata,
39
40
  } from '../hashTree/hashTreeParser';
40
- import {ObjectType} from '../hashTree/types';
41
- import {LocusDTO} from './types';
41
+ import {HashTreeObject, ObjectType, ObjectTypeToLocusKeyMap} from '../hashTree/types';
42
+ import {isMetadata, isSelf} from '../hashTree/utils';
43
+ import {Links, LocusDTO, ReplacesInfo} from './types';
44
+ import MeetingsUtil from '../meetings/util';
45
+ import {MEETING_KEY} from '../meetings/meetings.types';
46
+ import MeetingCollection from '../meetings/collection';
42
47
 
43
48
  export type LocusLLMEvent = {
44
49
  data: {
@@ -47,9 +52,12 @@ export type LocusLLMEvent = {
47
52
  };
48
53
  };
49
54
 
55
+ // list of top level keys in Locus DTO relevant for Hash Tree DTOs processing
56
+ // it does not contain fields specific to classic Locus DTOs like sequence or baseSequence
50
57
  const LocusDtoTopLevelKeys = [
51
58
  'controls',
52
59
  'fullState',
60
+ 'embeddedApps',
53
61
  'host',
54
62
  'info',
55
63
  'links',
@@ -64,10 +72,13 @@ const LocusDtoTopLevelKeys = [
64
72
  'htMeta', // only exists when hash trees are used
65
73
  ];
66
74
 
67
- export type LocusApiResponseBody = {
68
- dataSets?: DataSet[];
69
- locus: LocusDTO; // this LocusDTO here might not be the full one (for example it won't have all the participants, but it should have self)
70
- };
75
+ export type LocusApiResponseBody =
76
+ | {
77
+ dataSets?: DataSet[];
78
+ locus: LocusDTO; // this LocusDTO here might not be the full one (for example it won't have all the participants, but it should have self)
79
+ metadata?: Metadata;
80
+ }
81
+ | LocusDTO; // when we invoke APIs on the whole Locus like "mute all" backend returns the whole Locus in the response like this
71
82
 
72
83
  const LocusObjectStateAfterUpdates = {
73
84
  unchanged: 'unchanged',
@@ -77,6 +88,168 @@ const LocusObjectStateAfterUpdates = {
77
88
 
78
89
  type LocusObjectStateAfterUpdates = Enum<typeof LocusObjectStateAfterUpdates>;
79
90
 
91
+ export type HashTreeParserEntry = {
92
+ parser: HashTreeParser;
93
+ replacedAt?: string;
94
+ initializedFromHashTree: boolean;
95
+ };
96
+
97
+ /**
98
+ * Gets the replacement information
99
+ *
100
+ * @param {any} self - "self" object from Locus DTO
101
+ * @param {string} deviceUrl - The URL of the specified device
102
+ * @returns {any} The replace information if available, otherwise undefined
103
+ */
104
+ function getReplaceInfoFromSelf(self: any, deviceUrl: string): ReplacesInfo | undefined {
105
+ if (self) {
106
+ const device = MeetingsUtil.getThisDevice({self}, deviceUrl);
107
+
108
+ if (device?.replaces?.length > 0) {
109
+ return device.replaces[0];
110
+ }
111
+ }
112
+
113
+ return undefined;
114
+ }
115
+
116
+ /**
117
+ * Finds a meeting by its locus URL in meeting collection. It checks all HashTreeParsers of all meetings in the collection.
118
+ *
119
+ * @param {MeetingCollection} meetingCollection - The collection of meetings to search
120
+ * @param {string} locusUrl - The locus URL to search for
121
+ * @returns {any} The meeting if found, otherwise undefined
122
+ */
123
+ function findLocusUrlInAnyHashTreeParser(
124
+ meetingCollection: MeetingCollection,
125
+ locusUrl: string
126
+ ): any {
127
+ for (const meeting of Object.values(meetingCollection.getAll()) as any[]) {
128
+ if (meeting?.locusInfo?.hashTreeParsers?.has(locusUrl)) {
129
+ return meeting;
130
+ }
131
+ }
132
+
133
+ return undefined;
134
+ }
135
+
136
+ /**
137
+ * Finds a meeting for a given hash tree message.
138
+ *
139
+ * @param {HashTreeMessage} message - The hash tree message to find the meeting for
140
+ * @param {MeetingCollection} meetingCollection - The collection of meetings to search
141
+ * @returns {any} The meeting if found, otherwise undefined
142
+ */
143
+ export function findMeetingForHashTreeMessage(
144
+ message: HashTreeMessage | undefined,
145
+ meetingCollection: MeetingCollection
146
+ ): any {
147
+ if (!message) {
148
+ return undefined;
149
+ }
150
+ let foundMeeting = findLocusUrlInAnyHashTreeParser(meetingCollection, message.locusUrl);
151
+
152
+ if (foundMeeting) {
153
+ return foundMeeting;
154
+ }
155
+
156
+ // if we haven't found anything, it may mean that message has a new locusUrl
157
+ // check if it indicates that it replaces some existing current locusUrl (this is indicated in "self")
158
+ const self = message.locusStateElements?.find((el) => isSelf(el))?.data;
159
+ const replaces = getReplaceInfoFromSelf(self, self?.deviceUrl);
160
+
161
+ if (replaces?.locusUrl) {
162
+ foundMeeting = findLocusUrlInAnyHashTreeParser(meetingCollection, replaces.locusUrl);
163
+
164
+ return foundMeeting;
165
+ }
166
+
167
+ return undefined;
168
+ }
169
+
170
+ /**
171
+ * Creates a locus object from the objects received in a hash tree message. It usually will be
172
+ * incomplete, because hash tree messages only contain the parts of locus that have changed,
173
+ * and some updates come separately over Mercury or LLM in separate messages.
174
+ *
175
+ * @param {HashTreeMessage} message hash tree message to created the locus from
176
+ * @returns {Object} the created locus object and metadata if present
177
+ */
178
+ export function createLocusFromHashTreeMessage(message: HashTreeMessage): {
179
+ locus: LocusDTO;
180
+ metadata?: Metadata;
181
+ } {
182
+ const locus: LocusDTO = {
183
+ participants: [],
184
+ url: message.locusUrl,
185
+ };
186
+ let metadata: Metadata | undefined;
187
+
188
+ if (!message.locusStateElements) {
189
+ return {locus, metadata};
190
+ }
191
+
192
+ for (const element of message.locusStateElements) {
193
+ if (!element.data) {
194
+ // eslint-disable-next-line no-continue
195
+ continue;
196
+ }
197
+
198
+ const type = element.htMeta.elementId.type.toLowerCase();
199
+
200
+ switch (type) {
201
+ case ObjectType.locus: {
202
+ // spread locus object data onto the top level, but remove keys managed by other ObjectTypes
203
+ const locusObjectData = {...element.data};
204
+
205
+ Object.values(ObjectTypeToLocusKeyMap).forEach((locusDtoKey) => {
206
+ delete locusObjectData[locusDtoKey];
207
+ });
208
+
209
+ Object.assign(locus, locusObjectData);
210
+ break;
211
+ }
212
+ case ObjectType.participant:
213
+ locus.participants.push(element.data);
214
+ break;
215
+ case ObjectType.mediaShare:
216
+ if (!locus.mediaShares) {
217
+ locus.mediaShares = [];
218
+ }
219
+ locus.mediaShares.push(element.data);
220
+ break;
221
+ case ObjectType.embeddedApp:
222
+ if (!locus.embeddedApps) {
223
+ locus.embeddedApps = [];
224
+ }
225
+ locus.embeddedApps.push(element.data);
226
+ break;
227
+ case ObjectType.control:
228
+ if (!locus.controls) {
229
+ locus.controls = {};
230
+ }
231
+ Object.assign(locus.controls, element.data);
232
+ break;
233
+ case ObjectType.links:
234
+ case ObjectType.info:
235
+ case ObjectType.fullState:
236
+ case ObjectType.self: {
237
+ const locusDtoKey = ObjectTypeToLocusKeyMap[type];
238
+ locus[locusDtoKey] = element.data;
239
+ break;
240
+ }
241
+ case ObjectType.metadata:
242
+ // metadata is not part of Locus DTO
243
+ metadata = {...element.data, htMeta: element.htMeta} as Metadata;
244
+ break;
245
+ default:
246
+ break;
247
+ }
248
+ }
249
+
250
+ return {locus, metadata};
251
+ }
252
+
80
253
  /**
81
254
  * @description LocusInfo extends ChildEmitter to convert locusInfo info a private emitter to parent object
82
255
  * @export
@@ -94,10 +267,7 @@ export default class LocusInfo extends EventsScope {
94
267
  aclUrl: any;
95
268
  baseSequence: any;
96
269
  created: any;
97
- identities: any;
98
- membership: any;
99
270
  participants: any;
100
- participantsUrl: any;
101
271
  replaces: any;
102
272
  scheduledMeeting: any;
103
273
  sequence: any;
@@ -109,13 +279,11 @@ export default class LocusInfo extends EventsScope {
109
279
  info: any;
110
280
  roles: any;
111
281
  mediaShares: any;
112
- replace: any;
113
282
  url: any;
114
- services: any;
115
- resources: any;
283
+ links?: Links;
116
284
  mainSessionLocusCache: any;
117
285
  self: any;
118
- hashTreeParser?: HashTreeParser;
286
+ hashTreeParsers: Map<string, HashTreeParserEntry>;
119
287
  hashTreeObjectId2ParticipantId: Map<number, string>; // mapping of hash tree object ids to participant ids
120
288
  classicVsHashTreeMismatchMetricCounter = 0;
121
289
 
@@ -137,6 +305,7 @@ export default class LocusInfo extends EventsScope {
137
305
  this.meetingId = meetingId;
138
306
  this.updateMeeting = updateMeeting;
139
307
  this.locusParser = new LocusDeltaParser();
308
+ this.hashTreeParsers = new Map();
140
309
  this.hashTreeObjectId2ParticipantId = new Map();
141
310
  }
142
311
 
@@ -242,7 +411,7 @@ export default class LocusInfo extends EventsScope {
242
411
  'Locus-info:index#doLocusSync --> got full DTO when we asked for delta'
243
412
  );
244
413
  }
245
- meeting.locusInfo.onFullLocus(res.body);
414
+ meeting.locusInfo.onFullLocus('classic Locus sync', res.body);
246
415
  })
247
416
  .catch((e) => {
248
417
  LoggerProxy.logger.info(
@@ -326,13 +495,10 @@ export default class LocusInfo extends EventsScope {
326
495
  init(locus: any = {}) {
327
496
  this.created = locus.created || null;
328
497
  this.scheduledMeeting = locus.meeting || null;
329
- this.participantsUrl = locus.participantsUrl || null;
330
498
  this.replaces = locus.replaces || null;
331
499
  this.aclUrl = locus.aclUrl || null;
332
500
  this.baseSequence = locus.baseSequence || null;
333
501
  this.sequence = locus.sequence || null;
334
- this.membership = locus.membership || null;
335
- this.identities = locus.identities || null;
336
502
  this.participants = locus.participants || null;
337
503
 
338
504
  /**
@@ -352,39 +518,71 @@ export default class LocusInfo extends EventsScope {
352
518
  this.updateControls(locus.controls, locus.self);
353
519
  this.updateLocusUrl(locus.url, ControlsUtils.isMainSessionDTO(locus));
354
520
  this.updateFullState(locus.fullState);
355
- this.updateMeetingInfo(locus.info);
521
+ this.updateMeetingInfo(locus.info, locus.self);
356
522
  this.updateEmbeddedApps(locus.embeddedApps);
357
523
  // self and participants generate sipUrl for 1:1 meeting
358
524
  this.updateSelf(locus.self);
359
525
  this.updateHostInfo(locus.host);
360
526
  this.updateMediaShares(locus.mediaShares);
361
- this.updateServices(locus.links?.services);
362
- this.updateResources(locus.links?.resources);
527
+ this.updateLinks(locus.links);
363
528
  }
364
529
 
365
530
  /**
366
- * Creates the HashTreeParser instance.
367
- * @param {Object} initial locus data
368
- * @returns {void}
531
+ * Creates a HashTreeParser instance for a given locusUrl and stores it in the map.
532
+ * @param {Object} params
533
+ * @param {string} params.locusUrl - the locus URL used as the map key
534
+ * @param {Object} params.initialLocus - initial locus data
535
+ * @param {Object} params.metadata - hash tree metadata
536
+ * @param {string} params.replacedAt - timestamp from Locus indicating when the replacement happened
537
+ * @returns {HashTreeParser} the newly created parser
369
538
  */
370
539
  private createHashTreeParser({
540
+ locusUrl,
371
541
  initialLocus,
542
+ metadata,
543
+ replacedAt,
372
544
  }: {
545
+ locusUrl: string;
373
546
  initialLocus: {
374
547
  dataSets: Array<DataSet>;
375
548
  locus: any;
376
549
  };
377
- }) {
378
- return new HashTreeParser({
550
+ metadata: Metadata | null;
551
+ replacedAt?: string;
552
+ }): HashTreeParser {
553
+ const parser = new HashTreeParser({
379
554
  initialLocus,
555
+ metadata,
380
556
  webexRequest: this.webex.request.bind(this.webex),
381
- locusInfoUpdateCallback: this.updateFromHashTree.bind(this),
382
- debugId: `HT-${this.meetingId.substring(0, 4)}`,
557
+ locusInfoUpdateCallback: this.updateFromHashTree.bind(this, locusUrl),
558
+ debugId: `HT-${locusUrl.split('/')?.pop()?.substring(0, 4)}`,
559
+ excludedDataSets: this.webex.config.meetings.locus?.excludedDataSets,
383
560
  });
561
+
562
+ // When a new HashTreeParser is created, previous one should be stopped.
563
+ // Locus will only be sending us updates for the current one.
564
+ for (const [existingLocusUrl, existingEntry] of this.hashTreeParsers) {
565
+ if (existingEntry.parser.state !== 'stopped') {
566
+ existingEntry.parser.stop();
567
+ if (replacedAt) {
568
+ existingEntry.replacedAt = replacedAt;
569
+ } else {
570
+ LoggerProxy.logger.warn(
571
+ `Locus-info:index#createHashTreeParser --> no replacedAt timestamp provided for new HashTreeParser with locusUrl ${locusUrl}, replacing ${existingLocusUrl}`
572
+ );
573
+ }
574
+ }
575
+ }
576
+
577
+ this.hashTreeParsers.set(locusUrl, {parser, initializedFromHashTree: false});
578
+ this.hashTreeObjectId2ParticipantId.clear();
579
+
580
+ return parser;
384
581
  }
385
582
 
386
583
  /**
387
584
  * @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
585
+ * @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)
388
586
  * @returns {undefined}
389
587
  * @memberof LocusInfo
390
588
  */
@@ -394,6 +592,7 @@ export default class LocusInfo extends EventsScope {
394
592
  trigger: 'join-response';
395
593
  locus: LocusDTO;
396
594
  dataSets?: DataSet[];
595
+ metadata?: Metadata;
397
596
  }
398
597
  | {
399
598
  trigger: 'locus-message';
@@ -403,46 +602,58 @@ export default class LocusInfo extends EventsScope {
403
602
  | {
404
603
  trigger: 'get-loci-response';
405
604
  locus?: LocusDTO;
406
- }
605
+ },
606
+ onLocusSynced?: (locus: LocusDTO) => void
407
607
  ) {
608
+ let initialFullLocus: LocusDTO | null = null;
408
609
  switch (data.trigger) {
409
610
  case 'locus-message':
410
611
  if (data.hashTreeMessage) {
411
- // we need the SELF object to be in the received message, because it contains visibleDataSets
612
+ // we need the Metadata object to be in the received message, because it contains visibleDataSets
412
613
  // and these are needed to initialize all the hash trees
413
- const selfObject = data.hashTreeMessage.locusStateElements?.find((el) => isSelf(el));
614
+ const metadataObject = data.hashTreeMessage.locusStateElements?.find((el) =>
615
+ isMetadata(el)
616
+ );
414
617
 
415
- if (!selfObject?.data?.visibleDataSets) {
416
- LoggerProxy.logger.warn(
417
- `Locus-info:index#initialSetup --> cannot initialize HashTreeParser, SELF object with visibleDataSets is missing in the message`
618
+ if (!metadataObject?.data?.visibleDataSets) {
619
+ // this is a common case (not an error)
620
+ // it happens for example after we leave the meeting and still get some heartbeats or delayed messages
621
+ LoggerProxy.logger.info(
622
+ `Locus-info:index#initialSetup --> cannot initialize HashTreeParser, Metadata object with visibleDataSets is missing in the message`
418
623
  );
419
624
 
420
- throw new Error('SELF object with visibleDataSets is missing in the message');
625
+ // throw so that handleLocusEvent() catches it and destroys the partially created meeting object
626
+ throw new Error('Metadata object with visibleDataSets is missing in the message');
421
627
  }
422
628
 
423
629
  LoggerProxy.logger.info(
424
630
  'Locus-info:index#initialSetup --> creating HashTreeParser from message'
425
631
  );
426
632
  // first create the HashTreeParser, but don't initialize it with any data yet
427
- // pass just a fake locus that contains only the visibleDataSets
428
- this.hashTreeParser = this.createHashTreeParser({
633
+ const hashTreeParser = this.createHashTreeParser({
634
+ locusUrl: data.hashTreeMessage.locusUrl,
429
635
  initialLocus: {
430
- locus: {self: {visibleDataSets: selfObject.data.visibleDataSets}},
431
- dataSets: [], // empty, because they will be populated in initializeFromMessage() call // dataSets: data.hashTreeMessage.dataSets,
636
+ locus: null,
637
+ dataSets: data.hashTreeMessage.dataSets,
638
+ },
639
+ metadata: {
640
+ htMeta: metadataObject.htMeta,
641
+ visibleDataSets: metadataObject.data.visibleDataSets,
432
642
  },
433
643
  });
434
644
 
435
645
  // now handle the message - that should populate all the visible datasets
436
- await this.hashTreeParser.initializeFromMessage(data.hashTreeMessage);
646
+ await hashTreeParser.initializeFromMessage(data.hashTreeMessage);
437
647
  } else {
438
648
  // "classic" Locus case, no hash trees involved
439
649
  this.updateLocusCache(data.locus);
440
- this.onFullLocus(data.locus, undefined);
650
+ this.onFullLocus('classic locus message', data.locus, undefined);
441
651
  }
442
652
  break;
443
653
  case 'join-response':
444
654
  this.updateLocusCache(data.locus);
445
- this.onFullLocus(data.locus, undefined, data.dataSets);
655
+ this.onFullLocus('join response', data.locus, undefined, data.dataSets, data.metadata);
656
+ initialFullLocus = data.locus;
446
657
  break;
447
658
  case 'get-loci-response':
448
659
  if (data.locus?.links?.resources?.visibleDataSets?.url) {
@@ -450,54 +661,117 @@ export default class LocusInfo extends EventsScope {
450
661
  'Locus-info:index#initialSetup --> creating HashTreeParser from get-loci-response'
451
662
  );
452
663
  // first create the HashTreeParser, but don't initialize it with any data yet
453
- // pass just a fake locus that contains only the visibleDataSets
454
- this.hashTreeParser = this.createHashTreeParser({
664
+ const hashTreeParser = this.createHashTreeParser({
665
+ locusUrl: data.locus.url as string,
455
666
  initialLocus: {
456
- locus: {self: {visibleDataSets: data.locus?.self?.visibleDataSets}},
667
+ locus: null,
457
668
  dataSets: [], // empty, because we don't have them yet
458
669
  },
670
+ metadata: null, // get-loci-response doesn't contain Metadata object
459
671
  });
460
672
 
461
673
  // now initialize all the data
462
- await this.hashTreeParser.initializeFromGetLociResponse(data.locus);
674
+ await hashTreeParser.initializeFromGetLociResponse(data.locus);
463
675
  } else {
464
676
  // "classic" Locus case, no hash trees involved
465
677
  this.updateLocusCache(data.locus);
466
- this.onFullLocus(data.locus, undefined);
678
+ this.onFullLocus('classic get-loci-response', data.locus, undefined);
679
+ initialFullLocus = data.locus || null;
467
680
  }
468
681
  }
682
+
683
+ if (onLocusSynced) {
684
+ try {
685
+ onLocusSynced(initialFullLocus || this.getCurrentLocusSnapshot());
686
+ } catch (error) {
687
+ LoggerProxy.logger.warn(
688
+ `Locus-info:index#initialSetup --> onLocusSynced callback failed: ${error}`
689
+ );
690
+ }
691
+ }
692
+
469
693
  // Change it to true after it receives it first locus object
470
694
  this.emitChange = true;
471
695
  }
472
696
 
697
+ /**
698
+ * Builds a full locus DTO snapshot from current internal locus state.
699
+ *
700
+ * @returns {LocusDTO}
701
+ */
702
+ private getCurrentLocusSnapshot(): LocusDTO {
703
+ const locus: Record<string, any> = {};
704
+
705
+ LocusDtoTopLevelKeys.forEach((key) => {
706
+ const value = (this as Record<string, any>)[key];
707
+
708
+ if (value !== undefined && value !== null) {
709
+ locus[key] = cloneDeep(value);
710
+ }
711
+ });
712
+
713
+ if (!Array.isArray(locus.participants)) {
714
+ locus.participants = [];
715
+ }
716
+
717
+ return locus as LocusDTO;
718
+ }
719
+
473
720
  /**
474
721
  * Handles HTTP response from Locus API call.
475
722
  * @param {Meeting} meeting meeting object
476
723
  * @param {LocusApiResponseBody} responseBody body of the http response from Locus API call
477
724
  * @returns {void}
478
725
  */
479
- handleLocusAPIResponse(meeting, responseBody: LocusApiResponseBody): void {
480
- if (this.hashTreeParser) {
481
- // API responses with hash tree are a bit problematic and not fully confirmed how they will look like
482
- // we don't really need them, because all updates are guaranteed to come via Mercury or LLM messages anyway
483
- // so it's OK to skip them for now
484
- LoggerProxy.logger.info(
485
- 'Locus-info:index#handleLocusAPIResponse: skipping handling of API http response with hashTreeParser'
486
- );
487
- } else {
488
- if (responseBody.dataSets) {
489
- this.sendClassicVsHashTreeMismatchMetric(
490
- meeting,
491
- `unexpected hash tree dataSets in API response`
492
- );
726
+ handleLocusAPIResponse(meeting: any, responseBody: LocusApiResponseBody): void {
727
+ const isWrapped = 'locus' in responseBody;
728
+ const locusUrl = isWrapped ? responseBody.locus?.url : responseBody.url;
729
+ const hashTreeParserEntry = locusUrl && this.hashTreeParsers.get(locusUrl);
730
+ const locus = isWrapped
731
+ ? (responseBody as {locus: LocusDTO}).locus
732
+ : (responseBody as LocusDTO);
733
+
734
+ if (this.hashTreeParsers.size > 0) {
735
+ // We are in hash tree mode. Check if we need to create/reactivate a parser for this locusUrl.
736
+ if (!hashTreeParserEntry || hashTreeParserEntry.parser.state === 'stopped') {
737
+ if (!locusUrl) {
738
+ LoggerProxy.logger.warn(
739
+ 'Locus-info:index#handleLocusAPIResponse --> API response has no locusUrl, cannot handle hash tree parser switch'
740
+ );
741
+
742
+ return;
743
+ }
744
+
745
+ this.handleHashTreeParserSwitchForAPIResponse(locusUrl, locus);
746
+
747
+ return;
748
+ }
749
+
750
+ // Active parser found - pass the API response to it
751
+ if (isWrapped) {
752
+ // update the data in our hash trees
753
+ hashTreeParserEntry.parser.handleLocusUpdate(responseBody);
754
+ } else {
755
+ // LocusDTO without wrapper - pass it through as if it had no dataSets nor metadata
756
+ hashTreeParserEntry.parser.handleLocusUpdate({locus: responseBody});
493
757
  }
494
- // classic Locus delta
495
- this.handleLocusDelta(responseBody.locus, meeting);
758
+
759
+ return;
760
+ }
761
+
762
+ // No hash tree parsers - classic Locus mode
763
+ if (isWrapped && responseBody.dataSets) {
764
+ this.sendClassicVsHashTreeMismatchMetric(
765
+ meeting,
766
+ `unexpected hash tree dataSets in API response`
767
+ );
496
768
  }
769
+
770
+ // classic Locus delta
771
+ this.handleLocusDelta(locus, meeting);
497
772
  }
498
773
 
499
774
  /**
500
- *
501
775
  * @param {HashTreeObject} object data set object
502
776
  * @param {any} locus
503
777
  * @returns {void}
@@ -505,29 +779,39 @@ export default class LocusInfo extends EventsScope {
505
779
  updateLocusFromHashTreeObject(object: HashTreeObject, locus: LocusDTO): LocusDTO {
506
780
  const type = object.htMeta.elementId.type.toLowerCase();
507
781
 
782
+ const addParticipantObject = (obj: HashTreeObject) => {
783
+ if (!locus.participants) {
784
+ locus.participants = [];
785
+ }
786
+ locus.participants.push(obj.data);
787
+ this.hashTreeObjectId2ParticipantId.set(obj.htMeta.elementId.id, obj.data.id);
788
+ };
789
+
508
790
  switch (type) {
509
791
  case ObjectType.locus: {
510
792
  if (!object.data) {
511
793
  // not doing anything here, as we need Locus to always be there (at least some fields)
512
794
  // and that's already taken care of in updateFromHashTree()
513
795
  LoggerProxy.logger.info(
514
- `Locus-info:index#updateLocusFromHashTreeObject --> LOCUS object removed`
796
+ `Locus-info:index#updateLocusFromHashTreeObject --> LOCUS object removed, version=${object.htMeta.elementId.version}`
515
797
  );
516
798
 
517
799
  return locus;
518
800
  }
519
801
  // replace the main locus
520
802
 
521
- // The Locus object we receive from backend has empty participants, so removing them to avoid it overriding the ones in our current locus object
522
- // Also, other fields like mediaShares are managed by other ObjectType updates, so removing them too
523
- // BTW, it also doesn't have "self". That's OK as it won't override existing locus.self and also existing SDK code can handle that missing self in Locus updates
803
+ // The Locus object we receive from backend has empty participants array,
804
+ // and may have (although it shouldn't) other fields that are managed by other ObjectTypes
805
+ // like "fullState" or "info", so we're making sure to delete them here
524
806
  const locusObjectFromData = object.data;
525
- delete locusObjectFromData.participants;
526
- delete locusObjectFromData.mediaShares;
807
+
808
+ Object.values(ObjectTypeToLocusKeyMap).forEach((locusDtoKey) => {
809
+ delete locusObjectFromData[locusDtoKey];
810
+ });
527
811
 
528
812
  locus = {...locus, ...locusObjectFromData};
529
813
  LoggerProxy.logger.info(
530
- `Locus-info:index#updateLocusFromHashTreeObject --> LOCUS object updated`
814
+ `Locus-info:index#updateLocusFromHashTreeObject --> LOCUS object updated to version=${object.htMeta.elementId.version}`
531
815
  );
532
816
  break;
533
817
  }
@@ -540,7 +824,7 @@ export default class LocusInfo extends EventsScope {
540
824
  object.data.name === 'content'
541
825
  ? `floor=${object.data.floor?.disposition}, ${object.data.floor?.beneficiary?.id}`
542
826
  : ''
543
- }`
827
+ } version=${object.htMeta.elementId.version}`
544
828
  );
545
829
  const existingMediaShare = locus.mediaShares?.find(
546
830
  (ms) => ms.htMeta.elementId.id === object.htMeta.elementId.id
@@ -554,27 +838,46 @@ export default class LocusInfo extends EventsScope {
554
838
  }
555
839
  } else {
556
840
  LoggerProxy.logger.info(
557
- `Locus-info:index#updateLocusFromHashTreeObject --> mediaShare id=${object.htMeta.elementId.id} removed`
841
+ `Locus-info:index#updateLocusFromHashTreeObject --> mediaShare id=${object.htMeta.elementId.id} removed, version=${object.htMeta.elementId.version}`
558
842
  );
559
843
  locus.mediaShares = locus.mediaShares?.filter(
560
844
  (ms) => ms.htMeta.elementId.id !== object.htMeta.elementId.id
561
845
  );
562
846
  }
563
847
  break;
848
+ case ObjectType.embeddedApp:
849
+ if (object.data) {
850
+ LoggerProxy.logger.info(
851
+ `Locus-info:index#updateLocusFromHashTreeObject --> embeddedApp id=${object.htMeta.elementId.id} url='${object.data.url}' updated version=${object.htMeta.elementId.version}:`,
852
+ object.data
853
+ );
854
+ const existingEmbeddedApp = locus.embeddedApps?.find(
855
+ (ms) => ms.htMeta.elementId.id === object.htMeta.elementId.id
856
+ );
857
+
858
+ if (existingEmbeddedApp) {
859
+ Object.assign(existingEmbeddedApp, object.data);
860
+ } else {
861
+ locus.embeddedApps = locus.embeddedApps || [];
862
+ locus.embeddedApps.push(object.data);
863
+ }
864
+ } else {
865
+ LoggerProxy.logger.info(
866
+ `Locus-info:index#updateLocusFromHashTreeObject --> embeddedApp id=${object.htMeta.elementId.id} removed, version=${object.htMeta.elementId.version}`
867
+ );
868
+ locus.embeddedApps = locus.embeddedApps?.filter(
869
+ (ms) => ms.htMeta.elementId.id !== object.htMeta.elementId.id
870
+ );
871
+ }
872
+ break;
564
873
  case ObjectType.participant:
565
874
  LoggerProxy.logger.info(
566
875
  `Locus-info:index#updateLocusFromHashTreeObject --> participant id=${
567
876
  object.htMeta.elementId.id
568
- } ${object.data ? 'updated' : 'removed'}`
877
+ } ${object.data ? 'updated' : 'removed'} version=${object.htMeta.elementId.version}`
569
878
  );
570
879
  if (object.data) {
571
- if (!locus.participants) {
572
- locus.participants = [];
573
- }
574
- const participantObject = object.data;
575
- participantObject.htMeta = object.htMeta;
576
- locus.participants.push(participantObject);
577
- this.hashTreeObjectId2ParticipantId.set(object.htMeta.elementId.id, participantObject.id);
880
+ addParticipantObject(object);
578
881
  } else {
579
882
  const participantId = this.hashTreeObjectId2ParticipantId.get(object.htMeta.elementId.id);
580
883
 
@@ -584,20 +887,91 @@ export default class LocusInfo extends EventsScope {
584
887
  locus.jsSdkMeta.removedParticipantIds.push(participantId);
585
888
  this.hashTreeObjectId2ParticipantId.delete(object.htMeta.elementId.id);
586
889
  }
890
+ // Create self from the participant if it matches self identity and is being moved.
891
+ // We need this, because participant update comes in LLM message often before the self update from Mercury.
892
+ // Other parts of the code detect move only by looking at self, while some other parts of the SDK/webapp code
893
+ // look at participant for roles etc, so if participant is updated but not self, then it looks like we our lost roles temporarily
894
+ // (until self is updated)
895
+ // This will be fixed properly in SPARK-790239
896
+ if (
897
+ object.data &&
898
+ object.data.identity === locus.self?.identity &&
899
+ object.data.state === 'LEFT' &&
900
+ object.data.reason === 'MOVED'
901
+ ) {
902
+ LoggerProxy.logger.info(
903
+ `Locus-info:index#updateLocusFromHashTreeObject --> FOUND a match for MOVED self in participant object ${object.htMeta.elementId.id}`
904
+ );
905
+ Object.assign(locus[ObjectTypeToLocusKeyMap[ObjectType.self]], object.data);
906
+ }
587
907
  break;
908
+ case ObjectType.control:
909
+ if (object.data) {
910
+ Object.keys(object.data).forEach((controlKey) => {
911
+ LoggerProxy.logger.info(
912
+ `Locus-info:index#updateLocusFromHashTreeObject --> control ${controlKey} updated:`,
913
+ object.data[controlKey]
914
+ );
915
+ if (!locus.controls) {
916
+ locus.controls = {};
917
+ }
918
+ locus.controls[controlKey] = object.data[controlKey];
919
+ });
920
+ } else {
921
+ LoggerProxy.logger.warn(
922
+ `Locus-info:index#updateLocusFromHashTreeObject --> control object update without data - this is not expected!`
923
+ );
924
+ }
925
+ break;
926
+ case ObjectType.links:
927
+ case ObjectType.info:
928
+ case ObjectType.fullState:
588
929
  case ObjectType.self:
589
930
  if (!object.data) {
590
931
  // self without data is handled inside HashTreeParser and results in LocusInfoUpdateType.MEETING_ENDED, so we should never get here
591
- LoggerProxy.logger.warn(
592
- `Locus-info:index#updateLocusFromHashTreeObject --> received SELF object without data, this is not expected!`
932
+ // all other types info, fullstate, etc - Locus should never send them without data
933
+ // but we end up with this method being called without the data for them when the main dataset is removed from visible datasets list
934
+ LoggerProxy.logger.info(
935
+ `Locus-info:index#updateLocusFromHashTreeObject --> received ${type} object without data, version=${object.htMeta.elementId.version}`
936
+ );
937
+ } else {
938
+ LoggerProxy.logger.info(
939
+ `Locus-info:index#updateLocusFromHashTreeObject --> ${type} object updated to version ${object.htMeta.elementId.version}`
593
940
  );
594
941
 
595
- return locus;
942
+ if (type === ObjectType.self) {
943
+ LoggerProxy.logger.info(
944
+ `Locus-info:index#updateLocusFromHashTreeObject --> self data: removed=${object.data.removed} state=${object.data.state} reason=${object.data.reason}`
945
+ );
946
+ }
947
+
948
+ const locusDtoKey = ObjectTypeToLocusKeyMap[type] as keyof LocusDTO;
949
+ locus[locusDtoKey] = object.data;
950
+
951
+ /* Hash tree based webinar attendees don't receive a Participant object for themselves from Locus,
952
+ but a lot of existing code in SDK and web app expects a member object for self to exist,
953
+ so whenever SELF changes for a webinar attendee, we copy it into a participant object.
954
+ We can do it, because SELF has always all the same properties as a participant object.
955
+ */
956
+ if (
957
+ type === ObjectType.self &&
958
+ locus.info?.isWebinar &&
959
+ object.data.controls?.role?.roles?.find(
960
+ (r) => r.type === SELF_ROLES.ATTENDEE && r.hasRole
961
+ )
962
+ ) {
963
+ LoggerProxy.logger.info(
964
+ `Locus-info:index#updateLocusFromHashTreeObject --> webinar attendee: creating participant object from self`
965
+ );
966
+ addParticipantObject(object);
967
+ }
596
968
  }
969
+ break;
970
+ case ObjectType.metadata:
597
971
  LoggerProxy.logger.info(
598
- `Locus-info:index#updateLocusFromHashTreeObject --> SELF object updated`
972
+ `Locus-info:index#updateLocusFromHashTreeObject --> metadata object updated to version ${object.htMeta.elementId.version}`
599
973
  );
600
- locus.self = object.data;
974
+ // we don't use hash tree metadata right now for anything, it's mainly used internally by HashTreeParser
601
975
  break;
602
976
  default:
603
977
  LoggerProxy.logger.warn(
@@ -631,6 +1005,176 @@ export default class LocusInfo extends EventsScope {
631
1005
  }
632
1006
  }
633
1007
 
1008
+ /**
1009
+ * Helper that handles the common logic for reactivating a stopped HashTreeParser when
1010
+ * a newer "replaces" is detected. Used by both the message and API response parser switch methods.
1011
+ *
1012
+ * @param {string} callerName - name of the calling method, used in log messages
1013
+ * @param {string} locusUrl - the locus URL of the stopped parser
1014
+ * @param {HashTreeParserEntry} stoppedEntry - the stopped parser entry
1015
+ * @param {ReplacesInfo} replaces - replacement info extracted from self
1016
+ * @param {Function} resumeCallback - callback to invoke after reactivation to resume the parser
1017
+ * @returns {void}
1018
+ */
1019
+ private resumeStoppedParser(
1020
+ callerName: string,
1021
+ locusUrl: string,
1022
+ stoppedEntry: HashTreeParserEntry,
1023
+ replaces: ReplacesInfo | undefined,
1024
+ resumeCallback: () => void
1025
+ ): void {
1026
+ // this check is just for typescript, it should never happen, replaces should always be defined
1027
+ if (!replaces) {
1028
+ LoggerProxy.logger.info(
1029
+ `Locus-info:index#${callerName} --> received data for stopped HashTreeParser with locusUrl ${locusUrl}, but no replaces info provided, so not re-activating the parser`
1030
+ );
1031
+
1032
+ return;
1033
+ }
1034
+
1035
+ if (replaces.replacedAt <= (stoppedEntry.replacedAt || '')) {
1036
+ LoggerProxy.logger.info(
1037
+ `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`
1038
+ );
1039
+
1040
+ return;
1041
+ }
1042
+
1043
+ LoggerProxy.logger.info(
1044
+ `Locus-info:index#${callerName} --> reactivating HashTreeParser for locusUrl=${locusUrl}, which replaces ${replaces.locusUrl}`
1045
+ );
1046
+
1047
+ const replacedEntry = this.hashTreeParsers.get(replaces.locusUrl);
1048
+
1049
+ if (replacedEntry) {
1050
+ replacedEntry.replacedAt = replaces.replacedAt;
1051
+ replacedEntry.parser.stop();
1052
+ } else {
1053
+ LoggerProxy.logger.warn(
1054
+ `Locus-info:index#${callerName} --> the parser that is supposed to be replaced with the currently reactivated parser is not found, locusUrl=${replaces.locusUrl}`
1055
+ );
1056
+ }
1057
+
1058
+ stoppedEntry.initializedFromHashTree = false;
1059
+ this.hashTreeObjectId2ParticipantId.clear();
1060
+
1061
+ resumeCallback();
1062
+ }
1063
+
1064
+ /**
1065
+ * Handles an API response whose locusUrl doesn't match any active HashTreeParser
1066
+ * (either no entry exists, or the existing entry is stopped).
1067
+ * Creates a new parser or reactivates a stopped one using initializeFromGetLociResponse.
1068
+ *
1069
+ * @param {string} locusUrl - the locus URL from the API response
1070
+ * @param {LocusDTO} locus - the locus DTO from the API response
1071
+ * @returns {void}
1072
+ */
1073
+ private handleHashTreeParserSwitchForAPIResponse(locusUrl: string, locus: LocusDTO): void {
1074
+ const entry = this.hashTreeParsers.get(locusUrl);
1075
+
1076
+ const replaces = getReplaceInfoFromSelf(
1077
+ locus.self,
1078
+ // @ts-ignore
1079
+ this.webex.internal.device.url
1080
+ );
1081
+
1082
+ if (!entry) {
1083
+ LoggerProxy.logger.info(
1084
+ `Locus-info:index#handleHashTreeParserSwitchForAPIResponse --> no parser for locusUrl ${locusUrl}, creating a new one`
1085
+ );
1086
+
1087
+ const parser = this.createHashTreeParser({
1088
+ locusUrl,
1089
+ initialLocus: {locus: null, dataSets: []},
1090
+ metadata: null,
1091
+ replacedAt: replaces?.replacedAt,
1092
+ });
1093
+
1094
+ parser.initializeFromGetLociResponse(locus);
1095
+
1096
+ return;
1097
+ }
1098
+
1099
+ if (entry.parser.state !== 'stopped') {
1100
+ LoggerProxy.logger.warn(
1101
+ `Locus-info:index#handleHashTreeParserSwitchForAPIResponse --> unexpected parser state "${entry.parser.state}" for locusUrl ${locusUrl}`
1102
+ );
1103
+
1104
+ return;
1105
+ }
1106
+
1107
+ this.resumeStoppedParser(
1108
+ 'handleHashTreeParserSwitchForAPIResponse',
1109
+ locusUrl,
1110
+ entry,
1111
+ replaces,
1112
+ () => entry.parser.resumeFromApiResponse(locus)
1113
+ );
1114
+ }
1115
+
1116
+ /**
1117
+ * Checks if the hash tree message should trigger a switch to a different HashTreeParser
1118
+ *
1119
+ * @param {HashTreeMessage} message incoming hash tree message
1120
+ * @returns {boolean} true if the message was handled as a parser switch, false otherwise
1121
+ */
1122
+ private handleHashTreeParserSwitch(message: HashTreeMessage): boolean {
1123
+ const entry = this.hashTreeParsers.get(message.locusUrl);
1124
+
1125
+ const self = message.locusStateElements?.find((el) => isSelf(el))?.data;
1126
+ const replaces = getReplaceInfoFromSelf(
1127
+ self,
1128
+ // @ts-ignore
1129
+ this.webex.internal.device.url
1130
+ );
1131
+
1132
+ if (!entry) {
1133
+ // Metadata object that contains information about visible datasets is needed to initialize the HashTreeParser,
1134
+ // but it's buried inside the message, we need to find it and pass it to HashTreeParser constructor
1135
+ const metadata = message.locusStateElements?.find((el) => isMetadata(el));
1136
+
1137
+ if (metadata && metadata.data?.visibleDataSets?.length > 0) {
1138
+ LoggerProxy.logger.info(
1139
+ `Locus-info:index#handleHashTreeParserSwitch --> no hash tree parser found for locusUrl ${message.locusUrl}, creating a new one`
1140
+ );
1141
+
1142
+ const parser = this.createHashTreeParser({
1143
+ locusUrl: message.locusUrl,
1144
+ initialLocus: {
1145
+ locus: null,
1146
+ dataSets: message.dataSets,
1147
+ },
1148
+ metadata: {
1149
+ htMeta: metadata.htMeta,
1150
+ visibleDataSets: metadata.data.visibleDataSets,
1151
+ },
1152
+ replacedAt: replaces?.replacedAt,
1153
+ });
1154
+
1155
+ // handle the message with the new parser
1156
+ parser.handleMessage(message);
1157
+ }
1158
+
1159
+ return true;
1160
+ }
1161
+ if (entry.parser.state === 'stopped') {
1162
+ // 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
1163
+ // this happens when you move from breakout A -> breakout B -> back to breakout A
1164
+ this.resumeStoppedParser(
1165
+ 'handleHashTreeParserSwitch',
1166
+ message.locusUrl,
1167
+ entry,
1168
+ replaces,
1169
+ () => entry.parser.resumeFromMessage(message)
1170
+ );
1171
+
1172
+ return true;
1173
+ }
1174
+
1175
+ return false;
1176
+ }
1177
+
634
1178
  /**
635
1179
  * Handles a hash tree message received from Locus.
636
1180
  *
@@ -649,33 +1193,61 @@ export default class LocusInfo extends EventsScope {
649
1193
  return;
650
1194
  }
651
1195
 
652
- this.hashTreeParser.handleMessage(message);
1196
+ const parserSwitched = this.handleHashTreeParserSwitch(message);
1197
+
1198
+ if (parserSwitched) {
1199
+ return;
1200
+ }
1201
+
1202
+ const entry = this.hashTreeParsers.get(message.locusUrl);
1203
+
1204
+ // the check is just for typescript, the case of no entry in hashTreeParsers is handled in handleHashTreeParserSwitch() above
1205
+ if (entry) {
1206
+ entry.parser.handleMessage(message);
1207
+ }
1208
+ }
1209
+
1210
+ /**
1211
+ * Triggers a sync of all hash tree datasets for all hash tree parsers associated with this meeting.
1212
+ * The syncs are executed sequentially within each parser.
1213
+ *
1214
+ * @param {Object} [options={}] - Options for syncing
1215
+ * @param {boolean} [options.onlyLLM=false] - Whether to sync only LLM based data sets
1216
+ * @returns {Promise<void>}
1217
+ */
1218
+ async syncAllHashTreeDatasets(options: {onlyLLM?: boolean} = {}): Promise<void> {
1219
+ for (const [, entry] of this.hashTreeParsers) {
1220
+ if (entry.parser) {
1221
+ // eslint-disable-next-line no-await-in-loop
1222
+ await entry.parser.syncAllDatasets(options);
1223
+ }
1224
+ }
653
1225
  }
654
1226
 
655
1227
  /**
656
1228
  * Callback registered with HashTreeParser to receive locus info updates.
657
1229
  * Updates our locus info based on the data parsed by the hash tree parser.
658
1230
  *
659
- * @param {LocusInfoUpdateType} updateType - The type of update received.
660
- * @param {Object} [data] - Additional data for the update, if applicable.
1231
+ * @param {string} locusUrl - the locus URL for which the update is received
1232
+ * @param {LocusInfoUpdate} update - Details about the update.
661
1233
  * @returns {void}
662
1234
  */
663
- private updateFromHashTree(
664
- updateType: LocusInfoUpdateType,
665
- data?: {updatedObjects: HashTreeObject[]}
666
- ) {
667
- switch (updateType) {
1235
+ private updateFromHashTree(locusUrl: string, update: LocusInfoUpdate) {
1236
+ switch (update.updateType) {
668
1237
  case LocusInfoUpdateType.OBJECTS_UPDATED: {
669
1238
  // initialize our new locus
670
1239
  let locus: LocusDTO = {
671
1240
  participants: [],
672
- jsSdkMeta: {removedParticipantIds: []},
1241
+ jsSdkMeta: {
1242
+ removedParticipantIds: [],
1243
+ forceReplaceMembers: false,
1244
+ },
673
1245
  };
674
1246
 
675
1247
  // first go over all the updates and check what happens with the main locus object
676
1248
  let locusObjectStateAfterUpdates: LocusObjectStateAfterUpdates =
677
1249
  LocusObjectStateAfterUpdates.unchanged;
678
- data.updatedObjects.forEach((object) => {
1250
+ update.updatedObjects.forEach((object) => {
679
1251
  if (object.htMeta.elementId.type.toLowerCase() === ObjectType.locus) {
680
1252
  if (locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.updated) {
681
1253
  // this code doesn't supported it right now,
@@ -702,34 +1274,64 @@ export default class LocusInfo extends EventsScope {
702
1274
  }
703
1275
  });
704
1276
 
705
- // if Locus object is unchanged or removed, we need to keep using the existing locus
706
- // because the rest of the locusInfo code expects locus to always be present (with at least some of the fields)
707
- // if it gets updated, we don't need to do anything and we start with an empty one
708
- // so that when it gets updated, if the new one is missing some field, that field will
709
- // be removed from our locusInfo
710
- if (
1277
+ const hashTreeParserEntry = this.hashTreeParsers.get(locusUrl);
1278
+
1279
+ if (!hashTreeParserEntry) {
1280
+ LoggerProxy.logger.warn(
1281
+ `Locus-info:index#updateFromHashTree --> no HashTreeParser found for locusUrl ${locusUrl} when trying to apply updates from hash tree`
1282
+ );
1283
+
1284
+ return;
1285
+ }
1286
+
1287
+ if (!hashTreeParserEntry.initializedFromHashTree) {
1288
+ // this is the first time we're getting an update for this locusUrl,
1289
+ // so it's probably a move to/from breakout. We need to start from a clean state,
1290
+ // so empty locus and we rely on Locus giving us sufficient data in the updates to populate it.
1291
+ LoggerProxy.logger.info(
1292
+ `Locus-info:index#updateFromHashTree --> first INITIAL update for locusUrl ${locusUrl}, starting from empty state`
1293
+ );
1294
+ hashTreeParserEntry.initializedFromHashTree = true;
1295
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1296
+ locus.jsSdkMeta!.forceReplaceMembers = true;
1297
+ } else if (
1298
+ // if Locus object is unchanged or removed, we need to keep using the existing locus
1299
+ // because the rest of the locusInfo code expects locus to always be present (with at least some of the fields)
1300
+ // if it gets updated, we only need to have the fields that are not part of "locus" object (like "info" or "mediaShares")
1301
+ // so that when Locus object gets updated, if the new one is missing some field, that field will
1302
+ // be removed from our locusInfo
711
1303
  locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.unchanged ||
712
1304
  locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.removed
713
1305
  ) {
714
- // copy over existing locus
1306
+ // copy over all of existing locus except participants
715
1307
  LocusDtoTopLevelKeys.forEach((key) => {
716
1308
  if (key !== 'participants') {
717
- locus[key] = cloneDeep(this[key]);
1309
+ (locus as Record<string, any>)[key] = cloneDeep((this as Record<string, any>)[key]);
1310
+ }
1311
+ });
1312
+ } else {
1313
+ // initialize only the fields that are not part of main "Locus" object
1314
+ // (except participants, which need to stay empty - that means "no participant changes")
1315
+ Object.values(ObjectTypeToLocusKeyMap).forEach((locusDtoKey) => {
1316
+ if (locusDtoKey !== 'participants') {
1317
+ (locus as Record<string, any>)[locusDtoKey] = cloneDeep(
1318
+ (this as Record<string, any>)[locusDtoKey]
1319
+ );
718
1320
  }
719
1321
  });
720
1322
  }
721
1323
 
722
1324
  LoggerProxy.logger.info(
723
1325
  `Locus-info:index#updateFromHashTree --> LOCUS object is ${locusObjectStateAfterUpdates}, all updates: ${JSON.stringify(
724
- data.updatedObjects.map((o) => ({
1326
+ update.updatedObjects.map((o) => ({
725
1327
  type: o.htMeta.elementId.type,
726
1328
  id: o.htMeta.elementId.id,
727
- hasData: o.data !== undefined,
1329
+ hasData: !!o.data,
728
1330
  }))
729
1331
  )}`
730
1332
  );
731
1333
  // now apply all the updates from the hash tree onto the locus
732
- data.updatedObjects.forEach((object) => {
1334
+ update.updatedObjects.forEach((object) => {
733
1335
  locus = this.updateLocusFromHashTreeObject(object, locus);
734
1336
  });
735
1337
 
@@ -740,11 +1342,29 @@ export default class LocusInfo extends EventsScope {
740
1342
  }
741
1343
 
742
1344
  case LocusInfoUpdateType.MEETING_ENDED: {
1345
+ const meeting = this.webex.meetings.meetingCollection.get(this.meetingId);
1346
+
1347
+ if (meeting) {
1348
+ LoggerProxy.logger.info(
1349
+ `Locus-info:index#updateFromHashTree --> received signal that meeting ended, destroying meeting ${this.meetingId}`
1350
+ );
1351
+ this.webex.meetings.destroy(meeting, MEETING_REMOVED_REASON.SELF_REMOVED);
1352
+ }
1353
+ break;
1354
+ }
1355
+
1356
+ case LocusInfoUpdateType.LOCUS_NOT_FOUND: {
743
1357
  LoggerProxy.logger.info(
744
- `Locus-info:index#updateFromHashTree --> received signal that meeting ended, destroying meeting ${this.meetingId}`
1358
+ `Locus-info:index#updateFromHashTree --> received LOCUS_NOT_FOUND for ${locusUrl}, triggering syncMeetings`
745
1359
  );
746
- const meeting = this.webex.meetings.meetingCollection.get(this.meetingId);
747
- this.webex.meetings.destroy(meeting, MEETING_REMOVED_REASON.SELF_REMOVED);
1360
+ this.webex.meetings
1361
+ .syncMeetings({keepOnlyLocusMeetings: false, skipHashTreeSync: true})
1362
+ .catch((syncError) => {
1363
+ LoggerProxy.logger.error(
1364
+ `Locus-info:index#updateFromHashTree --> syncMeetings failed after LOCUS_NOT_FOUND: ${syncError}`
1365
+ );
1366
+ });
1367
+ break;
748
1368
  }
749
1369
  }
750
1370
  }
@@ -756,15 +1376,31 @@ export default class LocusInfo extends EventsScope {
756
1376
  * @memberof LocusInfo
757
1377
  */
758
1378
  parse(meeting: any, data: any) {
759
- if (this.hashTreeParser) {
760
- this.handleHashTreeMessage(
761
- meeting,
762
- data.eventType,
763
- data.stateElementsMessage as HashTreeMessage
764
- );
1379
+ if (this.hashTreeParsers.size > 0) {
1380
+ if (data.eventType === LOCUSEVENT.SDK_LOCUS_FROM_SYNC_MEETINGS) {
1381
+ // sync meetings response follows the format of "not wrapped" locus API responses,
1382
+ // so has no dataSets nor Metadata
1383
+ this.handleLocusAPIResponse(meeting, {...data.locus});
1384
+ } else {
1385
+ this.handleHashTreeMessage(
1386
+ meeting,
1387
+ data.eventType,
1388
+ data.stateElementsMessage as HashTreeMessage
1389
+ );
1390
+ }
765
1391
  } else {
766
- // eslint-disable-next-line @typescript-eslint/no-shadow
767
1392
  const {eventType} = data;
1393
+
1394
+ if (eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED) {
1395
+ // this can happen when we get an event before join http response
1396
+ // it's OK to just ignore it
1397
+ LoggerProxy.logger.info(
1398
+ `Locus-info:index#parse --> received locus hash tree event before hashTreeParser is created`
1399
+ );
1400
+
1401
+ return;
1402
+ }
1403
+
768
1404
  const locus = this.getTheLocusToUpdate(data.locus);
769
1405
  LoggerProxy.logger.info(`Locus-info:index#parse --> received locus data: ${eventType}`);
770
1406
 
@@ -785,17 +1421,11 @@ export default class LocusInfo extends EventsScope {
785
1421
  case LOCUSEVENT.PARTICIPANT_DECLINED:
786
1422
  case LOCUSEVENT.FLOOR_GRANTED:
787
1423
  case LOCUSEVENT.FLOOR_RELEASED:
788
- this.onFullLocus(locus, eventType);
1424
+ this.onFullLocus(`classic locus event ${eventType}`, locus, eventType);
789
1425
  break;
790
1426
  case LOCUSEVENT.DIFFERENCE:
791
1427
  this.handleLocusDelta(locus, meeting);
792
1428
  break;
793
- case LOCUSEVENT.HASH_TREE_DATA_UPDATED:
794
- this.sendClassicVsHashTreeMismatchMetric(
795
- meeting,
796
- `got ${eventType}, expected classic events`
797
- );
798
- break;
799
1429
 
800
1430
  default:
801
1431
  // Why will there be a event with no eventType ????
@@ -819,46 +1449,64 @@ export default class LocusInfo extends EventsScope {
819
1449
  /**
820
1450
  * Function for handling full locus when it's using hash trees (so not the "classic" one).
821
1451
  *
1452
+ * @param {string} debugText string explaining the trigger for this call, added to logs for debugging purposes
822
1453
  * @param {object} locus locus object
823
- * @param {string} eventType locus event
1454
+ * @param {object} metadata locus hash trees metadata
824
1455
  * @param {DataSet[]} dataSets
1456
+ * @param {string} eventType locus event
825
1457
  * @returns {void}
826
1458
  */
827
- private onFullLocusWithHashTrees(locus: any, eventType?: string, dataSets?: Array<DataSet>) {
828
- if (!this.hashTreeParser) {
829
- LoggerProxy.logger.info(`Locus-info:index#onFullLocus --> creating hash tree parser`);
1459
+ private onFullLocusWithHashTrees(
1460
+ debugText: string,
1461
+ locus: any,
1462
+ metadata: Metadata,
1463
+ dataSets: Array<DataSet>,
1464
+ eventType?: string
1465
+ ) {
1466
+ if (!this.hashTreeParsers.has(locus.url)) {
1467
+ LoggerProxy.logger.info(
1468
+ `Locus-info:index#onFullLocus (${debugText}) --> creating hash tree parser for locusUrl=${locus.url}`
1469
+ );
830
1470
  LoggerProxy.logger.info(
831
- 'Locus-info:index#onFullLocus --> dataSets:',
1471
+ `Locus-info:index#onFullLocus (${debugText}) --> dataSets:`,
832
1472
  dataSets,
833
1473
  ' and locus:',
834
- locus
1474
+ locus,
1475
+ ' and metadata:',
1476
+ metadata
835
1477
  );
836
- this.hashTreeParser = this.createHashTreeParser({
1478
+ this.createHashTreeParser({
1479
+ locusUrl: locus.url,
837
1480
  initialLocus: {locus, dataSets},
1481
+ metadata,
838
1482
  });
1483
+ // we have a full locus to start with, so we consider Locus info to be "initialized"
1484
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1485
+ this.hashTreeParsers.get(locus.url)!.initializedFromHashTree = true;
839
1486
  this.onFullLocusCommon(locus, eventType);
840
1487
  } else {
841
1488
  // in this case the Locus we're getting is not necessarily the full one
842
1489
  // so treat it like if we just got it in any api response
843
1490
 
844
1491
  LoggerProxy.logger.info(
845
- 'Locus-info:index#onFullLocus --> hash tree parser already exists, handling it like a normal API response'
1492
+ `Locus-info:index#onFullLocus (${debugText}) --> hash tree parser already exists, handling it like a normal API response`
846
1493
  );
847
- this.handleLocusAPIResponse(undefined, {dataSets, locus});
1494
+ this.handleLocusAPIResponse(undefined, {dataSets, locus, metadata});
848
1495
  }
849
1496
  }
850
1497
 
851
1498
  /**
852
1499
  * Function for handling full locus when it's the "classic" one (not hash trees)
853
1500
  *
1501
+ * @param {string} debugText string explaining the trigger for this call, added to logs for debugging purposes
854
1502
  * @param {object} locus locus object
855
1503
  * @param {string} eventType locus event
856
1504
  * @returns {void}
857
1505
  */
858
- private onFullLocusClassic(locus: any, eventType?: string) {
1506
+ private onFullLocusClassic(debugText: string, locus: any, eventType?: string) {
859
1507
  if (!this.locusParser.isNewFullLocus(locus)) {
860
1508
  LoggerProxy.logger.info(
861
- `Locus-info:index#onFullLocus --> ignoring old full locus DTO, eventType=${eventType}`
1509
+ `Locus-info:index#onFullLocus (${debugText}) --> ignoring old full locus DTO, eventType=${eventType}`
862
1510
  );
863
1511
 
864
1512
  return;
@@ -868,24 +1516,37 @@ export default class LocusInfo extends EventsScope {
868
1516
 
869
1517
  /**
870
1518
  * updates the locus with full locus object
1519
+ * @param {string} debugText string explaining the trigger for this call, added to logs for debugging purposes
871
1520
  * @param {object} locus locus object
872
1521
  * @param {string} eventType locus event
873
1522
  * @param {DataSet[]} dataSets
1523
+ * @param {object} metadata locus hash trees metadata
874
1524
  * @returns {object} null
875
1525
  * @memberof LocusInfo
876
1526
  */
877
- onFullLocus(locus: any, eventType?: string, dataSets?: Array<DataSet>) {
1527
+ onFullLocus(
1528
+ debugText: string,
1529
+ locus: any,
1530
+ eventType?: string,
1531
+ dataSets?: Array<DataSet>,
1532
+ metadata?: Metadata
1533
+ ) {
878
1534
  if (!locus) {
879
1535
  LoggerProxy.logger.error(
880
- 'Locus-info:index#onFullLocus --> object passed as argument was invalid, continuing.'
1536
+ `Locus-info:index#onFullLocus (${debugText}) --> object passed as argument was invalid, continuing.`
881
1537
  );
882
1538
  }
883
1539
 
884
1540
  if (dataSets) {
1541
+ if (!metadata) {
1542
+ throw new Error(
1543
+ `Locus-info:index#onFullLocus (${debugText}) --> hash tree metadata is missing with full Locus`
1544
+ );
1545
+ }
885
1546
  // this is the new hashmap Locus DTO format (only applicable to webinars for now)
886
- this.onFullLocusWithHashTrees(locus, eventType, dataSets);
1547
+ this.onFullLocusWithHashTrees(debugText, locus, metadata, dataSets, eventType);
887
1548
  } else {
888
- this.onFullLocusClassic(locus, eventType);
1549
+ this.onFullLocusClassic(debugText, locus, eventType);
889
1550
  }
890
1551
  }
891
1552
 
@@ -900,7 +1561,7 @@ export default class LocusInfo extends EventsScope {
900
1561
  this.participants = locus.participants;
901
1562
  this.participants?.forEach((participant) => {
902
1563
  // participant.htMeta is set only for hash tree based locus
903
- if (participant.htMeta?.elementId.id) {
1564
+ if (typeof participant.htMeta?.elementId.id === 'number') {
904
1565
  this.hashTreeObjectId2ParticipantId.set(participant.htMeta.elementId.id, participant.id);
905
1566
  }
906
1567
  });
@@ -927,8 +1588,8 @@ export default class LocusInfo extends EventsScope {
927
1588
  // eslint-disable-next-line @typescript-eslint/no-shadow
928
1589
  handleOneOnOneEvent(eventType: string) {
929
1590
  if (
930
- this.parsedLocus.fullState.type === _CALL_ ||
931
- this.parsedLocus.fullState.type === _SIP_BRIDGE_
1591
+ this.parsedLocus.fullState?.type === _CALL_ ||
1592
+ this.parsedLocus.fullState?.type === _SIP_BRIDGE_
932
1593
  ) {
933
1594
  // for 1:1 bob calls alice and alice declines, notify the meeting state
934
1595
  if (eventType === LOCUSEVENT.PARTICIPANT_DECLINED) {
@@ -963,20 +1624,61 @@ export default class LocusInfo extends EventsScope {
963
1624
  }
964
1625
  }
965
1626
 
1627
+ /**
1628
+ * Makes sure that passed in locus object has a participant object for self.
1629
+ *
1630
+ * @param {LocusDTO} locus The locus object to check and modify if needed
1631
+ * @returns {void}
1632
+ */
1633
+ ensureSelfParticipantExists(locus: any) {
1634
+ const {self} = locus;
1635
+
1636
+ // sanity check, this should never fail
1637
+ if (!self?.identity || !Array.isArray(locus.participants)) {
1638
+ LoggerProxy.logger.warn(
1639
+ `Locus-info:index#ensureSelfParticipantExists --> locus object is missing required fields, cannot ensure self participant exists. self?.identity="${self?.identity}"`
1640
+ );
1641
+
1642
+ return;
1643
+ }
1644
+
1645
+ const selfExists = locus.participants.some(
1646
+ (participant) => participant.identity === self.identity
1647
+ );
1648
+
1649
+ if (!selfExists) {
1650
+ locus.participants.push({...self});
1651
+ }
1652
+ }
1653
+
966
1654
  /**
967
1655
  * @param {Object} locus
968
1656
  * @returns {undefined}
969
1657
  * @memberof LocusInfo
970
1658
  */
971
1659
  onDeltaLocus(locus: any) {
972
- const isReplaceMembers = ControlsUtils.isNeedReplaceMembers(this.controls, locus.controls);
1660
+ const isReplaceMembers =
1661
+ locus.jsSdkMeta?.forceReplaceMembers !== undefined
1662
+ ? locus.jsSdkMeta.forceReplaceMembers
1663
+ : ControlsUtils.isNeedReplaceMembers(this.controls, locus.controls);
1664
+
1665
+ if (isReplaceMembers) {
1666
+ // when we're moving between breakouts, Locus sometimes doesn't send us
1667
+ // any participants at all for a few seconds
1668
+ // Web app relies on having at least the self participant always there
1669
+ // so we copy self into participants if it's not there.
1670
+ this.ensureSelfParticipantExists(locus);
1671
+ }
973
1672
  this.mergeParticipants(this.participants, locus.participants);
974
- this.updateLocusInfo(locus);
975
- this.updateParticipants(
976
- locus.participants,
977
- locus.jsSdkMeta?.removedParticipantIds,
978
- isReplaceMembers
979
- );
1673
+ const updatesApplied = this.updateLocusInfo(locus);
1674
+
1675
+ if (updatesApplied) {
1676
+ this.updateParticipants(
1677
+ locus.participants,
1678
+ locus.jsSdkMeta?.removedParticipantIds,
1679
+ isReplaceMembers
1680
+ );
1681
+ }
980
1682
  this.isMeetingActive();
981
1683
  }
982
1684
 
@@ -986,11 +1688,11 @@ export default class LocusInfo extends EventsScope {
986
1688
  * @memberof LocusInfo
987
1689
  */
988
1690
  updateLocusInfo(locus) {
989
- if (locus.self?.reason === 'MOVED' && locus.self?.state === 'LEFT') {
1691
+ if (MeetingsUtil.isSelfMovedOrBreakoutEnded(locus)) {
990
1692
  // When moved to a breakout session locus sends a message for the previous locus
991
1693
  // indicating that we have been moved. It isn't helpful to continue parsing this
992
1694
  // as it gets interpreted as if we have left the call
993
- return;
1695
+ return false;
994
1696
  }
995
1697
 
996
1698
  this.updateControls(locus.controls, locus.self);
@@ -1001,19 +1703,17 @@ export default class LocusInfo extends EventsScope {
1001
1703
  this.updateLocusUrl(locus.url, ControlsUtils.isMainSessionDTO(locus));
1002
1704
  this.updateMeetingInfo(locus.info, locus.self);
1003
1705
  this.updateMediaShares(locus.mediaShares);
1004
- this.updateParticipantsUrl(locus.participantsUrl);
1005
- this.updateReplace(locus.replace);
1706
+ this.updateReplaces(locus.replaces);
1006
1707
  this.updateSelf(locus.self);
1007
1708
  this.updateAclUrl(locus.aclUrl);
1008
1709
  this.updateBasequence(locus.baseSequence);
1009
1710
  this.updateSequence(locus.sequence);
1010
- this.updateMemberShip(locus.membership);
1011
- this.updateIdentifiers(locus.identities);
1012
1711
  this.updateEmbeddedApps(locus.embeddedApps);
1013
- this.updateServices(locus.links?.services);
1014
- this.updateResources(locus.links?.resources);
1712
+ this.updateLinks(locus.links);
1015
1713
  this.compareAndUpdate();
1016
1714
  // update which required to compare different objects from locus
1715
+
1716
+ return true;
1017
1717
  }
1018
1718
 
1019
1719
  /**
@@ -1045,9 +1745,9 @@ export default class LocusInfo extends EventsScope {
1045
1745
  */
1046
1746
  isMeetingActive() {
1047
1747
  if (
1048
- this.parsedLocus.fullState.type === _CALL_ ||
1049
- this.parsedLocus.fullState.type === _SIP_BRIDGE_ ||
1050
- this.parsedLocus.fullState.type === _SPACE_SHARE_
1748
+ this.parsedLocus.fullState?.type === _CALL_ ||
1749
+ this.parsedLocus.fullState?.type === _SIP_BRIDGE_ ||
1750
+ this.parsedLocus.fullState?.type === _SPACE_SHARE_
1051
1751
  ) {
1052
1752
  // @ts-ignore
1053
1753
  const partner = this.getLocusPartner(this.participants, this.self);
@@ -1140,15 +1840,10 @@ export default class LocusInfo extends EventsScope {
1140
1840
  }
1141
1841
  );
1142
1842
  }
1143
- } else if (this.parsedLocus.fullState.type === _MEETING_) {
1144
- if (
1145
- this.fullState &&
1146
- (this.fullState.state === LOCUS.STATE.INACTIVE ||
1147
- // @ts-ignore
1148
- this.fullState.state === LOCUS.STATE.TERMINATING)
1149
- ) {
1843
+ } else if (this.parsedLocus.fullState?.type === _MEETING_) {
1844
+ if (this.fullState && MeetingsUtil.isWholeMeetingEnded(this.fullState)) {
1150
1845
  LoggerProxy.logger.warn(
1151
- 'Locus-info:index#isMeetingActive --> Meeting is ending due to inactive or terminating'
1846
+ 'Locus-info:index#isMeetingActive --> Meeting is ending due to inactive'
1152
1847
  );
1153
1848
 
1154
1849
  // @ts-ignore
@@ -1169,27 +1864,6 @@ export default class LocusInfo extends EventsScope {
1169
1864
  shouldLeave: false,
1170
1865
  }
1171
1866
  );
1172
- } else if (this.fullState && this.fullState.removed) {
1173
- // user has been dropped from a meeting
1174
-
1175
- // @ts-ignore
1176
- this.webex.internal.newMetrics.submitClientEvent({
1177
- name: 'client.call.remote-ended',
1178
- options: {
1179
- meetingId: this.meetingId,
1180
- },
1181
- });
1182
- this.emitScoped(
1183
- {
1184
- file: 'locus-info',
1185
- function: 'isMeetingActive',
1186
- },
1187
- EVENTS.DESTROY_MEETING,
1188
- {
1189
- reason: MEETING_REMOVED_REASON.FULLSTATE_REMOVED,
1190
- shouldLeave: false,
1191
- }
1192
- );
1193
1867
  }
1194
1868
  // If you are guest and you are removed from the meeting
1195
1869
  // You wont get any further events
@@ -1237,6 +1911,7 @@ export default class LocusInfo extends EventsScope {
1237
1911
  compareSelfAndHost() {
1238
1912
  // In some cases the host info is not present but the moderator values changes from null to false so it triggers an update
1239
1913
  if (
1914
+ this.parsedLocus.self &&
1240
1915
  this.parsedLocus.self.selfIdentity === this.parsedLocus.host?.hostId &&
1241
1916
  this.parsedLocus.self.moderator
1242
1917
  ) {
@@ -1323,6 +1998,8 @@ export default class LocusInfo extends EventsScope {
1323
1998
  hasRecordingPausedChanged,
1324
1999
  hasMeetingContainerChanged,
1325
2000
  hasTranscribeChanged,
2001
+ hasHesiodLLMIdChanged,
2002
+ hasAiSummaryNotificationChanged,
1326
2003
  hasTranscribeSpokenLanguageChanged,
1327
2004
  hasManualCaptionChanged,
1328
2005
  hasEntryExitToneChanged,
@@ -1429,6 +2106,8 @@ export default class LocusInfo extends EventsScope {
1429
2106
  state,
1430
2107
  modifiedBy: current.record.modifiedBy,
1431
2108
  lastModified: current.record.lastModified,
2109
+ modifiedByServiceAppName: current.record.modifiedByServiceAppName,
2110
+ modifiedByServiceAppId: current.record.modifiedByServiceAppId,
1432
2111
  }
1433
2112
  );
1434
2113
  }
@@ -1464,6 +2143,34 @@ export default class LocusInfo extends EventsScope {
1464
2143
  );
1465
2144
  }
1466
2145
 
2146
+ if (hasHesiodLLMIdChanged) {
2147
+ const {hesiodLlmId} = current.transcribe;
2148
+
2149
+ this.emitScoped(
2150
+ {
2151
+ file: 'locus-info',
2152
+ function: 'updateControls',
2153
+ },
2154
+ LOCUSINFO.EVENTS.CONTROLS_MEETING_HESIOD_LLM_ID_UPDATED,
2155
+ {
2156
+ hesiodLlmId,
2157
+ }
2158
+ );
2159
+ }
2160
+
2161
+ if (hasAiSummaryNotificationChanged) {
2162
+ this.emitScoped(
2163
+ {
2164
+ file: 'locus-info',
2165
+ function: 'updateControls',
2166
+ },
2167
+ LOCUSINFO.EVENTS.CONTROLS_AI_SUMMARY_NOTIFICATION_UPDATED,
2168
+ {
2169
+ aiSummaryNotification: current.transcribe.aiSummaryNotification,
2170
+ }
2171
+ );
2172
+ }
2173
+
1467
2174
  if (hasTranscribeSpokenLanguageChanged) {
1468
2175
  const {spokenLanguage} = current.transcribe;
1469
2176
 
@@ -1496,6 +2203,7 @@ export default class LocusInfo extends EventsScope {
1496
2203
 
1497
2204
  if (hasBreakoutChanged) {
1498
2205
  const {breakout} = current;
2206
+
1499
2207
  breakout.breakoutMoveId = SelfUtils.getReplacedBreakoutMoveId(
1500
2208
  self,
1501
2209
  this.webex.internal.device.url
@@ -1663,17 +2371,19 @@ export default class LocusInfo extends EventsScope {
1663
2371
  }
1664
2372
 
1665
2373
  /**
1666
- * @param {Object} services
2374
+ * Updates links and emits appropriate events if services or resources have changed
2375
+ * @param {Object} links
1667
2376
  * @returns {undefined}
1668
2377
  * @memberof LocusInfo
1669
2378
  */
1670
- updateServices(services: Record<'breakout' | 'record', {url: string}>) {
1671
- if (services && !isEqual(this.services, services)) {
1672
- this.services = services;
2379
+ updateLinks(links?: Links) {
2380
+ const {services, resources} = links || {};
2381
+
2382
+ if (services && !isEqual(this.links?.services, services)) {
1673
2383
  this.emitScoped(
1674
2384
  {
1675
2385
  file: 'locus-info',
1676
- function: 'updateServices',
2386
+ function: 'updateLinks',
1677
2387
  },
1678
2388
  LOCUSINFO.EVENTS.LINKS_SERVICES,
1679
2389
  {
@@ -1681,20 +2391,12 @@ export default class LocusInfo extends EventsScope {
1681
2391
  }
1682
2392
  );
1683
2393
  }
1684
- }
1685
2394
 
1686
- /**
1687
- * @param {Object} resources
1688
- * @returns {undefined}
1689
- * @memberof LocusInfo
1690
- */
1691
- updateResources(resources: Record<'webcastInstance', {url: string}>) {
1692
- if (resources && !isEqual(this.resources, resources)) {
1693
- this.resources = resources;
2395
+ if (resources && !isEqual(this.links?.resources, resources)) {
1694
2396
  this.emitScoped(
1695
2397
  {
1696
2398
  file: 'locus-info',
1697
- function: 'updateResources',
2399
+ function: 'updateLinks',
1698
2400
  },
1699
2401
  LOCUSINFO.EVENTS.LINKS_RESOURCES,
1700
2402
  {
@@ -1702,6 +2404,8 @@ export default class LocusInfo extends EventsScope {
1702
2404
  }
1703
2405
  );
1704
2406
  }
2407
+
2408
+ this.links = links;
1705
2409
  }
1706
2410
 
1707
2411
  /**
@@ -1787,9 +2491,19 @@ export default class LocusInfo extends EventsScope {
1787
2491
  */
1788
2492
  updateMeetingInfo(info: object, self?: object) {
1789
2493
  const roles = self ? SelfUtils.getRoles(self) : this.parsedLocus.self?.roles || [];
1790
- if ((info && !isEqual(this.info, info)) || (!isEqual(this.roles, roles) && info)) {
1791
- const isJoined = SelfUtils.isJoined(self || this.parsedLocus.self);
1792
- const parsedInfo = InfoUtils.getInfos(this.parsedLocus.info, info, roles, isJoined);
2494
+ const isJoined = SelfUtils.isJoined(self || this.parsedLocus.self);
2495
+
2496
+ // The parsed userDisplayHints depend on info, roles and isJoined, so we must recompute
2497
+ // whenever any of them changes. A common case is self transitioning to JOINED via a delta
2498
+ // that doesn't carry an info section - in that case we fall back to the previously stored
2499
+ // info so the hints get reparsed with the new joined state (e.g. VIEW_THE_PARTICIPANT_LIST).
2500
+ const infoToParse = info || this.info;
2501
+ const infoChanged = info && !isEqual(this.info, info);
2502
+ const rolesChanged = !isEqual(this.roles, roles);
2503
+ const isJoinedChanged = SelfUtils.isJoined(this.parsedLocus.self) !== isJoined;
2504
+
2505
+ if (infoToParse && (infoChanged || rolesChanged || isJoinedChanged)) {
2506
+ const parsedInfo = InfoUtils.getInfos(this.parsedLocus.info, infoToParse, roles, isJoined);
1793
2507
 
1794
2508
  if (parsedInfo.updates.isLocked) {
1795
2509
  this.emitScoped(
@@ -1812,7 +2526,7 @@ export default class LocusInfo extends EventsScope {
1812
2526
  );
1813
2527
  }
1814
2528
 
1815
- this.info = info;
2529
+ this.info = infoToParse;
1816
2530
  this.parsedLocus.info = parsedInfo.current;
1817
2531
  // Parses the info and adds necessary values
1818
2532
  this.updateMeeting(parsedInfo.current);
@@ -1888,24 +2602,13 @@ export default class LocusInfo extends EventsScope {
1888
2602
  }
1889
2603
 
1890
2604
  /**
1891
- * @param {String} participantsUrl
2605
+ * @param {Object} replaces
1892
2606
  * @returns {undefined}
1893
2607
  * @memberof LocusInfo
1894
2608
  */
1895
- updateParticipantsUrl(participantsUrl: string) {
1896
- if (participantsUrl && !isEqual(this.participantsUrl, participantsUrl)) {
1897
- this.participantsUrl = participantsUrl;
1898
- }
1899
- }
1900
-
1901
- /**
1902
- * @param {Object} replace
1903
- * @returns {undefined}
1904
- * @memberof LocusInfo
1905
- */
1906
- updateReplace(replace: object) {
1907
- if (replace && !isEqual(this.replace, replace)) {
1908
- this.replace = replace;
2609
+ updateReplaces(replaces: object) {
2610
+ if (replaces && !isEqual(this.replaces, replaces)) {
2611
+ this.replaces = replaces;
1909
2612
  }
1910
2613
  }
1911
2614
 
@@ -1936,14 +2639,14 @@ export default class LocusInfo extends EventsScope {
1936
2639
  }
1937
2640
 
1938
2641
  // TODO: check if we need to save the sipUri here as well
1939
- // this.emit(LOCUSINFO.EVENTS.MEETING_UPDATE, SelfUtils.getSipUrl(this.getLocusPartner(participants, self), this.parsedLocus.fullState.type, this.parsedLocus.info.sipUri));
2642
+ // this.emit(LOCUSINFO.EVENTS.MEETING_UPDATE, SelfUtils.getSipUrl(this.getLocusPartner(participants, self), this.parsedLocus.fullState?.type, this.parsedLocus.info?.sipUri));
1940
2643
  const result = SelfUtils.getSipUrl(
1941
2644
  this.getLocusPartner(this.participants, self),
1942
- this.parsedLocus.fullState.type,
1943
- this.parsedLocus.info.sipUri
2645
+ this.parsedLocus.fullState?.type,
2646
+ this.parsedLocus.info?.sipUri
1944
2647
  );
1945
2648
 
1946
- if (result.sipUri) {
2649
+ if (result?.sipUri) {
1947
2650
  this.updateMeeting(result);
1948
2651
  }
1949
2652
 
@@ -1988,6 +2691,19 @@ export default class LocusInfo extends EventsScope {
1988
2691
  );
1989
2692
  }
1990
2693
 
2694
+ if (parsedSelves.updates.selfIdChanged) {
2695
+ this.emitScoped(
2696
+ {
2697
+ file: 'locus-info',
2698
+ function: 'updateSelf',
2699
+ },
2700
+ LOCUSINFO.EVENTS.SELF_ID_CHANGED,
2701
+ {
2702
+ selfId: parsedSelves.current.selfId,
2703
+ }
2704
+ );
2705
+ }
2706
+
1991
2707
  if (parsedSelves.updates.interpretationChanged) {
1992
2708
  this.emitScoped(
1993
2709
  {
@@ -2071,6 +2787,7 @@ export default class LocusInfo extends EventsScope {
2071
2787
  {
2072
2788
  muted: parsedSelves.current.remoteMuted,
2073
2789
  unmuteAllowed: parsedSelves.current.unmuteAllowed,
2790
+ modifiedBy: parsedSelves.current.modifiedBy ?? null,
2074
2791
  }
2075
2792
  );
2076
2793
  }
@@ -2242,28 +2959,6 @@ export default class LocusInfo extends EventsScope {
2242
2959
  }
2243
2960
  }
2244
2961
 
2245
- /**
2246
- * @param {Object} membership
2247
- * @returns {undefined}
2248
- * @memberof LocusInfo
2249
- */
2250
- updateMemberShip(membership: object) {
2251
- if (membership && !isEqual(this.membership, membership)) {
2252
- this.membership = membership;
2253
- }
2254
- }
2255
-
2256
- /**
2257
- * @param {Array} identities
2258
- * @returns {undefined}
2259
- * @memberof LocusInfo
2260
- */
2261
- updateIdentifiers(identities: Array<any>) {
2262
- if (identities && !isEqual(this.identities, identities)) {
2263
- this.identities = identities;
2264
- }
2265
- }
2266
-
2267
2962
  /**
2268
2963
  * check the locus is main session's one or not, if is main session's, update main session cache
2269
2964
  * @param {Object} locus
@@ -2365,4 +3060,17 @@ export default class LocusInfo extends EventsScope {
2365
3060
  clearMainSessionLocusCache() {
2366
3061
  this.mainSessionLocusCache = null;
2367
3062
  }
3063
+
3064
+ /**
3065
+ * Cleans up all hash tree parsers and clears internal maps.
3066
+ * @returns {void}
3067
+ * @memberof LocusInfo
3068
+ */
3069
+ cleanUp() {
3070
+ this.hashTreeParsers.forEach((entry) => {
3071
+ entry.parser.cleanUp();
3072
+ });
3073
+ this.hashTreeParsers.clear();
3074
+ this.hashTreeObjectId2ParticipantId.clear();
3075
+ }
2368
3076
  }