Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/@webex/plugin-meetings/src/locus-info/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ export default class LocusInfo extends EventsScope {
* Does a Locus sync. It tries to get the latest delta DTO or if it can't, it falls back to getting the full Locus DTO.
*
* @param {Meeting} meeting
* @param {boolean} isLocusUrlChanged
* @returns {undefined}
*/
private doLocusSync(meeting: any) {
private doLocusSync(meeting: any, isLocusUrlChanged: boolean) {
let isDelta;
let url;
let meetingDestroyed = false;
Expand Down Expand Up @@ -172,6 +173,14 @@ export default class LocusInfo extends EventsScope {
return;
}

// When the locus url changed, if the participants from locus sync response are empty, add the participants from workingCopy to the new locus,
// otherwise the participants info will be lost after the breakout session ends.
if (isLocusUrlChanged) {
if (!res.body.participants?.length) {
res.body.participants = this.locusParser.workingCopy.participants;
}
}

if (isDelta) {
if (res.body.baseSequence) {
meeting.locusInfo.handleLocusDelta(res.body, meeting);
Expand Down Expand Up @@ -217,6 +226,7 @@ export default class LocusInfo extends EventsScope {
*/
applyLocusDeltaData(action: string, locus: any, meeting: any) {
const {DESYNC, USE_CURRENT, USE_INCOMING, WAIT, LOCUS_URL_CHANGED} = LocusDeltaParser.loci;
const isLocusUrlChanged = action === LOCUS_URL_CHANGED;

switch (action) {
case USE_INCOMING:
Expand All @@ -228,7 +238,7 @@ export default class LocusInfo extends EventsScope {
break;
case DESYNC:
case LOCUS_URL_CHANGED:
this.doLocusSync(meeting);
this.doLocusSync(meeting, isLocusUrlChanged);
break;
default:
LoggerProxy.logger.info(
Expand Down
8 changes: 7 additions & 1 deletion packages/@webex/plugin-meetings/src/locus-info/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,13 +728,19 @@ export default class Parser {
break;

case USE_INCOMING:
case LOCUS_URL_CHANGED:
// update working copy for future comparisons.
// Note: The working copy of parser gets updated in .onFullLocus()
// and here when USE_INCOMING or LOCUS_URL_CHANGED locus.
this.workingCopy = newLoci;
break;

case LOCUS_URL_CHANGED:
// update working copy
// and reset the sequence in workingCopy so that the sequence value from locus sync response will be always "newer"
this.workingCopy = newLoci;
this.workingCopy.sequence.entries = [];
break;

case WAIT:
// we've taken newLoci from the front of the queue, so put it back there as we have to wait
// for the one that should be in front of it, before we can process it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2367,12 +2367,20 @@ describe('plugin-meetings', () => {
});
});

it('applyLocusDeltaData handles LOCUS_URL_CHANGED action correctly', () => {
it('applyLocusDeltaData handles LOCUS_URL_CHANGED action correctly', async () => {
const {LOCUS_URL_CHANGED} = LocusDeltaParser.loci;
const fakeDeltaLocus = {id: 'fake delta locus'};
const fakeDeltaLocus = {
url: 'new loci url',
participants: [],
};
const fakeParticipants = [
{participantId: 'participant id 1'},
{participantId: 'participant id 2'},
]
const res = {body: fakeDeltaLocus};
const meeting = {
meetingRequest: {
getLocusDTO: sandbox.stub().resolves({body: fakeDeltaLocus}),
getLocusDTO: sandbox.stub().resolves(res),
},
locusInfo: {
handleLocusDelta: sandbox.stub(),
Expand All @@ -2382,10 +2390,15 @@ describe('plugin-meetings', () => {

locusInfo.locusParser.workingCopy = {
syncUrl: 'current sync url',
participants: fakeParticipants,
};

locusInfo.applyLocusDeltaData(LOCUS_URL_CHANGED, fakeLocus, meeting);

await testUtils.flushPromises();

assert.calledOnceWithExactly(meeting.meetingRequest.getLocusDTO, {url: 'current sync url'});
assert.equal(res.body.participants, fakeParticipants)
});

describe('edge cases for sync failing', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ describe('locus-info/parser', () => {
});

it('replaces current loci when the locus URL changes and incoming sequence is later, even when baseSequence doesn\'t match', () => {
const {USE_INCOMING} = LocusDeltaParser.loci;
const {LOCUS_URL_CHANGED} = LocusDeltaParser.loci;
sandbox.stub(LocusDeltaParser, 'compare').returns(LOCUS_URL_CHANGED);

parser.queue.dequeue = sandbox.stub().returns(NEW_LOCI);
parser.onDeltaAction = sandbox.stub();
Expand All @@ -262,7 +263,10 @@ describe('locus-info/parser', () => {

parser.processDeltaEvent();

assert.equal(parser.workingCopy, NEW_LOCI);
assert.deepEqual(parser.workingCopy, {
...NEW_LOCI,
sequence: {entries: []}
});
});

it('does not replace current loci when the locus URL changes but incoming sequence is not later', () => {
Expand Down
Loading