webcomponent: add kick participant command
This commit is contained in:
parent
3904ab05b7
commit
424db94781
@ -38,6 +38,6 @@ export class MeetingService {
|
||||
async kickParticipant(roomId: string, participantId: string): Promise<void> {
|
||||
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}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
*
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user