@webex/plugin-meetings 3.12.0 → 3.13.0

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 (320) hide show
  1. package/.sdd/manifest.json +1312 -0
  2. package/.sdd/templates/.source.json +30 -0
  3. package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +111 -0
  4. package/.sdd/templates/component-repo/module-docs/module-spec.template.md +321 -0
  5. package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +59 -0
  6. package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +49 -0
  7. package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +42 -0
  8. package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +120 -0
  9. package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +206 -0
  10. package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +90 -0
  11. package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +68 -0
  12. package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +111 -0
  13. package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +57 -0
  14. package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +69 -0
  15. package/.sdd/templates/component-repo/standing-docs/RULES.template.md +96 -0
  16. package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +84 -0
  17. package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +82 -0
  18. package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +94 -0
  19. package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +64 -0
  20. package/.sdd/templates/component-repo/template-map.json +112 -0
  21. package/AGENTS.md +135 -0
  22. package/ai-docs/ARCHITECTURE.md +208 -0
  23. package/ai-docs/CONTRACTS.md +267 -0
  24. package/ai-docs/DATA_MODEL.md +64 -0
  25. package/ai-docs/GETTING_STARTED.md +73 -0
  26. package/ai-docs/GLOSSARY.md +56 -0
  27. package/ai-docs/REVIEW_CHECKLIST.md +45 -0
  28. package/ai-docs/RULES.md +79 -0
  29. package/ai-docs/SECURITY.md +74 -0
  30. package/ai-docs/SERVICE_STATE.md +59 -0
  31. package/ai-docs/SPEC_INDEX.md +85 -0
  32. package/ai-docs/TEST_INDEX.md +45 -0
  33. package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +61 -0
  34. package/ai-docs/patterns/defensive-error-propagation.md +55 -0
  35. package/ai-docs/patterns/event-scope-emission.md +46 -0
  36. package/ai-docs/patterns/source-to-test-path-mirroring.md +45 -0
  37. package/ai-docs/patterns/stateless-plugin-request-classes.md +53 -0
  38. package/ai-docs/patterns/typed-constants-and-enum-values.md +47 -0
  39. package/assets/README.md +28 -0
  40. package/assets/e2ee-0.0.1.js +2 -0
  41. package/assets/e2ee-0.0.1.wasm +0 -0
  42. package/dist/aiEnableRequest/index.js +15 -2
  43. package/dist/aiEnableRequest/index.js.map +1 -1
  44. package/dist/annotation/index.js +55 -19
  45. package/dist/annotation/index.js.map +1 -1
  46. package/dist/assets/e2ee-0.0.1.js +2 -0
  47. package/dist/assets/e2ee-0.0.1.wasm +0 -0
  48. package/dist/breakouts/breakout.js +8 -3
  49. package/dist/breakouts/breakout.js.map +1 -1
  50. package/dist/breakouts/events.js +29 -14
  51. package/dist/breakouts/events.js.map +1 -1
  52. package/dist/breakouts/index.js +128 -7
  53. package/dist/breakouts/index.js.map +1 -1
  54. package/dist/common/errors/webex-errors.js +54 -5
  55. package/dist/common/errors/webex-errors.js.map +1 -1
  56. package/dist/config.js +4 -2
  57. package/dist/config.js.map +1 -1
  58. package/dist/constants.js +39 -11
  59. package/dist/constants.js.map +1 -1
  60. package/dist/controls-options-manager/constants.js +11 -1
  61. package/dist/controls-options-manager/constants.js.map +1 -1
  62. package/dist/controls-options-manager/index.js +67 -29
  63. package/dist/controls-options-manager/index.js.map +1 -1
  64. package/dist/controls-options-manager/util.js +91 -0
  65. package/dist/controls-options-manager/util.js.map +1 -1
  66. package/dist/hashTree/constants.js +13 -1
  67. package/dist/hashTree/constants.js.map +1 -1
  68. package/dist/hashTree/hashTreeParser.js +1245 -404
  69. package/dist/hashTree/hashTreeParser.js.map +1 -1
  70. package/dist/hashTree/utils.js +42 -0
  71. package/dist/hashTree/utils.js.map +1 -1
  72. package/dist/index.js +8 -0
  73. package/dist/index.js.map +1 -1
  74. package/dist/interceptors/dataChannelAuthToken.js +58 -16
  75. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  76. package/dist/interceptors/locusRetry.js +24 -9
  77. package/dist/interceptors/locusRetry.js.map +1 -1
  78. package/dist/interpretation/index.js +55 -12
  79. package/dist/interpretation/index.js.map +1 -1
  80. package/dist/interpretation/interpretation.types.js +7 -0
  81. package/dist/interpretation/interpretation.types.js.map +1 -0
  82. package/dist/interpretation/siLanguage.js +1 -1
  83. package/dist/locus-info/controlsUtils.js +4 -1
  84. package/dist/locus-info/controlsUtils.js.map +1 -1
  85. package/dist/locus-info/index.js +914 -196
  86. package/dist/locus-info/index.js.map +1 -1
  87. package/dist/locus-info/infoUtils.js +36 -5
  88. package/dist/locus-info/infoUtils.js.map +1 -1
  89. package/dist/locus-info/types.js +20 -0
  90. package/dist/locus-info/types.js.map +1 -1
  91. package/dist/media/MediaConnectionAwaiter.js +229 -166
  92. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  93. package/dist/media/index.js +8 -2
  94. package/dist/media/index.js.map +1 -1
  95. package/dist/media/properties.js +4 -5
  96. package/dist/media/properties.js.map +1 -1
  97. package/dist/meeting/in-meeting-actions.js +5 -1
  98. package/dist/meeting/in-meeting-actions.js.map +1 -1
  99. package/dist/meeting/index.js +1931 -887
  100. package/dist/meeting/index.js.map +1 -1
  101. package/dist/meeting/locusMediaRequest.js +229 -82
  102. package/dist/meeting/locusMediaRequest.js.map +1 -1
  103. package/dist/meeting/muteState.js +10 -1
  104. package/dist/meeting/muteState.js.map +1 -1
  105. package/dist/meeting/request.js +5 -2
  106. package/dist/meeting/request.js.map +1 -1
  107. package/dist/meeting/util.js +42 -3
  108. package/dist/meeting/util.js.map +1 -1
  109. package/dist/meeting/voicea-meeting.js +2 -1
  110. package/dist/meeting/voicea-meeting.js.map +1 -1
  111. package/dist/meeting-info/meeting-info-v2.js +12 -5
  112. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  113. package/dist/meetings/index.js +322 -129
  114. package/dist/meetings/index.js.map +1 -1
  115. package/dist/meetings/meetings.types.js +6 -1
  116. package/dist/meetings/meetings.types.js.map +1 -1
  117. package/dist/meetings/request.js +39 -0
  118. package/dist/meetings/request.js.map +1 -1
  119. package/dist/meetings/util.js +116 -18
  120. package/dist/meetings/util.js.map +1 -1
  121. package/dist/member/index.js +10 -0
  122. package/dist/member/index.js.map +1 -1
  123. package/dist/member/types.js.map +1 -1
  124. package/dist/member/util.js +30 -0
  125. package/dist/member/util.js.map +1 -1
  126. package/dist/members/index.js +101 -43
  127. package/dist/members/index.js.map +1 -1
  128. package/dist/members/util.js +8 -1
  129. package/dist/members/util.js.map +1 -1
  130. package/dist/metrics/constants.js +11 -1
  131. package/dist/metrics/constants.js.map +1 -1
  132. package/dist/multistream/codec/constants.js +63 -0
  133. package/dist/multistream/codec/constants.js.map +1 -0
  134. package/dist/multistream/mediaRequestManager.js +62 -15
  135. package/dist/multistream/mediaRequestManager.js.map +1 -1
  136. package/dist/multistream/receiveSlot.js +9 -0
  137. package/dist/multistream/receiveSlot.js.map +1 -1
  138. package/dist/multistream/remoteMediaManager.js +32 -4
  139. package/dist/multistream/remoteMediaManager.js.map +1 -1
  140. package/dist/multistream/sendSlotManager.js +127 -3
  141. package/dist/multistream/sendSlotManager.js.map +1 -1
  142. package/dist/reachability/clusterReachability.js.map +1 -1
  143. package/dist/reachability/index.js +121 -83
  144. package/dist/reachability/index.js.map +1 -1
  145. package/dist/reachability/reachability.types.js +2 -0
  146. package/dist/reachability/reachability.types.js.map +1 -1
  147. package/dist/reachability/util.js +45 -0
  148. package/dist/reachability/util.js.map +1 -1
  149. package/dist/reactions/reactions.type.js.map +1 -1
  150. package/dist/recording-controller/index.js +1 -3
  151. package/dist/recording-controller/index.js.map +1 -1
  152. package/dist/roap/turnDiscovery.js +8 -1
  153. package/dist/roap/turnDiscovery.js.map +1 -1
  154. package/dist/types/annotation/index.d.ts +19 -0
  155. package/dist/types/common/errors/webex-errors.d.ts +36 -2
  156. package/dist/types/config.d.ts +4 -2
  157. package/dist/types/constants.d.ts +15 -2
  158. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  159. package/dist/types/controls-options-manager/index.d.ts +16 -0
  160. package/dist/types/hashTree/constants.d.ts +2 -0
  161. package/dist/types/hashTree/hashTreeParser.d.ts +230 -18
  162. package/dist/types/hashTree/utils.d.ts +18 -0
  163. package/dist/types/index.d.ts +4 -0
  164. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  165. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  166. package/dist/types/locus-info/index.d.ts +151 -15
  167. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  168. package/dist/types/locus-info/types.d.ts +28 -1
  169. package/dist/types/media/MediaConnectionAwaiter.d.ts +66 -49
  170. package/dist/types/media/properties.d.ts +6 -2
  171. package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
  172. package/dist/types/meeting/index.d.ts +247 -13
  173. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  174. package/dist/types/meeting/request.d.ts +1 -0
  175. package/dist/types/meeting/util.d.ts +12 -1
  176. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  177. package/dist/types/meetings/index.d.ts +40 -19
  178. package/dist/types/meetings/meetings.types.d.ts +15 -0
  179. package/dist/types/meetings/request.d.ts +14 -0
  180. package/dist/types/member/index.d.ts +1 -0
  181. package/dist/types/member/types.d.ts +1 -0
  182. package/dist/types/member/util.d.ts +9 -0
  183. package/dist/types/members/index.d.ts +15 -2
  184. package/dist/types/members/util.d.ts +1 -5
  185. package/dist/types/metrics/constants.d.ts +10 -0
  186. package/dist/types/multistream/codec/constants.d.ts +7 -0
  187. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  188. package/dist/types/multistream/remoteMediaManager.d.ts +18 -0
  189. package/dist/types/multistream/sendSlotManager.d.ts +28 -2
  190. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  191. package/dist/types/reachability/index.d.ts +10 -3
  192. package/dist/types/reachability/reachability.types.d.ts +7 -0
  193. package/dist/types/reachability/util.d.ts +17 -0
  194. package/dist/types/reactions/reactions.type.d.ts +3 -0
  195. package/dist/webinar/index.js +539 -245
  196. package/dist/webinar/index.js.map +1 -1
  197. package/package.json +26 -24
  198. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +223 -0
  199. package/src/aiEnableRequest/index.ts +16 -0
  200. package/src/annotation/ai-docs/annotation-spec.md +236 -0
  201. package/src/annotation/index.ts +61 -29
  202. package/src/breakouts/ai-docs/breakouts-spec.md +324 -0
  203. package/src/breakouts/breakout.ts +3 -1
  204. package/src/breakouts/events.ts +33 -11
  205. package/src/breakouts/index.ts +145 -3
  206. package/src/common/errors/webex-errors.ts +56 -3
  207. package/src/config.ts +8 -3
  208. package/src/constants.ts +23 -4
  209. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +243 -0
  210. package/src/controls-options-manager/constants.ts +14 -1
  211. package/src/controls-options-manager/index.ts +87 -28
  212. package/src/controls-options-manager/util.ts +81 -1
  213. package/src/hashTree/ai-docs/hash-tree-spec.md +267 -0
  214. package/src/hashTree/constants.ts +16 -0
  215. package/src/hashTree/hashTreeParser.ts +1021 -214
  216. package/src/hashTree/utils.ts +36 -0
  217. package/src/index.ts +7 -0
  218. package/src/interceptors/ai-docs/interceptors-spec.md +247 -0
  219. package/src/interceptors/dataChannelAuthToken.ts +59 -12
  220. package/src/interceptors/locusRetry.ts +26 -5
  221. package/src/interpretation/ai-docs/interpretation-spec.md +256 -0
  222. package/src/interpretation/index.ts +65 -10
  223. package/src/interpretation/interpretation.types.ts +11 -0
  224. package/src/locus-info/ai-docs/locus-info-spec.md +293 -0
  225. package/src/locus-info/controlsUtils.ts +3 -1
  226. package/src/locus-info/index.ts +907 -184
  227. package/src/locus-info/infoUtils.ts +41 -6
  228. package/src/locus-info/types.ts +33 -1
  229. package/src/media/MediaConnectionAwaiter.ts +229 -196
  230. package/src/media/ai-docs/media-spec.md +267 -0
  231. package/src/media/index.ts +10 -1
  232. package/src/media/properties.ts +8 -3
  233. package/src/meeting/ai-docs/meeting-spec.md +404 -0
  234. package/src/meeting/in-meeting-actions.ts +8 -0
  235. package/src/meeting/index.ts +1237 -254
  236. package/src/meeting/locusMediaRequest.ts +106 -6
  237. package/src/meeting/muteState.ts +10 -1
  238. package/src/meeting/request.ts +11 -0
  239. package/src/meeting/util.ts +53 -8
  240. package/src/meeting/voicea-meeting.ts +1 -1
  241. package/src/meeting-info/ai-docs/meeting-info-spec.md +261 -0
  242. package/src/meeting-info/meeting-info-v2.ts +11 -4
  243. package/src/meetings/ai-docs/meetings-spec.md +296 -0
  244. package/src/meetings/index.ts +224 -80
  245. package/src/meetings/meetings.types.ts +19 -0
  246. package/src/meetings/request.ts +43 -0
  247. package/src/meetings/util.ts +117 -4
  248. package/src/member/ai-docs/member-spec.md +196 -0
  249. package/src/member/index.ts +10 -0
  250. package/src/member/types.ts +1 -0
  251. package/src/member/util.ts +29 -0
  252. package/src/members/ai-docs/members-spec.md +256 -0
  253. package/src/members/index.ts +70 -7
  254. package/src/members/util.ts +12 -4
  255. package/src/metrics/ai-docs/metrics-spec.md +185 -0
  256. package/src/metrics/constants.ts +11 -0
  257. package/src/multistream/ai-docs/multistream-spec.md +295 -0
  258. package/src/multistream/codec/constants.ts +58 -0
  259. package/src/multistream/mediaRequestManager.ts +119 -28
  260. package/src/multistream/receiveSlot.ts +18 -0
  261. package/src/multistream/remoteMediaManager.ts +23 -1
  262. package/src/multistream/sendSlotManager.ts +112 -4
  263. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +234 -0
  264. package/src/reachability/ai-docs/reachability-spec.md +261 -0
  265. package/src/reachability/clusterReachability.ts +3 -2
  266. package/src/reachability/index.ts +47 -16
  267. package/src/reachability/reachability.types.ts +11 -0
  268. package/src/reachability/util.ts +36 -0
  269. package/src/reactions/ai-docs/reactions-spec.md +198 -0
  270. package/src/reactions/reactions.type.ts +3 -0
  271. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +272 -0
  272. package/src/recording-controller/ai-docs/recording-controller-spec.md +223 -0
  273. package/src/recording-controller/index.ts +1 -2
  274. package/src/roap/ai-docs/roap-spec.md +241 -0
  275. package/src/roap/turnDiscovery.ts +9 -1
  276. package/src/webinar/ai-docs/webinar-spec.md +243 -0
  277. package/src/webinar/index.ts +333 -73
  278. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  279. package/test/unit/spec/annotation/index.ts +214 -182
  280. package/test/unit/spec/breakouts/breakout.ts +9 -3
  281. package/test/unit/spec/breakouts/events.ts +120 -2
  282. package/test/unit/spec/breakouts/index.ts +336 -15
  283. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  284. package/test/unit/spec/controls-options-manager/index.js +244 -29
  285. package/test/unit/spec/controls-options-manager/util.js +165 -0
  286. package/test/unit/spec/hashTree/hashTreeParser.ts +3126 -238
  287. package/test/unit/spec/hashTree/utils.ts +125 -1
  288. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +179 -1
  289. package/test/unit/spec/interceptors/locusRetry.ts +234 -5
  290. package/test/unit/spec/interpretation/index.ts +119 -4
  291. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  292. package/test/unit/spec/locus-info/index.js +1880 -136
  293. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  294. package/test/unit/spec/media/MediaConnectionAwaiter.ts +479 -17
  295. package/test/unit/spec/media/index.ts +92 -0
  296. package/test/unit/spec/media/properties.ts +26 -26
  297. package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
  298. package/test/unit/spec/meeting/index.js +3697 -501
  299. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  300. package/test/unit/spec/meeting/muteState.js +81 -0
  301. package/test/unit/spec/meeting/request.js +12 -0
  302. package/test/unit/spec/meeting/utils.js +206 -16
  303. package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
  304. package/test/unit/spec/meeting-info/meetinginfov2.js +88 -11
  305. package/test/unit/spec/meetings/index.js +586 -53
  306. package/test/unit/spec/meetings/request.js +141 -0
  307. package/test/unit/spec/meetings/utils.js +402 -51
  308. package/test/unit/spec/member/index.js +7 -0
  309. package/test/unit/spec/member/util.js +89 -0
  310. package/test/unit/spec/members/index.js +216 -0
  311. package/test/unit/spec/members/request.js +37 -1
  312. package/test/unit/spec/members/utils.js +63 -0
  313. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  314. package/test/unit/spec/multistream/remoteMediaManager.ts +46 -0
  315. package/test/unit/spec/multistream/sendSlotManager.ts +165 -38
  316. package/test/unit/spec/reachability/index.ts +128 -46
  317. package/test/unit/spec/reachability/util.ts +31 -0
  318. package/test/unit/spec/recording-controller/index.js +9 -8
  319. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  320. package/test/unit/spec/webinar/index.ts +982 -328
@@ -1,5 +1,15 @@
1
1
  import {SELF_ROLES, DISPLAY_HINTS, INTERSTITIAL_DISPLAY_HINTS} from '../constants';
2
2
 
3
+ // these values have to match what Locus sends us
4
+ export enum DisplayHintSection {
5
+ JOINED = 'joined',
6
+ MODERATOR = 'moderator',
7
+ COHOST = 'coHost',
8
+ PRESENTER = 'presenter',
9
+ PANELIST = 'panelist',
10
+ ATTENDEE = 'attendee',
11
+ }
12
+
3
13
  const InfoUtils: any = {};
4
14
 
5
15
  InfoUtils.parse = (info, roles, isJoined = true) => {
@@ -7,6 +17,9 @@ InfoUtils.parse = (info, roles, isJoined = true) => {
7
17
  policy: InfoUtils.parsePolicy(info),
8
18
  moderator: InfoUtils.parseModerator(info),
9
19
  coHost: InfoUtils.parseCoHost(info),
20
+ presenter: InfoUtils.parsePresenter(info),
21
+ panelist: InfoUtils.parsePanelist(info),
22
+ attendee: InfoUtils.parseAttendee(info),
10
23
  };
11
24
 
12
25
  let userDisplayHints = isJoined
@@ -27,6 +40,18 @@ InfoUtils.parse = (info, roles, isJoined = true) => {
27
40
  userDisplayHints = {...userDisplayHints, ...parsed.moderator};
28
41
  }
29
42
 
43
+ if (roles.includes(SELF_ROLES.PRESENTER)) {
44
+ userDisplayHints = {...userDisplayHints, ...parsed.presenter};
45
+ }
46
+
47
+ if (roles.includes(SELF_ROLES.PANELIST)) {
48
+ userDisplayHints = {...userDisplayHints, ...parsed.panelist};
49
+ }
50
+
51
+ if (roles.includes(SELF_ROLES.ATTENDEE)) {
52
+ userDisplayHints = {...userDisplayHints, ...parsed.attendee};
53
+ }
54
+
30
55
  parsed.userDisplayHints = Object.keys(userDisplayHints);
31
56
 
32
57
  if (info.sipUri) {
@@ -44,8 +69,8 @@ InfoUtils.parse = (info, roles, isJoined = true) => {
44
69
  return parsed;
45
70
  };
46
71
 
47
- InfoUtils.parseDisplayHintSection = (info, displayHintKey) => {
48
- const displayHints = {};
72
+ InfoUtils.parseDisplayHintSection = (info: any, displayHintKey: DisplayHintSection) => {
73
+ const displayHints: Record<string, boolean> = {};
49
74
 
50
75
  if (
51
76
  info &&
@@ -53,7 +78,7 @@ InfoUtils.parseDisplayHintSection = (info, displayHintKey) => {
53
78
  info.displayHints[displayHintKey] &&
54
79
  info.displayHints[displayHintKey].length > 0
55
80
  ) {
56
- info.displayHints[displayHintKey].forEach((key) => {
81
+ info.displayHints[displayHintKey].forEach((key: any) => {
57
82
  displayHints[key] = true;
58
83
  });
59
84
  }
@@ -61,20 +86,30 @@ InfoUtils.parseDisplayHintSection = (info, displayHintKey) => {
61
86
  return displayHints;
62
87
  };
63
88
 
64
- InfoUtils.parsePolicy = (info) => InfoUtils.parseDisplayHintSection(info, 'joined');
89
+ InfoUtils.parsePolicy = (info) =>
90
+ InfoUtils.parseDisplayHintSection(info, DisplayHintSection.JOINED);
65
91
 
66
92
  InfoUtils.parseModerator = (info) => {
67
- const displayHints = InfoUtils.parseDisplayHintSection(info, 'moderator');
93
+ const displayHints = InfoUtils.parseDisplayHintSection(info, DisplayHintSection.MODERATOR);
68
94
 
69
95
  return {...displayHints, [DISPLAY_HINTS.LOWER_SOMEONE_ELSES_HAND]: true};
70
96
  };
71
97
 
72
98
  InfoUtils.parseCoHost = (info) => {
73
- const displayHints = InfoUtils.parseDisplayHintSection(info, 'coHost');
99
+ const displayHints = InfoUtils.parseDisplayHintSection(info, DisplayHintSection.COHOST);
74
100
 
75
101
  return {...displayHints, [DISPLAY_HINTS.LOWER_SOMEONE_ELSES_HAND]: true};
76
102
  };
77
103
 
104
+ InfoUtils.parsePresenter = (info) =>
105
+ InfoUtils.parseDisplayHintSection(info, DisplayHintSection.PRESENTER);
106
+
107
+ InfoUtils.parsePanelist = (info) =>
108
+ InfoUtils.parseDisplayHintSection(info, DisplayHintSection.PANELIST);
109
+
110
+ InfoUtils.parseAttendee = (info) =>
111
+ InfoUtils.parseDisplayHintSection(info, DisplayHintSection.ATTENDEE);
112
+
78
113
  InfoUtils.isLocked = (policy) => policy.LOCK_STATUS_LOCKED || false;
79
114
 
80
115
  InfoUtils.isUnlocked = (policy) => policy.LOCK_STATUS_UNLOCKED || false;
@@ -1,15 +1,33 @@
1
+ import {Enum} from '../constants';
1
2
  import {HtMeta} from '../hashTree/types';
2
3
 
4
+ export const EndMeetingReason = {
5
+ maxMeetingDuration: 'MAX_MEETING_DURATION',
6
+ allParticipantsLeft: 'ALL_PARTICIPANTS_LEFT',
7
+ sipHostLeft: 'SIP_HOST_LEFT',
8
+ noHost: 'NO_HOST',
9
+ waitingForMpsEndMeetingTimeout: 'WAITING_FOR_MPS_END_MEETING_TIMEOUT',
10
+ fraudDetection: 'FRAUD_DETECTION',
11
+ meetingEndedByHost: 'MEETING_ENDED_BY_HOST',
12
+ meetingUpdated: 'MEETING_UPDATED', // Locus code has comment about EndMeetingIfPossible reason for this one
13
+ meetingCancelled: 'MEETING_CANCELLED', // Locus code has comment about EndMeetingIfPossible reason for this one
14
+ autoEndWithSingleParticipant: 'AUTO_END_WITH_SINGLE_PARTICIPANT',
15
+ breakoutEnded: 'BREAKOUT_ENDED', // indicates that only a breakout session ended, not the whole meeting
16
+ } as const;
17
+
18
+ export type EndMeetingReason = Enum<typeof EndMeetingReason>;
19
+
3
20
  export type LocusFullState = {
4
21
  active: boolean;
5
22
  count: number;
6
23
  lastActive: string;
7
24
  locked: boolean;
8
25
  sessionId: string;
9
- seessionIds: string[];
26
+ sessionIds: string[];
10
27
  startTime: number;
11
28
  state: string;
12
29
  type: string;
30
+ endMeetingReason?: EndMeetingReason;
13
31
  };
14
32
 
15
33
  export type Links = {
@@ -32,6 +50,7 @@ export type LocusDTO = {
32
50
  info?: any;
33
51
  jsSdkMeta?: {
34
52
  removedParticipantIds: string[]; // list of ids of participants that are removed in the last update
53
+ forceReplaceMembers?: boolean; // when true, forces a full replacement of meeting members (e.g. when switching to a new hash tree parser - when moving between breakouts)
35
54
  };
36
55
  links?: Links;
37
56
  mediaShares?: any[];
@@ -52,3 +71,16 @@ export type LocusDTO = {
52
71
  syncUrl?: string;
53
72
  url?: string;
54
73
  };
74
+
75
+ export type ReplacesInfo = {
76
+ locusUrl: string;
77
+ replacedAt: string;
78
+ sessionId: string;
79
+ };
80
+
81
+ export const LocusErrorCodes = {
82
+ LOCUS_INACTIVE: 2403004,
83
+ LOCUS_USER_FULL: 2423001,
84
+ } as const;
85
+
86
+ export type LocusErrorCodes = Enum<typeof LocusErrorCodes>;
@@ -1,7 +1,7 @@
1
1
  import {Defer} from '@webex/common';
2
2
  import {ConnectionState, MediaConnectionEventNames} from '@webex/internal-media-core';
3
3
  import LoggerProxy from '../common/logs/logger-proxy';
4
- import {ICE_AND_DTLS_CONNECTION_TIMEOUT} from '../constants';
4
+ import {DTLS_CONNECTION_TIMEOUT, ICE_CONNECTION_TIMEOUT} from '../constants';
5
5
  import BEHAVIORAL_METRICS from '../metrics/constants';
6
6
  import Metrics from '../metrics';
7
7
 
@@ -10,282 +10,315 @@ export interface MediaConnectionAwaiterProps {
10
10
  correlationId: string;
11
11
  }
12
12
 
13
+ export interface FailureResult {
14
+ iceConnected: boolean;
15
+ iceConnectedAtLeastOnce: boolean;
16
+ }
17
+
18
+ type State =
19
+ | {name: 'idle'}
20
+ | {name: 'ice'; gatheringRetried: boolean}
21
+ | {name: 'dtls'}
22
+ | {name: 'connected'}
23
+ | {name: 'failed'; result: FailureResult};
24
+
25
+ type ActiveState = Extract<State, {name: 'ice' | 'dtls'}>;
26
+ type EnteredState = Exclude<State, {name: 'idle'}>;
27
+
28
+ const PHASE_TIMEOUT: Record<ActiveState['name'], number> = {
29
+ ice: ICE_CONNECTION_TIMEOUT,
30
+ dtls: DTLS_CONNECTION_TIMEOUT,
31
+ };
32
+
13
33
  /**
14
- * @class MediaConnectionAwaiter
34
+ * Waits for ICE and DTLS connectivity using explicit lifecycle states.
15
35
  */
16
36
  export default class MediaConnectionAwaiter {
17
- private webrtcMediaConnection: any;
18
- private timer: any;
19
- private defer: Defer;
20
- private retried: boolean;
21
- private iceConnected: boolean;
22
- private correlationId: string;
23
- private onTimeoutCallback: () => void;
24
- private peerConnectionStateCallback: () => void;
25
- private iceConnectionStateCallback: () => void;
26
- private iceGatheringStateCallback: () => void;
37
+ private props: MediaConnectionAwaiterProps;
38
+ private state: State = {name: 'idle'};
39
+ private timer?: ReturnType<typeof setTimeout>;
40
+ private iceConnectedAtLeastOnce = false;
41
+ private defer = new Defer();
27
42
 
28
43
  /**
29
- * @param {MediaConnectionAwaiterProps} mediaConnectionAwaiterProps
44
+ * @param {MediaConnectionAwaiterProps} props
30
45
  */
31
- constructor({webrtcMediaConnection, correlationId}: MediaConnectionAwaiterProps) {
32
- this.webrtcMediaConnection = webrtcMediaConnection;
33
- this.defer = new Defer();
34
- this.retried = false;
35
- this.iceConnected = false;
36
- this.correlationId = correlationId;
37
- this.onTimeoutCallback = this.onTimeout.bind(this);
38
- this.peerConnectionStateCallback = this.peerConnectionStateHandler.bind(this);
39
- this.iceConnectionStateCallback = this.iceConnectionStateHandler.bind(this);
40
- this.iceGatheringStateCallback = this.iceGatheringStateHandler.bind(this);
46
+ constructor(props: MediaConnectionAwaiterProps) {
47
+ this.props = props;
41
48
  }
42
49
 
43
50
  /**
44
- * Returns true if the connection is connected, false otherwise.
45
- *
46
- * @returns {boolean}
51
+ * Registers listeners and starts the wait once, settling terminal connections immediately.
52
+ * @returns {Promise<void>} Rejects with FailureResult on failure
47
53
  */
48
- private isConnected(): boolean {
49
- return this.webrtcMediaConnection.getConnectionState() === ConnectionState.Connected;
54
+ waitForMediaConnectionConnected(): Promise<void> {
55
+ if (this.state.name === 'idle') {
56
+ this.registerCallbacks();
57
+ this.evaluate('waitForMediaConnectionConnected');
58
+ }
59
+
60
+ return this.defer.promise;
50
61
  }
51
62
 
52
63
  /**
53
- * Returns true if the connection is in an unrecoverable "failed" state
54
- *
55
- * @returns {boolean}
64
+ * Applies a transition to a new state and owns its deadline or terminal settlement.
65
+ * @param {EnteredState} next - State to enter; an active wait cannot return to idle
66
+ * @param {string} reason - Trigger or reason for the transition
67
+ * @returns {void}
56
68
  */
57
- private isFailed(): boolean {
58
- return this.webrtcMediaConnection.getConnectionState() === ConnectionState.Failed;
69
+ private enter(next: EnteredState, reason: string): void {
70
+ if (this.isTerminal()) {
71
+ return;
72
+ }
73
+
74
+ LoggerProxy.logger.log(
75
+ `Media:MediaConnectionAwaiter#enter --> ${this.state.name} -> ${next.name}: ${reason}`
76
+ );
77
+ this.state = next;
78
+
79
+ switch (next.name) {
80
+ case 'ice':
81
+ case 'dtls':
82
+ this.armTimer(next, reason);
83
+ break;
84
+ case 'connected':
85
+ this.teardown();
86
+ this.defer.resolve();
87
+ break;
88
+ case 'failed':
89
+ this.teardown();
90
+ this.defer.reject(next.result);
91
+ break;
92
+ }
59
93
  }
60
94
 
61
95
  /**
62
- * Returns true if the ICE Gathering is completed, false otherwise.
63
- *
96
+ * Returns whether the promise has settled.
64
97
  * @returns {boolean}
65
98
  */
66
- private isIceGatheringCompleted(): boolean {
67
- return this.webrtcMediaConnection.getIceGatheringState() === 'complete';
99
+ private isTerminal(): boolean {
100
+ return this.state.name === 'connected' || this.state.name === 'failed';
68
101
  }
69
102
 
70
103
  /**
71
- * Clears the callbacks.
72
- *
73
- * @returns {void}
104
+ * Returns the current state only if it owns a connection deadline.
105
+ * @returns {ActiveState | undefined}
74
106
  */
75
- private clearCallbacks(): void {
76
- this.webrtcMediaConnection.off(
77
- MediaConnectionEventNames.ICE_GATHERING_STATE_CHANGED,
78
- this.iceGatheringStateCallback
79
- );
80
- this.webrtcMediaConnection.off(
81
- MediaConnectionEventNames.PEER_CONNECTION_STATE_CHANGED,
82
- this.peerConnectionStateCallback
83
- );
84
- this.webrtcMediaConnection.off(
85
- MediaConnectionEventNames.ICE_CONNECTION_STATE_CHANGED,
86
- this.iceConnectionStateCallback
87
- );
107
+ private getActiveState(): ActiveState | undefined {
108
+ const {state} = this;
109
+
110
+ return state.name === 'ice' || state.name === 'dtls' ? state : undefined;
88
111
  }
89
112
 
90
113
  /**
91
- * On connection state change.
92
- *
93
- * @returns {void}
114
+ * Logs current browser state and transitions when connectivity or phase changes.
115
+ * @param {string} trigger - Callback or operation that triggered evaluation
116
+ * @returns {boolean} Whether a state transition occurred
94
117
  */
95
- connectionStateChange(): void {
118
+ private evaluate(trigger: string): boolean {
119
+ const connection = this.props.webrtcMediaConnection;
120
+ const connectionState = connection.getConnectionState();
121
+
96
122
  LoggerProxy.logger.log(
97
- `Media:MediaConnectionAwaiter#connectionStateChange --> connection state: ${this.webrtcMediaConnection.getConnectionState()}`
123
+ `Media:MediaConnectionAwaiter#evaluate --> triggered by ${trigger}, connection state: ${connectionState}, peer connection state: ${connection.getPeerConnectionState()}, ICE connection state: ${connection.getIceConnectionState()}, ICE gathering state: ${connection.getIceGatheringState()}, awaiter state: ${
124
+ this.state.name
125
+ }`
98
126
  );
99
127
 
100
- if (this.isFailed()) {
101
- LoggerProxy.logger.warn(
102
- 'Media:MediaConnectionAwaiter#connectionStateChange --> ICE failed, rejecting'
103
- );
104
- this.clearCallbacks();
105
-
106
- this.defer.reject({
107
- iceConnected: this.iceConnected,
108
- });
128
+ if (this.isTerminal()) {
129
+ return false;
109
130
  }
110
131
 
111
- if (!this.isConnected()) {
112
- return;
132
+ const connectivity = this.getConnectivity();
133
+ if (connectionState === ConnectionState.Connected) {
134
+ this.enter({name: 'connected'}, trigger);
135
+
136
+ return true;
113
137
  }
138
+ if (connectionState === ConnectionState.Failed || connectionState === ConnectionState.Closed) {
139
+ this.enter({name: 'failed', result: connectivity}, trigger);
114
140
 
115
- clearTimeout(this.timer);
141
+ return true;
142
+ }
116
143
 
117
- this.clearCallbacks();
144
+ const phase = connectivity.iceConnected ? 'dtls' : 'ice';
145
+ if (this.state.name === phase) {
146
+ return false;
147
+ }
118
148
 
119
- LoggerProxy.logger.warn('Media:MediaConnectionAwaiter#connectionStateChange --> Resolving');
149
+ this.enter(phase === 'ice' ? {name: 'ice', gatheringRetried: false} : {name: 'dtls'}, trigger);
120
150
 
121
- this.defer.resolve();
151
+ return true;
122
152
  }
123
153
 
124
154
  /**
125
- * Listener for peer connection state change.
126
- *
155
+ * Listener for peer connection state changes.
127
156
  * @returns {void}
128
157
  */
129
- peerConnectionStateHandler(): void {
130
- const peerConnectionState = this.webrtcMediaConnection.getPeerConnectionState();
131
-
132
- LoggerProxy.logger.log(
133
- `Media:MediaConnectionAwaiter#peerConnectionStateHandler --> Peer connection state change -> ${peerConnectionState}`
134
- );
135
-
136
- this.connectionStateChange();
137
- }
158
+ peerConnectionStateHandler = (): void => {
159
+ this.evaluate('peerConnectionStateHandler');
160
+ };
138
161
 
139
162
  /**
140
- * Listener for ICE connection state change.
141
- *
163
+ * Listener for ICE connection state changes.
142
164
  * @returns {void}
143
165
  */
144
- iceConnectionStateHandler(): void {
145
- const iceConnectionState = this.webrtcMediaConnection.getIceConnectionState();
166
+ iceConnectionStateHandler = (): void => {
167
+ this.evaluate('iceConnectionStateHandler');
168
+ };
146
169
 
147
- LoggerProxy.logger.log(
148
- `Media:MediaConnectionAwaiter#iceConnectionStateHandler --> ICE connection state change -> ${iceConnectionState}`
149
- );
150
-
151
- if (iceConnectionState === 'connected' && !this.iceConnected) {
152
- this.iceConnected = true;
170
+ /**
171
+ * Restarts only an unchanged ICE phase when gathering completes.
172
+ * @returns {void}
173
+ */
174
+ iceGatheringStateHandler = (): void => {
175
+ const changed = this.evaluate('iceGatheringStateHandler');
176
+ if (!changed && this.state.name === 'ice' && this.isIceGatheringCompleted()) {
177
+ this.armTimer(this.state, 'iceGatheringStateHandler: ICE gathering completed');
153
178
  }
154
-
155
- this.connectionStateChange();
156
- }
179
+ };
157
180
 
158
181
  /**
159
- * Listener for ICE gathering state change.
160
- *
182
+ * Rechecks connectivity before applying the deadline or the ICE gathering retry.
161
183
  * @returns {void}
162
184
  */
163
- iceGatheringStateHandler(): void {
164
- const iceGatheringState = this.webrtcMediaConnection.getIceGatheringState();
165
-
166
- LoggerProxy.logger.log(
167
- `Media:MediaConnectionAwaiter#iceGatheringStateHandler --> ICE gathering state change -> ${iceGatheringState}`
168
- );
185
+ onTimeout = (): void => {
186
+ if (this.evaluate('onTimeout')) {
187
+ return;
188
+ }
169
189
 
170
- if (!this.isIceGatheringCompleted()) {
190
+ const state = this.getActiveState();
191
+ if (!state) {
171
192
  return;
172
193
  }
173
194
 
174
- if (this.isConnected()) {
195
+ this.sendMetric().catch((error) => {
196
+ LoggerProxy.logger.warn('Media:MediaConnectionAwaiter#onTimeout --> metric failed', error);
197
+ });
198
+
199
+ if (state.name === 'ice' && !state.gatheringRetried && !this.isIceGatheringCompleted()) {
200
+ this.enter(
201
+ {...state, gatheringRetried: true},
202
+ 'onTimeout: ICE gathering incomplete, retrying once'
203
+ );
204
+
175
205
  return;
176
206
  }
177
207
 
178
- clearTimeout(this.timer);
208
+ this.enter({name: 'failed', result: this.getConnectivity()}, `${state.name} timeout`);
209
+ };
179
210
 
180
- this.timer = setTimeout(this.onTimeoutCallback, ICE_AND_DTLS_CONNECTION_TIMEOUT);
211
+ /**
212
+ * Arms an active phase's deadline and logs every start or restart.
213
+ * @param {ActiveState} state - Active state whose deadline is being started
214
+ * @param {string} reason - Why the deadline is being started or restarted
215
+ * @returns {void}
216
+ */
217
+ private armTimer(state: ActiveState, reason: string): void {
218
+ if (this.timer !== undefined) {
219
+ clearTimeout(this.timer);
220
+ }
221
+ const timeout = PHASE_TIMEOUT[state.name];
222
+ this.timer = setTimeout(this.onTimeout, timeout);
223
+ LoggerProxy.logger.log(
224
+ `Media:MediaConnectionAwaiter#armTimer --> ${state.name} (${timeout}ms): ${reason}`
225
+ );
181
226
  }
182
227
 
183
228
  /**
184
- * sends a metric with some additional info that might help debugging
185
- * issues where browser doesn't update the RTCPeerConnection's iceConnectionState or connectionState
186
- *
229
+ * Releases the deadline and registered listeners on either terminal transition.
187
230
  * @returns {void}
188
231
  */
189
- async sendMetric() {
190
- const stats = await this.webrtcMediaConnection.getStats();
191
-
192
- // in theory we can end up with more than one transport report in the stats,
193
- // but for the purpose of this metric it's fine to just use the first one
194
- const transportReports = Array.from(
195
- stats.values().filter((report) => report.type === 'transport')
196
- ) as Record<string, number | string>[];
197
-
198
- Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.MEDIA_STILL_NOT_CONNECTED, {
199
- correlation_id: this.correlationId,
200
- numTransports: transportReports.length,
201
- dtlsState: transportReports[0]?.dtlsState,
202
- iceState: transportReports[0]?.iceState,
203
- packetsSent: transportReports[0]?.packetsSent,
204
- packetsReceived: transportReports[0]?.packetsReceived,
205
- dataChannelState: this.webrtcMediaConnection.multistreamConnection?.dataChannel?.readyState,
206
- });
232
+ private teardown(): void {
233
+ clearTimeout(this.timer);
234
+ this.timer = undefined;
235
+ this.unregisterCallbacks();
207
236
  }
208
237
 
209
238
  /**
210
- * Function called when the timeout is reached.
211
- *
239
+ * Registers each callback once with a stable function reference.
212
240
  * @returns {void}
213
241
  */
214
- onTimeout(): void {
215
- if (this.isConnected()) {
216
- this.clearCallbacks();
217
-
218
- this.defer.resolve();
219
-
220
- return;
221
- }
222
-
223
- this.sendMetric();
224
-
225
- if (!this.isIceGatheringCompleted()) {
226
- if (!this.retried) {
227
- LoggerProxy.logger.warn(
228
- 'Media:MediaConnectionAwaiter#onTimeout --> ICE gathering did not complete within the timeout for the first time, retrying once'
229
- );
230
-
231
- // retry once if ICE gathering is not completed
232
- this.retried = true;
233
- clearTimeout(this.timer);
234
- this.timer = setTimeout(this.onTimeoutCallback, ICE_AND_DTLS_CONNECTION_TIMEOUT);
235
-
236
- return;
237
- }
238
-
239
- LoggerProxy.logger.warn(
240
- 'Media:MediaConnectionAwaiter#onTimeout --> ICE gathering did not complete within the timeout for the second time, rejecting'
241
- );
242
- } else {
243
- LoggerProxy.logger.warn(
244
- 'Media:MediaConnectionAwaiter#onTimeout --> ICE gathering completed, but connection state is not connected, rejecting'
245
- );
246
- }
247
-
248
- this.clearCallbacks();
249
-
250
- this.defer.reject({
251
- iceConnected: this.iceConnected,
252
- });
242
+ private registerCallbacks(): void {
243
+ const connection = this.props.webrtcMediaConnection;
244
+ connection.on(
245
+ MediaConnectionEventNames.PEER_CONNECTION_STATE_CHANGED,
246
+ this.peerConnectionStateHandler
247
+ );
248
+ connection.on(
249
+ MediaConnectionEventNames.ICE_CONNECTION_STATE_CHANGED,
250
+ this.iceConnectionStateHandler
251
+ );
252
+ connection.on(
253
+ MediaConnectionEventNames.ICE_GATHERING_STATE_CHANGED,
254
+ this.iceGatheringStateHandler
255
+ );
253
256
  }
254
257
 
255
258
  /**
256
- * Waits for the webrtc media connection to be connected.
257
- *
258
- * @returns {Promise}
259
+ * Removes callbacks when the wait reaches a terminal state.
260
+ * @returns {void}
259
261
  */
260
- waitForMediaConnectionConnected(): Promise<void> {
261
- if (this.isConnected()) {
262
- LoggerProxy.logger.log(
263
- 'Media:MediaConnectionAwaiter#waitForMediaConnectionConnected --> Already connected'
264
- );
265
-
266
- return Promise.resolve();
267
- }
268
- LoggerProxy.logger.log(
269
- 'Media:MediaConnectionAwaiter#waitForMediaConnectionConnected --> Waiting for media connection to be connected'
262
+ private unregisterCallbacks(): void {
263
+ const connection = this.props.webrtcMediaConnection;
264
+ connection.off(
265
+ MediaConnectionEventNames.ICE_GATHERING_STATE_CHANGED,
266
+ this.iceGatheringStateHandler
270
267
  );
271
-
272
- this.webrtcMediaConnection.on(
268
+ connection.off(
273
269
  MediaConnectionEventNames.PEER_CONNECTION_STATE_CHANGED,
274
- this.peerConnectionStateCallback
270
+ this.peerConnectionStateHandler
275
271
  );
276
-
277
- this.webrtcMediaConnection.on(
272
+ connection.off(
278
273
  MediaConnectionEventNames.ICE_CONNECTION_STATE_CHANGED,
279
- this.iceConnectionStateCallback
274
+ this.iceConnectionStateHandler
280
275
  );
276
+ }
281
277
 
282
- this.webrtcMediaConnection.on(
283
- MediaConnectionEventNames.ICE_GATHERING_STATE_CHANGED,
284
- this.iceGatheringStateCallback
285
- );
278
+ /**
279
+ * Returns whether ICE gathering has completed.
280
+ * @returns {boolean}
281
+ */
282
+ private isIceGatheringCompleted(): boolean {
283
+ return this.props.webrtcMediaConnection.getIceGatheringState() === 'complete';
284
+ }
286
285
 
287
- this.timer = setTimeout(this.onTimeoutCallback, ICE_AND_DTLS_CONNECTION_TIMEOUT);
286
+ /**
287
+ * Captures current and historical ICE connectivity for failures and metrics.
288
+ * @returns {FailureResult}
289
+ */
290
+ private getConnectivity(): FailureResult {
291
+ const iceState = this.props.webrtcMediaConnection.getIceConnectionState();
292
+ const iceConnected = iceState === 'connected' || iceState === 'completed';
293
+ this.iceConnectedAtLeastOnce ||= iceConnected;
288
294
 
289
- return this.defer.promise;
295
+ return {iceConnected, iceConnectedAtLeastOnce: this.iceConnectedAtLeastOnce};
296
+ }
297
+
298
+ /**
299
+ * Sends connectivity diagnostics when a deadline expires.
300
+ * @returns {Promise<void>}
301
+ */
302
+ private async sendMetric(): Promise<void> {
303
+ // Capture connectivity before awaiting stats, which may finish after another state change.
304
+ const connectivity = this.getConnectivity();
305
+ const connection = this.props.webrtcMediaConnection;
306
+ const stats = await connection.getStats();
307
+
308
+ // There may be multiple transport reports; the first is sufficient for this metric.
309
+ const transportReports = Array.from(
310
+ stats.values().filter((report) => report.type === 'transport')
311
+ ) as Record<string, number | string>[];
312
+
313
+ Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.MEDIA_STILL_NOT_CONNECTED, {
314
+ correlation_id: this.props.correlationId,
315
+ ...connectivity,
316
+ numTransports: transportReports.length,
317
+ dtlsState: transportReports[0]?.dtlsState,
318
+ iceState: transportReports[0]?.iceState,
319
+ packetsSent: transportReports[0]?.packetsSent,
320
+ packetsReceived: transportReports[0]?.packetsReceived,
321
+ dataChannelState: connection.multistreamConnection?.dataChannel?.readyState,
322
+ });
290
323
  }
291
324
  }