frontend: implement MeetingService for managing meeting actions and refactor VideoRoomComponent to use it

This commit is contained in:
juancarmore 2025-07-07 20:01:30 +02:00
parent f58d728452
commit 7836da8858
4 changed files with 48 additions and 20 deletions

View File

@ -16,6 +16,7 @@ import {
ApplicationFeatures, ApplicationFeatures,
AuthService, AuthService,
FeatureConfigurationService, FeatureConfigurationService,
MeetingService,
NavigationService, NavigationService,
NotificationService, NotificationService,
ParticipantTokenService, ParticipantTokenService,
@ -32,7 +33,6 @@ import {
WebComponentOutboundEventMessage WebComponentOutboundEventMessage
} from '@lib/typings/ce'; } from '@lib/typings/ce';
import { MeetSignalType } from '@lib/typings/ce/event.model'; import { MeetSignalType } from '@lib/typings/ce/event.model';
import { import {
ApiDirectiveModule, ApiDirectiveModule,
DataPacket_Kind, DataPacket_Kind,
@ -93,6 +93,7 @@ export class VideoRoomComponent implements OnInit, OnDestroy {
protected recManagerService: RecordingManagerService, protected recManagerService: RecordingManagerService,
protected authService: AuthService, protected authService: AuthService,
protected roomService: RoomService, protected roomService: RoomService,
protected meetingService: MeetingService,
protected openviduService: OpenViduService, protected openviduService: OpenViduService,
protected participantService: ParticipantTokenService, protected participantService: ParticipantTokenService,
protected wcManagerService: WebComponentManagerService, protected wcManagerService: WebComponentManagerService,
@ -167,12 +168,12 @@ export class VideoRoomComponent implements OnInit, OnDestroy {
async endMeeting() { async endMeeting() {
if (this.participantService.isModeratorParticipant()) { if (this.participantService.isModeratorParticipant()) {
const roomId = this.roomService.getRoomId(); const roomId = this.roomService.getRoomId();
await this.roomService.endMeeting(roomId); await this.meetingService.endMeeting(roomId);
} }
} }
async forceDisconnectParticipant(participant: ParticipantModel) { async forceDisconnectParticipant(participant: ParticipantModel) {
await this.roomService.kickParticipant(this.roomId, participant.identity); await this.meetingService.kickParticipant(this.roomId, participant.identity);
} }
async copyModeratorLink() { async copyModeratorLink() {

View File

@ -4,6 +4,7 @@ export * from './auth.service';
export * from './global-preferences.service'; export * from './global-preferences.service';
export * from './room.service'; export * from './room.service';
export * from './participant-token.service'; export * from './participant-token.service';
export * from './meeting.service';
export * from './feature-configuration.service'; export * from './feature-configuration.service';
export * from './recording-manager.service'; export * from './recording-manager.service';
export * from './webcomponent-manager.service'; export * from './webcomponent-manager.service';

View File

@ -0,0 +1,43 @@
import { Injectable } from '@angular/core';
import { HttpService } from '@lib/services';
import { LoggerService } from 'openvidu-components-angular';
@Injectable({
providedIn: 'root'
})
export class MeetingService {
protected readonly MEETINGS_API = `${HttpService.INTERNAL_API_PATH_PREFIX}/meetings`;
protected log;
constructor(
protected loggerService: LoggerService,
protected httpService: HttpService
) {
this.log = this.loggerService.get('OpenVidu Meet - MeetingService');
}
/**
* Ends a meeting by its room ID.
*
* @param roomId - The unique identifier of the meeting room
* @returns A promise that resolves when the meeting has been ended
*/
async endMeeting(roomId: string): Promise<any> {
const path = `${this.MEETINGS_API}/${roomId}`;
return this.httpService.deleteRequest(path);
}
/**
* Kicks a participant from a meeting.
*
* @param roomId - The unique identifier of the meeting room
* @param participantId - The unique identifier of the participant to be kicked
* @returns A promise that resolves when the participant has been kicked
*/
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}`);
}
}

View File

@ -232,21 +232,4 @@ export class RoomService {
const path = `${this.INTERNAL_ROOMS_API}/${roomId}/roles/${secret}`; const path = `${this.INTERNAL_ROOMS_API}/${roomId}/roles/${secret}`;
return this.httpService.getRequest(path); return this.httpService.getRequest(path);
} }
/**
* Ends a meeting by its room ID.
*
* @param roomId - The unique identifier of the meeting room
* @returns A promise that resolves when the meeting has been ended
*/
async endMeeting(roomId: string): Promise<any> {
const path = `${this.MEETINGS_API}/${roomId}`;
return this.httpService.deleteRequest(path);
}
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}`);
}
} }