diff --git a/packages/@webex/plugin-meetings/src/meetings/collection.ts b/packages/@webex/plugin-meetings/src/meetings/collection.ts index 17e370dac8f..094f1e3a537 100644 --- a/packages/@webex/plugin-meetings/src/meetings/collection.ts +++ b/packages/@webex/plugin-meetings/src/meetings/collection.ts @@ -60,4 +60,17 @@ export default class MeetingCollection extends Collection { return null; } + + /** + * Gets the meeting that has a webrtc media connection + * NOTE: this function assumes there is no more than 1 such meeting + * + * @returns {Meeting} first meeting found, else undefined + * @public + * @memberof MeetingCollection + */ + public getActiveWebrtcMeeting() { + // @ts-ignore + return find(this.meetings, (meeting) => meeting.mediaProperties.webrtcMediaConnection); + } } diff --git a/packages/@webex/plugin-meetings/src/meetings/index.ts b/packages/@webex/plugin-meetings/src/meetings/index.ts index 76aa7b1d5a2..4e50ea4ef34 100644 --- a/packages/@webex/plugin-meetings/src/meetings/index.ts +++ b/packages/@webex/plugin-meetings/src/meetings/index.ts @@ -1467,4 +1467,15 @@ export default class Meetings extends WebexPlugin { getLogger() { return LoggerProxy.get(); } + + /** + * Returns the first meeting it finds that has the webrtc media connection created. + * Useful for debugging in the console. + * + * @private + * @returns {Meeting} Meeting object that has a webrtc media connection, else undefined + */ + getActiveWebrtcMeeting() { + return this.meetingCollection.getActiveWebrtcMeeting(); + } } diff --git a/packages/@webex/plugin-meetings/test/unit/spec/meetings/collection.js b/packages/@webex/plugin-meetings/test/unit/spec/meetings/collection.js index 7b1a3315edb..bfb98e94d36 100644 --- a/packages/@webex/plugin-meetings/test/unit/spec/meetings/collection.js +++ b/packages/@webex/plugin-meetings/test/unit/spec/meetings/collection.js @@ -62,5 +62,17 @@ describe('plugin-meetings', () => { breakouts: {url: 'url', isActiveBreakout: true}, id: uuid1}); }); }); + + describe('#getActiveWebrtcMeeting', () => { + it('returns the meeting with a webrtc media connection', () => { + const activeMeeting = {value: 'test3', id: uuid.v4(), mediaProperties: { webrtcMediaConnection: 'something'}}; + + meetingCollection.meetings.test = {value: 'test', id: uuid1, mediaProperties: {}}; + meetingCollection.meetings.test2 = {value: 'test2', id: uuid2, mediaProperties: {}}; + meetingCollection.meetings.test3 = activeMeeting; + + assert.equal(meetingCollection.getActiveWebrtcMeeting(), activeMeeting); + }) + }) }); });