diff --git a/frontend/projects/shared-meet-components/src/lib/services/meeting.service.ts b/frontend/projects/shared-meet-components/src/lib/services/meeting.service.ts index 694a642..dbe48e3 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/meeting.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/meeting.service.ts @@ -38,6 +38,6 @@ export class MeetingService { async kickParticipant(roomId: string, participantId: string): Promise { const path = `${this.MEETINGS_API}/${roomId}/participants/${participantId}`; await this.httpService.deleteRequest(path); - this.log.d(`Participant ${participantId} kicked from room ${roomId}`); + this.log.d(`Participant '${participantId}' kicked from room ${roomId}`); } } diff --git a/frontend/projects/shared-meet-components/src/lib/services/webcomponent-manager.service.ts b/frontend/projects/shared-meet-components/src/lib/services/webcomponent-manager.service.ts index 049149b..ecaac2e 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/webcomponent-manager.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/webcomponent-manager.service.ts @@ -111,6 +111,29 @@ export class WebComponentManagerService { break; case WebComponentCommand.LEAVE_ROOM: await this.openviduService.disconnectRoom(); + break; + case WebComponentCommand.KICK_PARTICIPANT: + // Only moderators can kick participants + if (!this.participantService.isModeratorParticipant()) { + this.log.w('Kick participant command received but participant is not a moderator'); + return; + } + + if (!payload || !('participantIdentity' in payload)) { + this.log.e('Kick participant command received without participant identity'); + return; + } + + const participantIdentity = payload['participantIdentity']; + + try { + this.log.d(`Kicking participant '${participantIdentity}' from the meeting...`); + const roomId = this.roomService.getRoomId(); + await this.meetingService.kickParticipant(roomId, participantIdentity); + } catch (error) { + this.log.e(`Error kicking participant '${participantIdentity}':`, error); + } + break; default: break; diff --git a/frontend/webcomponent/src/components/CommandsManager.ts b/frontend/webcomponent/src/components/CommandsManager.ts index 837d5a1..274ff78 100644 --- a/frontend/webcomponent/src/components/CommandsManager.ts +++ b/frontend/webcomponent/src/components/CommandsManager.ts @@ -164,6 +164,14 @@ export class CommandsManager { this.sendMessage(message); } + public kickParticipant(participantIdentity: string) { + const message: WebComponentInboundCommandMessage = { + command: WebComponentCommand.KICK_PARTICIPANT, + payload: { participantIdentity } + }; + this.sendMessage(message); + } + /** * Sends a message to the iframe using window.postMessage * diff --git a/frontend/webcomponent/src/components/OpenViduMeet.ts b/frontend/webcomponent/src/components/OpenViduMeet.ts index b62900f..ed026c6 100644 --- a/frontend/webcomponent/src/components/OpenViduMeet.ts +++ b/frontend/webcomponent/src/components/OpenViduMeet.ts @@ -217,4 +217,12 @@ export class OpenViduMeet extends HTMLElement { public leaveRoom() { this.commandsManager.leaveRoom(); } + + /** + * Kicks a participant from the meeting. + * @param participantIdentity The identity of the participant to kick + */ + public kickParticipant(participantIdentity: string) { + this.commandsManager.kickParticipant(participantIdentity); + } } diff --git a/typings/src/webcomponent/command.model.ts b/typings/src/webcomponent/command.model.ts index 1c71217..3f22e06 100644 --- a/typings/src/webcomponent/command.model.ts +++ b/typings/src/webcomponent/command.model.ts @@ -16,7 +16,12 @@ export enum WebComponentCommand { /** * Disconnects the local participant from the current room. */ - LEAVE_ROOM = 'LEAVE_ROOM' + LEAVE_ROOM = 'LEAVE_ROOM', + /** + * Kicks a participant from the meeting. + * This command is only available for the moderator. + */ + KICK_PARTICIPANT = 'KICK_PARTICIPANT' } /** @@ -34,7 +39,9 @@ export interface WebComponentCommandPayloads { }; [WebComponentCommand.END_MEETING]: void; [WebComponentCommand.LEAVE_ROOM]: void; - // [WebComponentCommand.TOGGLE_CHAT]: void; + [WebComponentCommand.KICK_PARTICIPANT]: { + participantIdentity: string; + }; } /**