@webex/plugin-meetings 3.10.0-next.28 → 3.10.0-next.29

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.
@@ -104,13 +104,17 @@ MeetingsUtil.getMediaServerIp = function (sdp) {
104
104
  }
105
105
  return mediaServerIp;
106
106
  };
107
- MeetingsUtil.checkForCorrelationId = function (deviceUrl, locus) {
108
- var devices = [];
109
- if (locus) {
110
- if (locus && locus.self && locus.self.devices) {
111
- devices = locus.self.devices;
112
- }
113
- var foundDevice = devices.find(function (device) {
107
+
108
+ /**
109
+ * Finds correlationId of a device from locus self devices array
110
+ * that matches the given deviceUrl
111
+ * @param {string} deviceUrl
112
+ * @param {object} locusSelf
113
+ * @returns {string|false} correlationId or false if not found
114
+ */
115
+ MeetingsUtil.getCorrelationIdForDevice = function (deviceUrl, locusSelf) {
116
+ if (locusSelf !== null && locusSelf !== void 0 && locusSelf.devices) {
117
+ var foundDevice = locusSelf === null || locusSelf === void 0 ? void 0 : locusSelf.devices.find(function (device) {
114
118
  return device.url === deviceUrl;
115
119
  });
116
120
  if (foundDevice && foundDevice.correlationId) {
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","require","_loggerProxy","_interopRequireDefault","_triggerProxy","_constants2","_metrics","_meetings","MeetingsUtil","getMeetingAddedType","type","DESTINATION_TYPE","LOCUS_ID","_INCOMING_","_CREATED_","handleRoapMercury","envelope","meetingCollection","data","eventType","LOCUSEVENT","MESSAGE_ROAP","meeting","getByKey","MEETING_KEY","CORRELATION_ID","correlationId","_data$message","message","seq","messageType","tieBreaker","errorType","errorCause","Metrics","sendBehavioralMetric","BEHAVIORAL_METRICS","ROAP_MERCURY_EVENT_RECEIVED","correlation_id","message_type","error_type","error_cause","ROAP","ROAP_TYPES","TURN_DISCOVERY_RESPONSE","roap","turnDiscovery","handleTurnDiscoveryResponse","_data$message$sdps","roapMessage","sdp","sdps","length","undefined","roapMessageReceived","getMediaServer","mediaServer","split","find","line","startsWith","shift","replace","toLowerCase","_unused","getMediaServerIp","mediaServerIp","_sdp$split$find$match","match","trim","_unused2","checkForCorrelationId","deviceUrl","locus","devices","self","foundDevice","device","url","parseDefaultSiteFromMeetingPreferences","userPreferences","_userPreferences$site","result","sites","defaultSite","site","default","siteUrl","hasH264Codec","_asyncToGenerator2","_regenerator","mark","_callee","hasCodec","pc","offer","_t","wrap","_context","prev","next","window","RTCPeerConnection","createOffer","offerToReceiveVideo","sent","close","LoggerProxy","logger","warn","abrupt","stop","checkH264Support","_checkH264Support","_callee2","options","_this","_ref2","firstChecked","disableNotifications","delay","maxDuration","shouldTrigger","shouldStopChecking","_context2","_now","Trigger","trigger","file","function","EVENT_TRIGGERS","MEDIA_CODEC_LOADED","log","error","MEDIA_CODEC_MISSING","setTimeout","timestamp","call","_x","apply","arguments","getThisDevice","newLocus","_newLocus$self","_newLocus$self$device","joinedOnThisDevice","thisDevice","state","_JOINED_","_LEFT_","reason","_MOVED_","isBreakoutLocusDTO","_newLocus$controls","_newLocus$controls$br","controls","breakout","sessionType","BREAKOUTS","SESSION_TYPES","BREAKOUT","isValidBreakoutLocus","_locus$fullState","_locus$self","inActiveStatus","fullState","LOCUS","STATE","INACTIVE","isLocusAsBreakout","selfJoined","_default","exports"],"sources":["util.ts"],"sourcesContent":["/* globals window */\n\nimport {\n _CREATED_,\n _INCOMING_,\n _JOINED_,\n _LEFT_,\n DESTINATION_TYPE,\n _MOVED_,\n BREAKOUTS,\n EVENT_TRIGGERS,\n LOCUS,\n LOCUSEVENT,\n ROAP,\n} from '../constants';\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport Trigger from '../common/events/trigger-proxy';\nimport BEHAVIORAL_METRICS from '../metrics/constants';\nimport Metrics from '../metrics';\nimport {MEETING_KEY} from './meetings.types';\n\n/**\n * Meetings Media Codec Missing Event\n * Emitted when H.264 codec is not\n * found in the browser.\n * @event media:codec:missing\n * @instance\n * @memberof MeetingsUtil\n */\n\n/**\n * Meetings Media Codec Loaded Event\n * Emitted when H.264 codec has been\n * loaded in the browser.\n * @event media:codec:loaded\n * @instance\n * @memberof MeetingsUtil\n */\n\nconst MeetingsUtil: any = {};\n\nMeetingsUtil.getMeetingAddedType = (type: DESTINATION_TYPE) =>\n type === DESTINATION_TYPE.LOCUS_ID ? _INCOMING_ : _CREATED_;\n\nMeetingsUtil.handleRoapMercury = (envelope, meetingCollection) => {\n const {data} = envelope;\n const {eventType} = data;\n\n if (eventType === LOCUSEVENT.MESSAGE_ROAP) {\n const meeting = meetingCollection.getByKey(MEETING_KEY.CORRELATION_ID, data.correlationId);\n\n if (meeting) {\n const {seq, messageType, tieBreaker, errorType, errorCause} = data.message;\n\n Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.ROAP_MERCURY_EVENT_RECEIVED, {\n correlation_id: data.correlationId,\n seq,\n message_type: messageType,\n error_type: errorType,\n error_cause: errorCause,\n });\n\n if (messageType === ROAP.ROAP_TYPES.TURN_DISCOVERY_RESPONSE) {\n // turn discovery is not part of normal roap protocol and so we are not handling it\n // through the usual roap state machine\n meeting.roap.turnDiscovery.handleTurnDiscoveryResponse(data.message, 'from mercury');\n } else {\n const roapMessage = {\n seq,\n messageType,\n sdp: data.message.sdps?.length > 0 ? data.message.sdps[0] : undefined,\n tieBreaker,\n errorType,\n errorCause,\n };\n\n meeting.roapMessageReceived(roapMessage);\n }\n }\n }\n};\n\nMeetingsUtil.getMediaServer = (sdp) => {\n let mediaServer;\n\n // Attempt to collect the media server from the roap message.\n try {\n mediaServer = sdp\n .split('\\r\\n')\n .find((line) => line.startsWith('o='))\n .split(' ')\n .shift()\n .replace('o=', '')\n .toLowerCase();\n } catch {\n mediaServer = undefined;\n }\n\n return mediaServer;\n};\n\nMeetingsUtil.getMediaServerIp = (sdp) => {\n let mediaServerIp;\n\n // Attempt to collect the media server from the roap message.\n try {\n mediaServerIp = sdp\n .split('\\r\\n')\n .find((line) => line.startsWith('o='))\n .match(/o=\\S+ \\d+ \\d+ IN IP4 ([\\d.]+)/)?.[1]\n .toLowerCase()\n .trim();\n } catch {\n mediaServerIp = undefined;\n }\n\n return mediaServerIp;\n};\n\nMeetingsUtil.checkForCorrelationId = (deviceUrl, locus) => {\n let devices = [];\n\n if (locus) {\n if (locus && locus.self && locus.self.devices) {\n devices = locus.self.devices;\n }\n\n const foundDevice = devices.find((device) => device.url === deviceUrl);\n\n if (foundDevice && foundDevice.correlationId) {\n return foundDevice.correlationId;\n }\n }\n\n return false;\n};\n\nMeetingsUtil.parseDefaultSiteFromMeetingPreferences = (userPreferences) => {\n let result = '';\n\n if (userPreferences?.sites?.length) {\n const defaultSite = userPreferences.sites.find((site) => site.default);\n\n if (defaultSite) {\n result = defaultSite.siteUrl;\n } else {\n result = userPreferences.sites[0].siteUrl;\n }\n }\n\n return result;\n};\n\n/**\n * Will check to see if the H.264 media codec is supported.\n * @async\n * @private\n * @returns {Promise<boolean>}\n */\nMeetingsUtil.hasH264Codec = async () => {\n let hasCodec = false;\n\n try {\n const pc = new window.RTCPeerConnection();\n const offer = await pc.createOffer({offerToReceiveVideo: true});\n\n if (offer.sdp.match(/^a=rtpmap:\\d+\\s+H264\\/\\d+/m)) {\n hasCodec = true;\n }\n pc.close();\n } catch (error) {\n LoggerProxy.logger.warn(\n 'Meetings:util#hasH264Codec --> Error creating peerConnection for H.264 test.'\n );\n }\n\n return hasCodec;\n};\n\n/**\n * Notifies the user whether or not the H.264\n * codec is present. Will continuously check\n * until max duration.\n * @async\n * @private\n * @param {object} options\n * @param {Number} options.firstChecked Timestamp in milliseconds\n * @param {boolean} options.disableNotifications Default is false. Boolean to enable/disable notification and events\n * @returns {undefined}\n */\nMeetingsUtil.checkH264Support = async function checkH264Support(options: {\n firstChecked: number;\n disableNotifications: boolean;\n}) {\n const {hasH264Codec} = MeetingsUtil;\n const {firstChecked, disableNotifications} = options || {};\n const delay = 5e3; // ms\n const maxDuration = 3e5; // ms\n const shouldTrigger = firstChecked === undefined;\n const shouldStopChecking = firstChecked && Date.now() - firstChecked >= maxDuration;\n\n // Disable notifications and start H.264 download only\n if (disableNotifications) {\n hasH264Codec();\n\n return;\n }\n\n // Codec loaded trigger event notification\n if (await hasH264Codec()) {\n Trigger.trigger(\n this,\n {\n file: 'meetings/util',\n function: 'checkH264Support',\n },\n EVENT_TRIGGERS.MEDIA_CODEC_LOADED\n );\n LoggerProxy.logger.log('Meetings:util#checkH264Support --> H264 codec loaded successfully.');\n\n return;\n }\n\n // Stop checking if past the timelimit\n if (shouldStopChecking) {\n LoggerProxy.logger.error(\n 'Meetings:util#checkH264Support --> Timed out waiting for H264 codec to load.'\n );\n\n return;\n }\n\n // Trigger only once\n if (shouldTrigger) {\n Trigger.trigger(\n this,\n {\n file: 'meetings/util',\n function: 'checkH264Support',\n },\n EVENT_TRIGGERS.MEDIA_CODEC_MISSING\n );\n LoggerProxy.logger.log('Meetings:util#checkH264Support --> H264 codec is missing.');\n }\n\n // Keep checking in intervals to see if codec loaded\n window.setTimeout(() => {\n const timestamp = firstChecked || Date.now();\n\n MeetingsUtil.checkH264Support.call(this, {firstChecked: timestamp});\n }, delay);\n};\n\n/**\n * get device from locus data\n * @param {Object} newLocus new locus data\n * @param {String} deviceUrl current device url\n * @returns {Object}\n */\nMeetingsUtil.getThisDevice = (newLocus: any, deviceUrl: string) => {\n if (newLocus?.self?.devices?.length > 0) {\n return newLocus.self.devices.find((device) => device.url === deviceUrl);\n }\n\n return null;\n};\n\n/**\n * get self device joined status from locus data\n * @param {Object} meeting current meeting data\n * @param {Object} newLocus new locus data\n * @param {String} deviceUrl current device url\n * @returns {Object}\n */\nMeetingsUtil.joinedOnThisDevice = (meeting: any, newLocus: any, deviceUrl: string) => {\n const thisDevice = MeetingsUtil.getThisDevice(newLocus, deviceUrl);\n if (thisDevice) {\n if (!thisDevice.correlationId || meeting?.correlationId === thisDevice.correlationId) {\n return (\n thisDevice.state === _JOINED_ ||\n (thisDevice.state === _LEFT_ && thisDevice.reason === _MOVED_)\n );\n }\n }\n\n return false;\n};\n\n/**\n * check the new locus is breakout session's one or not\n * @param {Object} newLocus new locus data\n * @returns {boolean}\n * @private\n */\nMeetingsUtil.isBreakoutLocusDTO = (newLocus: any) => {\n return newLocus?.controls?.breakout?.sessionType === BREAKOUTS.SESSION_TYPES.BREAKOUT;\n};\n\n/**\n * check the locus is valid breakout locus or not\n * @param {Object} locus\n * @returns {boolean}\n * @private\n */\nMeetingsUtil.isValidBreakoutLocus = (locus: any) => {\n const inActiveStatus = locus?.fullState?.state === LOCUS.STATE.INACTIVE;\n const isLocusAsBreakout = MeetingsUtil.isBreakoutLocusDTO(locus);\n const selfJoined = locus.self?.state === _JOINED_;\n\n return isLocusAsBreakout && !inActiveStatus && selfJoined;\n};\nexport default MeetingsUtil;\n"],"mappings":";;;;;;;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AAaA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,aAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,WAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,QAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAnBA;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMO,YAAiB,GAAG,CAAC,CAAC;AAE5BA,YAAY,CAACC,mBAAmB,GAAG,UAACC,IAAsB;EAAA,OACxDA,IAAI,KAAKC,2BAAgB,CAACC,QAAQ,GAAGC,qBAAU,GAAGC,oBAAS;AAAA;AAE7DN,YAAY,CAACO,iBAAiB,GAAG,UAACC,QAAQ,EAAEC,iBAAiB,EAAK;EAChE,IAAOC,IAAI,GAAIF,QAAQ,CAAhBE,IAAI;EACX,IAAOC,SAAS,GAAID,IAAI,CAAjBC,SAAS;EAEhB,IAAIA,SAAS,KAAKC,qBAAU,CAACC,YAAY,EAAE;IACzC,IAAMC,OAAO,GAAGL,iBAAiB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,KAAK,KAAKC,mBAAQ,IAC5BF,UAAU,CAACC,KAAK,KAAKE,iBAAM,IAAIH,UAAU,CAACI,MAAM,KAAKC,kBAAQ;IAElE;EACF;EAEA,OAAO,KAAK;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA/I,YAAY,CAACgJ,kBAAkB,GAAG,UAACV,QAAa,EAAK;EAAA,IAAAW,kBAAA,EAAAC,qBAAA;EACnD,OAAO,CAAAZ,QAAQ,aAARA,QAAQ,wBAAAW,kBAAA,GAARX,QAAQ,CAAEa,QAAQ,cAAAF,kBAAA,wBAAAC,qBAAA,GAAlBD,kBAAA,CAAoBG,QAAQ,cAAAF,qBAAA,uBAA5BA,qBAAA,CAA8BG,WAAW,MAAKC,oBAAS,CAACC,aAAa,CAACC,QAAQ;AACvF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACAxJ,YAAY,CAACyJ,oBAAoB,GAAG,UAACxF,KAAU,EAAK;EAAA,IAAAyF,gBAAA,EAAAC,WAAA;EAClD,IAAMC,cAAc,GAAG,CAAA3F,KAAK,aAALA,KAAK,wBAAAyF,gBAAA,GAALzF,KAAK,CAAE4F,SAAS,cAAAH,gBAAA,uBAAhBA,gBAAA,CAAkBf,KAAK,MAAKmB,gBAAK,CAACC,KAAK,CAACC,QAAQ;EACvE,IAAMC,iBAAiB,GAAGjK,YAAY,CAACgJ,kBAAkB,CAAC/E,KAAK,CAAC;EAChE,IAAMiG,UAAU,GAAG,EAAAP,WAAA,GAAA1F,KAAK,CAACE,IAAI,cAAAwF,WAAA,uBAAVA,WAAA,CAAYhB,KAAK,MAAKC,mBAAQ;EAEjD,OAAOqB,iBAAiB,IAAI,CAACL,cAAc,IAAIM,UAAU;AAC3D,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAtF,OAAA,GACa9E,YAAY","ignoreList":[]}
1
+ {"version":3,"names":["_constants","require","_loggerProxy","_interopRequireDefault","_triggerProxy","_constants2","_metrics","_meetings","MeetingsUtil","getMeetingAddedType","type","DESTINATION_TYPE","LOCUS_ID","_INCOMING_","_CREATED_","handleRoapMercury","envelope","meetingCollection","data","eventType","LOCUSEVENT","MESSAGE_ROAP","meeting","getByKey","MEETING_KEY","CORRELATION_ID","correlationId","_data$message","message","seq","messageType","tieBreaker","errorType","errorCause","Metrics","sendBehavioralMetric","BEHAVIORAL_METRICS","ROAP_MERCURY_EVENT_RECEIVED","correlation_id","message_type","error_type","error_cause","ROAP","ROAP_TYPES","TURN_DISCOVERY_RESPONSE","roap","turnDiscovery","handleTurnDiscoveryResponse","_data$message$sdps","roapMessage","sdp","sdps","length","undefined","roapMessageReceived","getMediaServer","mediaServer","split","find","line","startsWith","shift","replace","toLowerCase","_unused","getMediaServerIp","mediaServerIp","_sdp$split$find$match","match","trim","_unused2","getCorrelationIdForDevice","deviceUrl","locusSelf","devices","foundDevice","device","url","parseDefaultSiteFromMeetingPreferences","userPreferences","_userPreferences$site","result","sites","defaultSite","site","default","siteUrl","hasH264Codec","_asyncToGenerator2","_regenerator","mark","_callee","hasCodec","pc","offer","_t","wrap","_context","prev","next","window","RTCPeerConnection","createOffer","offerToReceiveVideo","sent","close","LoggerProxy","logger","warn","abrupt","stop","checkH264Support","_checkH264Support","_callee2","options","_this","_ref2","firstChecked","disableNotifications","delay","maxDuration","shouldTrigger","shouldStopChecking","_context2","_now","Trigger","trigger","file","function","EVENT_TRIGGERS","MEDIA_CODEC_LOADED","log","error","MEDIA_CODEC_MISSING","setTimeout","timestamp","call","_x","apply","arguments","getThisDevice","newLocus","_newLocus$self","_newLocus$self$device","self","joinedOnThisDevice","thisDevice","state","_JOINED_","_LEFT_","reason","_MOVED_","isBreakoutLocusDTO","_newLocus$controls","_newLocus$controls$br","controls","breakout","sessionType","BREAKOUTS","SESSION_TYPES","BREAKOUT","isValidBreakoutLocus","locus","_locus$fullState","_locus$self","inActiveStatus","fullState","LOCUS","STATE","INACTIVE","isLocusAsBreakout","selfJoined","_default","exports"],"sources":["util.ts"],"sourcesContent":["/* globals window */\n\nimport {\n _CREATED_,\n _INCOMING_,\n _JOINED_,\n _LEFT_,\n DESTINATION_TYPE,\n _MOVED_,\n BREAKOUTS,\n EVENT_TRIGGERS,\n LOCUS,\n LOCUSEVENT,\n ROAP,\n} from '../constants';\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport Trigger from '../common/events/trigger-proxy';\nimport BEHAVIORAL_METRICS from '../metrics/constants';\nimport Metrics from '../metrics';\nimport {MEETING_KEY} from './meetings.types';\n\n/**\n * Meetings Media Codec Missing Event\n * Emitted when H.264 codec is not\n * found in the browser.\n * @event media:codec:missing\n * @instance\n * @memberof MeetingsUtil\n */\n\n/**\n * Meetings Media Codec Loaded Event\n * Emitted when H.264 codec has been\n * loaded in the browser.\n * @event media:codec:loaded\n * @instance\n * @memberof MeetingsUtil\n */\n\nconst MeetingsUtil: any = {};\n\nMeetingsUtil.getMeetingAddedType = (type: DESTINATION_TYPE) =>\n type === DESTINATION_TYPE.LOCUS_ID ? _INCOMING_ : _CREATED_;\n\nMeetingsUtil.handleRoapMercury = (envelope, meetingCollection) => {\n const {data} = envelope;\n const {eventType} = data;\n\n if (eventType === LOCUSEVENT.MESSAGE_ROAP) {\n const meeting = meetingCollection.getByKey(MEETING_KEY.CORRELATION_ID, data.correlationId);\n\n if (meeting) {\n const {seq, messageType, tieBreaker, errorType, errorCause} = data.message;\n\n Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.ROAP_MERCURY_EVENT_RECEIVED, {\n correlation_id: data.correlationId,\n seq,\n message_type: messageType,\n error_type: errorType,\n error_cause: errorCause,\n });\n\n if (messageType === ROAP.ROAP_TYPES.TURN_DISCOVERY_RESPONSE) {\n // turn discovery is not part of normal roap protocol and so we are not handling it\n // through the usual roap state machine\n meeting.roap.turnDiscovery.handleTurnDiscoveryResponse(data.message, 'from mercury');\n } else {\n const roapMessage = {\n seq,\n messageType,\n sdp: data.message.sdps?.length > 0 ? data.message.sdps[0] : undefined,\n tieBreaker,\n errorType,\n errorCause,\n };\n\n meeting.roapMessageReceived(roapMessage);\n }\n }\n }\n};\n\nMeetingsUtil.getMediaServer = (sdp) => {\n let mediaServer;\n\n // Attempt to collect the media server from the roap message.\n try {\n mediaServer = sdp\n .split('\\r\\n')\n .find((line) => line.startsWith('o='))\n .split(' ')\n .shift()\n .replace('o=', '')\n .toLowerCase();\n } catch {\n mediaServer = undefined;\n }\n\n return mediaServer;\n};\n\nMeetingsUtil.getMediaServerIp = (sdp) => {\n let mediaServerIp;\n\n // Attempt to collect the media server from the roap message.\n try {\n mediaServerIp = sdp\n .split('\\r\\n')\n .find((line) => line.startsWith('o='))\n .match(/o=\\S+ \\d+ \\d+ IN IP4 ([\\d.]+)/)?.[1]\n .toLowerCase()\n .trim();\n } catch {\n mediaServerIp = undefined;\n }\n\n return mediaServerIp;\n};\n\n/**\n * Finds correlationId of a device from locus self devices array\n * that matches the given deviceUrl\n * @param {string} deviceUrl\n * @param {object} locusSelf\n * @returns {string|false} correlationId or false if not found\n */\nMeetingsUtil.getCorrelationIdForDevice = (deviceUrl: string, locusSelf: any) => {\n if (locusSelf?.devices) {\n const foundDevice = locusSelf?.devices.find((device) => device.url === deviceUrl);\n\n if (foundDevice && foundDevice.correlationId) {\n return foundDevice.correlationId;\n }\n }\n\n return false;\n};\n\nMeetingsUtil.parseDefaultSiteFromMeetingPreferences = (userPreferences) => {\n let result = '';\n\n if (userPreferences?.sites?.length) {\n const defaultSite = userPreferences.sites.find((site) => site.default);\n\n if (defaultSite) {\n result = defaultSite.siteUrl;\n } else {\n result = userPreferences.sites[0].siteUrl;\n }\n }\n\n return result;\n};\n\n/**\n * Will check to see if the H.264 media codec is supported.\n * @async\n * @private\n * @returns {Promise<boolean>}\n */\nMeetingsUtil.hasH264Codec = async () => {\n let hasCodec = false;\n\n try {\n const pc = new window.RTCPeerConnection();\n const offer = await pc.createOffer({offerToReceiveVideo: true});\n\n if (offer.sdp.match(/^a=rtpmap:\\d+\\s+H264\\/\\d+/m)) {\n hasCodec = true;\n }\n pc.close();\n } catch (error) {\n LoggerProxy.logger.warn(\n 'Meetings:util#hasH264Codec --> Error creating peerConnection for H.264 test.'\n );\n }\n\n return hasCodec;\n};\n\n/**\n * Notifies the user whether or not the H.264\n * codec is present. Will continuously check\n * until max duration.\n * @async\n * @private\n * @param {object} options\n * @param {Number} options.firstChecked Timestamp in milliseconds\n * @param {boolean} options.disableNotifications Default is false. Boolean to enable/disable notification and events\n * @returns {undefined}\n */\nMeetingsUtil.checkH264Support = async function checkH264Support(options: {\n firstChecked: number;\n disableNotifications: boolean;\n}) {\n const {hasH264Codec} = MeetingsUtil;\n const {firstChecked, disableNotifications} = options || {};\n const delay = 5e3; // ms\n const maxDuration = 3e5; // ms\n const shouldTrigger = firstChecked === undefined;\n const shouldStopChecking = firstChecked && Date.now() - firstChecked >= maxDuration;\n\n // Disable notifications and start H.264 download only\n if (disableNotifications) {\n hasH264Codec();\n\n return;\n }\n\n // Codec loaded trigger event notification\n if (await hasH264Codec()) {\n Trigger.trigger(\n this,\n {\n file: 'meetings/util',\n function: 'checkH264Support',\n },\n EVENT_TRIGGERS.MEDIA_CODEC_LOADED\n );\n LoggerProxy.logger.log('Meetings:util#checkH264Support --> H264 codec loaded successfully.');\n\n return;\n }\n\n // Stop checking if past the timelimit\n if (shouldStopChecking) {\n LoggerProxy.logger.error(\n 'Meetings:util#checkH264Support --> Timed out waiting for H264 codec to load.'\n );\n\n return;\n }\n\n // Trigger only once\n if (shouldTrigger) {\n Trigger.trigger(\n this,\n {\n file: 'meetings/util',\n function: 'checkH264Support',\n },\n EVENT_TRIGGERS.MEDIA_CODEC_MISSING\n );\n LoggerProxy.logger.log('Meetings:util#checkH264Support --> H264 codec is missing.');\n }\n\n // Keep checking in intervals to see if codec loaded\n window.setTimeout(() => {\n const timestamp = firstChecked || Date.now();\n\n MeetingsUtil.checkH264Support.call(this, {firstChecked: timestamp});\n }, delay);\n};\n\n/**\n * get device from locus data\n * @param {Object} newLocus new locus data\n * @param {String} deviceUrl current device url\n * @returns {Object}\n */\nMeetingsUtil.getThisDevice = (newLocus: any, deviceUrl: string) => {\n if (newLocus?.self?.devices?.length > 0) {\n return newLocus.self.devices.find((device) => device.url === deviceUrl);\n }\n\n return null;\n};\n\n/**\n * get self device joined status from locus data\n * @param {Object} meeting current meeting data\n * @param {Object} newLocus new locus data\n * @param {String} deviceUrl current device url\n * @returns {Object}\n */\nMeetingsUtil.joinedOnThisDevice = (meeting: any, newLocus: any, deviceUrl: string) => {\n const thisDevice = MeetingsUtil.getThisDevice(newLocus, deviceUrl);\n if (thisDevice) {\n if (!thisDevice.correlationId || meeting?.correlationId === thisDevice.correlationId) {\n return (\n thisDevice.state === _JOINED_ ||\n (thisDevice.state === _LEFT_ && thisDevice.reason === _MOVED_)\n );\n }\n }\n\n return false;\n};\n\n/**\n * check the new locus is breakout session's one or not\n * @param {Object} newLocus new locus data\n * @returns {boolean}\n * @private\n */\nMeetingsUtil.isBreakoutLocusDTO = (newLocus: any) => {\n return newLocus?.controls?.breakout?.sessionType === BREAKOUTS.SESSION_TYPES.BREAKOUT;\n};\n\n/**\n * check the locus is valid breakout locus or not\n * @param {Object} locus\n * @returns {boolean}\n * @private\n */\nMeetingsUtil.isValidBreakoutLocus = (locus: any) => {\n const inActiveStatus = locus?.fullState?.state === LOCUS.STATE.INACTIVE;\n const isLocusAsBreakout = MeetingsUtil.isBreakoutLocusDTO(locus);\n const selfJoined = locus.self?.state === _JOINED_;\n\n return isLocusAsBreakout && !inActiveStatus && selfJoined;\n};\nexport default MeetingsUtil;\n"],"mappings":";;;;;;;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AAaA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,aAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,WAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,QAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA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KAAK,CAACC,QAAQ;EACvE,IAAMC,iBAAiB,GAAGlK,YAAY,CAACgJ,kBAAkB,CAACU,KAAK,CAAC;EAChE,IAAMS,UAAU,GAAG,EAAAP,WAAA,GAAAF,KAAK,CAAClB,IAAI,cAAAoB,WAAA,uBAAVA,WAAA,CAAYjB,KAAK,MAAKC,mBAAQ;EAEjD,OAAOsB,iBAAiB,IAAI,CAACL,cAAc,IAAIM,UAAU;AAC3D,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAxF,OAAA,GACa7E,YAAY","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import HashTree from './hashTree';
2
2
  import { Enum } from '../constants';
3
- import { HtMeta } from './types';
3
+ import { HashTreeObject } from './types';
4
4
  import { LocusDTO } from '../locus-info/types';
5
5
  export interface DataSet {
6
6
  url: string;
@@ -14,10 +14,6 @@ export interface DataSet {
14
14
  exponent: number;
15
15
  };
16
16
  }
17
- export interface HashTreeObject {
18
- htMeta: HtMeta;
19
- data: Record<string, any>;
20
- }
21
17
  export interface RootHashMessage {
22
18
  dataSets: Array<DataSet>;
23
19
  }
@@ -41,12 +37,6 @@ export type LocusInfoUpdateType = Enum<typeof LocusInfoUpdateType>;
41
37
  export type LocusInfoUpdateCallback = (updateType: LocusInfoUpdateType, data?: {
42
38
  updatedObjects: HashTreeObject[];
43
39
  }) => void;
44
- /**
45
- * Checks if the given hash tree object is of type "self"
46
- * @param {HashTreeObject} object object to check
47
- * @returns {boolean} True if the object is of type "self", false otherwise
48
- */
49
- export declare function isSelf(object: HashTreeObject): boolean;
50
40
  /**
51
41
  * Parses hash tree eventing locus data
52
42
  */
@@ -27,3 +27,7 @@ export interface HtMeta {
27
27
  };
28
28
  dataSetNames: string[];
29
29
  }
30
+ export interface HashTreeObject {
31
+ htMeta: HtMeta;
32
+ data: Record<string, any>;
33
+ }
@@ -1,3 +1,10 @@
1
+ import { HashTreeObject } from './types';
2
+ /**
3
+ * Checks if the given hash tree object is of type "self"
4
+ * @param {HashTreeObject} object object to check
5
+ * @returns {boolean} True if the object is of type "self", false otherwise
6
+ */
7
+ export declare function isSelf(object: HashTreeObject): boolean;
1
8
  /**
2
9
  * Analyzes given part of Locus DTO recursively and delete any nested objects that have their own htMeta
3
10
  *
@@ -1,6 +1,7 @@
1
1
  import EventsScope from '../common/events/events-scope';
2
2
  import { LOCUSEVENT } from '../constants';
3
- import HashTreeParser, { DataSet, HashTreeMessage, HashTreeObject } from '../hashTree/hashTreeParser';
3
+ import HashTreeParser, { DataSet, HashTreeMessage } from '../hashTree/hashTreeParser';
4
+ import { HashTreeObject } from '../hashTree/types';
4
5
  import { Links, LocusDTO } from './types';
5
6
  export type LocusLLMEvent = {
6
7
  data: {
@@ -448,7 +448,7 @@ var Webinar = _webexCore.WebexPlugin.extend({
448
448
  }, _callee7);
449
449
  }))();
450
450
  },
451
- version: "3.10.0-next.28"
451
+ version: "3.10.0-next.29"
452
452
  });
453
453
  var _default = exports.default = Webinar;
454
454
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -93,5 +93,5 @@
93
93
  "//": [
94
94
  "TODO: upgrade jwt-decode when moving to node 18"
95
95
  ],
96
- "version": "3.10.0-next.28"
96
+ "version": "3.10.0-next.29"
97
97
  }
@@ -3,9 +3,9 @@ import HashTree, {LeafDataItem} from './hashTree';
3
3
  import LoggerProxy from '../common/logs/logger-proxy';
4
4
  import {Enum, HTTP_VERBS} from '../constants';
5
5
  import {DataSetNames, EMPTY_HASH} from './constants';
6
- import {ObjectType, HtMeta} from './types';
6
+ import {ObjectType, HtMeta, HashTreeObject} from './types';
7
7
  import {LocusDTO} from '../locus-info/types';
8
- import {deleteNestedObjectsWithHtMeta} from './utils';
8
+ import {deleteNestedObjectsWithHtMeta, isSelf} from './utils';
9
9
 
10
10
  export interface DataSet {
11
11
  url: string;
@@ -20,11 +20,6 @@ export interface DataSet {
20
20
  };
21
21
  }
22
22
 
23
- export interface HashTreeObject {
24
- htMeta: HtMeta;
25
- data: Record<string, any>;
26
- }
27
-
28
23
  export interface RootHashMessage {
29
24
  dataSets: Array<DataSet>;
30
25
  }
@@ -60,15 +55,6 @@ export type LocusInfoUpdateCallback = (
60
55
  */
61
56
  class MeetingEndedError extends Error {}
62
57
 
63
- /**
64
- * Checks if the given hash tree object is of type "self"
65
- * @param {HashTreeObject} object object to check
66
- * @returns {boolean} True if the object is of type "self", false otherwise
67
- */
68
- export function isSelf(object: HashTreeObject) {
69
- return object.htMeta.elementId.type.toLowerCase() === ObjectType.self;
70
- }
71
-
72
58
  /**
73
59
  * Parses hash tree eventing locus data
74
60
  */
@@ -32,3 +32,8 @@ export interface HtMeta {
32
32
  };
33
33
  dataSetNames: string[];
34
34
  }
35
+
36
+ export interface HashTreeObject {
37
+ htMeta: HtMeta;
38
+ data: Record<string, any>;
39
+ }
@@ -1,5 +1,16 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
2
 
3
+ import {ObjectType, HashTreeObject} from './types';
4
+
5
+ /**
6
+ * Checks if the given hash tree object is of type "self"
7
+ * @param {HashTreeObject} object object to check
8
+ * @returns {boolean} True if the object is of type "self", false otherwise
9
+ */
10
+ export function isSelf(object: HashTreeObject) {
11
+ return object.htMeta.elementId.type.toLowerCase() === ObjectType.self;
12
+ }
13
+
3
14
  /**
4
15
  * Analyzes given part of Locus DTO recursively and delete any nested objects that have their own htMeta
5
16
  *
@@ -34,11 +34,10 @@ import BEHAVIORAL_METRICS from '../metrics/constants';
34
34
  import HashTreeParser, {
35
35
  DataSet,
36
36
  HashTreeMessage,
37
- HashTreeObject,
38
- isSelf,
39
37
  LocusInfoUpdateType,
40
38
  } from '../hashTree/hashTreeParser';
41
- import {ObjectType, ObjectTypeToLocusKeyMap} from '../hashTree/types';
39
+ import {HashTreeObject, ObjectType, ObjectTypeToLocusKeyMap} from '../hashTree/types';
40
+ import {isSelf} from '../hashTree/utils';
42
41
  import {Links, LocusDTO, LocusFullState} from './types';
43
42
 
44
43
  export type LocusLLMEvent = {
@@ -67,6 +67,8 @@ import {SpaceIDDeprecatedError} from '../common/errors/webex-errors';
67
67
  import NoMeetingInfoError from '../common/errors/no-meeting-info';
68
68
  import JoinForbiddenError from '../common/errors/join-forbidden-error';
69
69
  import {HashTreeMessage} from '../hashTree/hashTreeParser';
70
+ import {HashTreeObject} from '../hashTree/types';
71
+ import {isSelf} from '../hashTree/utils';
70
72
 
71
73
  let mediaLogger;
72
74
 
@@ -420,31 +422,36 @@ export default class Meetings extends WebexPlugin {
420
422
  * @memberof Meetings
421
423
  */
422
424
  getCorrespondingMeetingByLocus(data: LocusEvent) {
423
- if (
424
- data.eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED &&
425
- data.stateElementsMessage?.locusUrl
426
- ) {
427
- return this.meetingCollection.getByKey(
428
- MEETING_KEY.LOCUS_URL,
429
- data.stateElementsMessage.locusUrl
430
- );
425
+ const locusUrl =
426
+ data.stateElementsMessage?.locusUrl || // hash tree event
427
+ data.locusUrl; // classic event
428
+
429
+ // first try to find by locusUrl - that's the simplest and quickest way
430
+ const existingMeeting = this.meetingCollection.getByKey(MEETING_KEY.LOCUS_URL, locusUrl);
431
+
432
+ if (existingMeeting) {
433
+ return existingMeeting;
431
434
  }
432
435
 
433
- // getting meeting by correlationId. This will happen for the new event
434
- // Either the locus
435
- // TODO : Add check for the callBack Address
436
+ // if that didn't work, fallback to other fields like correlationId, sipUri, etc
437
+
438
+ // If the event is a hash tree event, we need to extract "self" object from it
439
+ // We don't care about the version, just need to find the meeting this event is for,
440
+ // so any hash tree object of type "self" will do
441
+ const hashTreeEventSelf = data.stateElementsMessage?.locusStateElements?.find(
442
+ (obj: HashTreeObject) => isSelf(obj)
443
+ )?.data;
444
+
445
+ const self = hashTreeEventSelf || data.locus?.self;
446
+
436
447
  return (
437
- this.meetingCollection.getByKey(MEETING_KEY.LOCUS_URL, data.locusUrl) ||
438
448
  // @ts-ignore
439
449
  this.meetingCollection.getByKey(
440
450
  MEETING_KEY.CORRELATION_ID,
441
451
  // @ts-ignore
442
- MeetingsUtil.checkForCorrelationId(this.webex.internal.device.url, data.locus)
443
- ) ||
444
- this.meetingCollection.getByKey(
445
- MEETING_KEY.SIP_URI,
446
- data.locus?.self?.callbackInfo?.callbackAddress
452
+ MeetingsUtil.getCorrelationIdForDevice(this.webex.internal.device.url, self)
447
453
  ) ||
454
+ this.meetingCollection.getByKey(MEETING_KEY.SIP_URI, self?.callbackInfo?.callbackAddress) ||
448
455
  (data.locus?.info?.isUnifiedSpaceMeeting
449
456
  ? undefined
450
457
  : this.meetingCollection.getByKey(
@@ -117,15 +117,16 @@ MeetingsUtil.getMediaServerIp = (sdp) => {
117
117
  return mediaServerIp;
118
118
  };
119
119
 
120
- MeetingsUtil.checkForCorrelationId = (deviceUrl, locus) => {
121
- let devices = [];
122
-
123
- if (locus) {
124
- if (locus && locus.self && locus.self.devices) {
125
- devices = locus.self.devices;
126
- }
127
-
128
- const foundDevice = devices.find((device) => device.url === deviceUrl);
120
+ /**
121
+ * Finds correlationId of a device from locus self devices array
122
+ * that matches the given deviceUrl
123
+ * @param {string} deviceUrl
124
+ * @param {object} locusSelf
125
+ * @returns {string|false} correlationId or false if not found
126
+ */
127
+ MeetingsUtil.getCorrelationIdForDevice = (deviceUrl: string, locusSelf: any) => {
128
+ if (locusSelf?.devices) {
129
+ const foundDevice = locusSelf?.devices.find((device) => device.url === deviceUrl);
129
130
 
130
131
  if (foundDevice && foundDevice.correlationId) {
131
132
  return foundDevice.correlationId;
@@ -1,4 +1,5 @@
1
- import {deleteNestedObjectsWithHtMeta} from '../../../../src/hashTree/utils';
1
+ import {HashTreeObject, ObjectType} from '../../../../src/hashTree/types';
2
+ import {deleteNestedObjectsWithHtMeta, isSelf} from '../../../../src/hashTree/utils';
2
3
 
3
4
  import {assert} from '@webex/test-helper-chai';
4
5
 
@@ -100,4 +101,40 @@ describe('Hash Tree Utils', () => {
100
101
  });
101
102
  });
102
103
  });
104
+
105
+ describe('#isSelf', () => {
106
+ ['self', 'SELF', 'Self'].forEach((type) => {
107
+ it(`should return true for object with type="${type}"`, () => {
108
+ const selfObject = {
109
+ htMeta: {
110
+ elementId: {
111
+ type,
112
+ id: 1,
113
+ version: 1,
114
+ },
115
+ dataSetNames: [],
116
+ },
117
+ data: {},
118
+ };
119
+
120
+ assert.isTrue(isSelf(selfObject as HashTreeObject));
121
+ });
122
+ });
123
+
124
+ it('should return false for non-self object', () => {
125
+ const participantObject = {
126
+ htMeta: {
127
+ elementId: {
128
+ type: ObjectType.participant,
129
+ id: 2,
130
+ version: 1,
131
+ },
132
+ dataSetNames: [],
133
+ },
134
+ data: {},
135
+ };
136
+
137
+ assert.isFalse(isSelf(participantObject));
138
+ });
139
+ });
103
140
  });
@@ -2911,7 +2911,7 @@ describe('plugin-meetings', () => {
2911
2911
  conversationUrl: 'conversationUrl1',
2912
2912
  };
2913
2913
 
2914
- sinon.stub(MeetingsUtil, 'checkForCorrelationId').returns('correlationId1');
2914
+ sinon.stub(MeetingsUtil, 'getCorrelationIdForDevice').returns('correlationId1');
2915
2915
  });
2916
2916
  afterEach(() => {
2917
2917
  sinon.restore();
@@ -3017,6 +3017,197 @@ describe('plugin-meetings', () => {
3017
3017
  );
3018
3018
  assert.calledWith(webex.meetings.meetingCollection.getByKey, 'meetingNumber', '123456');
3019
3019
  });
3020
+
3021
+ describe('when receiving hash tree events', () => {
3022
+ let hashTreeEvent;
3023
+
3024
+ beforeEach(() => {
3025
+ MeetingsUtil.getCorrelationIdForDevice.restore();
3026
+ sinon.spy(MeetingsUtil, 'getCorrelationIdForDevice');
3027
+
3028
+ hashTreeEvent = {
3029
+ eventType: 'locus.state_message',
3030
+ stateElementsMessage: {
3031
+ locusUrl: url1,
3032
+ locusStateElements: [
3033
+ {
3034
+ htMeta: {
3035
+ elementId: {
3036
+ type: 'participant',
3037
+ id: 2,
3038
+ version: 1,
3039
+ },
3040
+ dataSetNames: ['main'],
3041
+ },
3042
+ data: {
3043
+ id: 'participant1',
3044
+ },
3045
+ },
3046
+ {
3047
+ htMeta: {
3048
+ elementId: {
3049
+ type: 'Self',
3050
+ id: 1,
3051
+ version: 1,
3052
+ },
3053
+ dataSetNames: ['self'],
3054
+ },
3055
+ data: {
3056
+ callbackInfo: {
3057
+ callbackAddress: 'address1',
3058
+ },
3059
+ devices: [
3060
+ {
3061
+ url: 'deviceUrl',
3062
+ correlationId: 'correlationId1',
3063
+ },
3064
+ ],
3065
+ },
3066
+ },
3067
+ ],
3068
+ },
3069
+ };
3070
+
3071
+ webex.internal.device.url = 'deviceUrl';
3072
+ });
3073
+
3074
+ it('should find meeting by locusUrl from stateElementsMessage', () => {
3075
+ mockGetByKey('locusUrl');
3076
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
3077
+ assert.deepEqual(result, mockReturnMeeting);
3078
+ assert.calledOnceWithExactly(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
3079
+ });
3080
+
3081
+ it('should extract self data from locusStateElements and try correlationId when locusUrl not found', () => {
3082
+ mockGetByKey('correlationId');
3083
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
3084
+ assert.deepEqual(result, mockReturnMeeting);
3085
+ assert.callCount(webex.meetings.meetingCollection.getByKey, 2);
3086
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
3087
+ assert.calledWith(
3088
+ webex.meetings.meetingCollection.getByKey,
3089
+ 'correlationId',
3090
+ 'correlationId1'
3091
+ );
3092
+ assert.calledOnceWithExactly(
3093
+ MeetingsUtil.getCorrelationIdForDevice,
3094
+ 'deviceUrl',
3095
+ hashTreeEvent.stateElementsMessage.locusStateElements[1].data
3096
+ );
3097
+ });
3098
+
3099
+ it('should extract self data from locusStateElements and try sipUri when locusUrl and correlationId not found', () => {
3100
+ mockGetByKey('sipUri');
3101
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
3102
+ assert.deepEqual(result, mockReturnMeeting);
3103
+ assert.callCount(webex.meetings.meetingCollection.getByKey, 3);
3104
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
3105
+ assert.calledWith(
3106
+ webex.meetings.meetingCollection.getByKey,
3107
+ 'correlationId',
3108
+ 'correlationId1'
3109
+ );
3110
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'sipUri', 'address1');
3111
+ });
3112
+
3113
+ it('should try all keys when no meeting found', () => {
3114
+ mockGetByKey();
3115
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
3116
+ assert.isNull(result);
3117
+ assert.callCount(webex.meetings.meetingCollection.getByKey, 5);
3118
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
3119
+ assert.calledWith(
3120
+ webex.meetings.meetingCollection.getByKey,
3121
+ 'correlationId',
3122
+ 'correlationId1'
3123
+ );
3124
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'sipUri', 'address1');
3125
+ // these remaining 2 will never work for hash trees, but just checking that
3126
+ // the calls are made and we don't crash
3127
+ assert.calledWith(
3128
+ webex.meetings.meetingCollection.getByKey,
3129
+ 'conversationUrl',
3130
+ undefined
3131
+ );
3132
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'meetingNumber', undefined);
3133
+ });
3134
+
3135
+ it('should handle hash tree event with no self object', () => {
3136
+ mockGetByKey();
3137
+ hashTreeEvent.stateElementsMessage.locusStateElements = [
3138
+ {
3139
+ htMeta: {
3140
+ elementId: {
3141
+ type: 'participant',
3142
+ id: 2,
3143
+ version: 1,
3144
+ },
3145
+ dataSetNames: ['dataset1'],
3146
+ },
3147
+ data: {
3148
+ id: 'participant1',
3149
+ },
3150
+ },
3151
+ ];
3152
+
3153
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
3154
+ assert.isNull(result);
3155
+ assert.callCount(webex.meetings.meetingCollection.getByKey, 5);
3156
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
3157
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'correlationId', false);
3158
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'sipUri', undefined);
3159
+ // these remaining 2 will never work for hash trees, but just checking that
3160
+ // the calls are made and we don't crash
3161
+ assert.calledWith(
3162
+ webex.meetings.meetingCollection.getByKey,
3163
+ 'conversationUrl',
3164
+ undefined
3165
+ );
3166
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'meetingNumber', undefined);
3167
+ });
3168
+
3169
+ it('should handle hash tree event with empty locusStateElements', () => {
3170
+ mockGetByKey();
3171
+ hashTreeEvent.stateElementsMessage.locusStateElements = [];
3172
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
3173
+ assert.isNull(result);
3174
+ assert.callCount(webex.meetings.meetingCollection.getByKey, 5);
3175
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
3176
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'correlationId', false);
3177
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'sipUri', undefined);
3178
+ // these remaining 2 will never work for hash trees, but just checking that
3179
+ // the calls are made and we don't crash
3180
+ assert.calledWith(
3181
+ webex.meetings.meetingCollection.getByKey,
3182
+ 'conversationUrl',
3183
+ undefined
3184
+ );
3185
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'meetingNumber', undefined);
3186
+ });
3187
+
3188
+ it('should handle hash tree event with self object but no callbackAddress', () => {
3189
+ mockGetByKey('meetingNumber');
3190
+ delete hashTreeEvent.stateElementsMessage.locusStateElements[1].data.callbackInfo;
3191
+ const result = webex.meetings.getCorrespondingMeetingByLocus(hashTreeEvent);
3192
+ assert.deepEqual(result, mockReturnMeeting);
3193
+ assert.callCount(webex.meetings.meetingCollection.getByKey, 5);
3194
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'locusUrl', url1);
3195
+ assert.calledWith(
3196
+ webex.meetings.meetingCollection.getByKey,
3197
+ 'correlationId',
3198
+ 'correlationId1'
3199
+ );
3200
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'sipUri', undefined);
3201
+ // these remaining 2 will never work for hash trees, but just checking that
3202
+ // the calls are made and we don't crash
3203
+ assert.calledWith(
3204
+ webex.meetings.meetingCollection.getByKey,
3205
+ 'conversationUrl',
3206
+ undefined
3207
+ );
3208
+ assert.calledWith(webex.meetings.meetingCollection.getByKey, 'meetingNumber', undefined);
3209
+ });
3210
+ });
3020
3211
  });
3021
3212
 
3022
3213
  describe('#sortLocusArrayToUpdate', () => {