Remove MEETING_ENDED event and always send LEFT event with proper reason

This commit is contained in:
juancarmore 2025-07-19 20:00:07 +02:00
parent 200225a948
commit a0e23cd4a7
4 changed files with 14 additions and 41 deletions

View File

@ -332,29 +332,18 @@ export class VideoRoomComponent implements OnInit {
leftReason = LeftEventReason.MEETING_ENDED_BY_SELF; leftReason = LeftEventReason.MEETING_ENDED_BY_SELF;
} }
// Send LEFT or MEETING_ENDED event to the parent component // Send LEFT event to the parent component
let message: WebComponentOutboundEventMessage<WebComponentEvent.MEETING_ENDED | WebComponentEvent.LEFT>; const message: WebComponentOutboundEventMessage<WebComponentEvent.LEFT> = {
if (event.reason === ParticipantLeftReason.ROOM_DELETED) { event: WebComponentEvent.LEFT,
message = { payload: {
event: WebComponentEvent.MEETING_ENDED, roomId: event.roomName,
payload: { participantName: event.participantName,
roomId: event.roomName, reason: leftReason
endedByMe: this.meetingEndedByMe }
} };
} as WebComponentOutboundEventMessage<WebComponentEvent.MEETING_ENDED>;
} else {
message = {
event: WebComponentEvent.LEFT,
payload: {
roomId: event.roomName,
participantName: event.participantName,
reason: leftReason
}
} as WebComponentOutboundEventMessage<WebComponentEvent.LEFT>;
}
this.wcManagerService.sendMessageToParent(message); this.wcManagerService.sendMessageToParent(message);
// Remove the moderator secret from session storage if the participant left for a reason other than browser unload
if (event.reason !== ParticipantLeftReason.BROWSER_UNLOAD) { if (event.reason !== ParticipantLeftReason.BROWSER_UNLOAD) {
this.sessionStorageService.removeModeratorSecret(event.roomName); this.sessionStorageService.removeModeratorSecret(event.roomName);
} }

View File

@ -37,7 +37,7 @@ test.describe('Web Component E2E Tests', () => {
}); });
subscribedToAppErrors = true; subscribedToAppErrors = true;
} }
await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix); await prepareForJoiningRoom(page, MEET_TESTAPP_URL, testRoomPrefix);
participantName = `P-${Math.random().toString(36).substring(2, 9)}`; participantName = `P-${Math.random().toString(36).substring(2, 9)}`;
}); });
@ -91,19 +91,15 @@ test.describe('Web Component E2E Tests', () => {
expect(leftElements.length).toBe(1); expect(leftElements.length).toBe(1);
}); });
test('should successfully join to room and receive MEETING_ENDED event when using end meeting command', async ({ test('should successfully join to room and receive LEFT event when using end meeting command', async ({
page page
}) => { }) => {
await joinRoomAs('moderator', participantName, page); await joinRoomAs('moderator', participantName, page);
await page.click('#end-meeting-btn'); await page.click('#end-meeting-btn');
await page.waitForSelector('.event-MEETING_ENDED'); await page.waitForSelector('.event-LEFT');
const meetingEndedElements = await page.locator('.event-MEETING_ENDED').all(); const meetingEndedElements = await page.locator('.event-LEFT').all();
expect(meetingEndedElements.length).toBe(1); expect(meetingEndedElements.length).toBe(1);
// Check LEFT event does not exist
const leftEventElements = await page.locator('.event-LEFT').all();
expect(leftEventElements.length).toBe(0);
}); });
}); });
}); });

View File

@ -202,10 +202,6 @@ const listenWebComponentEvents = () => {
console.log('LEFT event received:', event); console.log('LEFT event received:', event);
addEventToLog('LEFT', JSON.stringify(event)); addEventToLog('LEFT', JSON.stringify(event));
}); });
meet.on('MEETING_ENDED', (event: CustomEvent<any>) => {
console.log('MEETING_ENDED event received:', event);
addEventToLog('MEETING_ENDED', JSON.stringify(event));
});
meet.on('CLOSED', (event: CustomEvent<any>) => { meet.on('CLOSED', (event: CustomEvent<any>) => {
console.log('CLOSED event received:', event); console.log('CLOSED event received:', event);
addEventToLog('CLOSED', JSON.stringify(event)); addEventToLog('CLOSED', JSON.stringify(event));

View File

@ -16,10 +16,6 @@ export enum WebComponentEvent {
* Event emitted when the local participant leaves the room. * Event emitted when the local participant leaves the room.
*/ */
LEFT = 'LEFT', LEFT = 'LEFT',
/**
* Event emitted when a moderator ends the meeting.
*/
MEETING_ENDED = 'MEETING_ENDED',
/** /**
* Event emitted when the application is closed. * Event emitted when the application is closed.
*/ */
@ -59,10 +55,6 @@ export interface WebComponentEventPayloads {
participantName: string; participantName: string;
reason: LeftEventReason; reason: LeftEventReason;
}; };
[WebComponentEvent.MEETING_ENDED]: {
roomId: string;
endedByMe: boolean; // Indicates if the meeting was ended by the local participant
};
} }
/** /**