diff --git a/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts b/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts index 1fa764c..db8145d 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts +++ b/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts @@ -16,6 +16,7 @@ import { ApplicationFeatures, AuthService, FeatureConfigurationService, + MeetingService, NavigationService, NotificationService, ParticipantTokenService, @@ -32,7 +33,6 @@ import { WebComponentOutboundEventMessage } from '@lib/typings/ce'; import { MeetSignalType } from '@lib/typings/ce/event.model'; - import { ApiDirectiveModule, DataPacket_Kind, @@ -93,6 +93,7 @@ export class VideoRoomComponent implements OnInit, OnDestroy { protected recManagerService: RecordingManagerService, protected authService: AuthService, protected roomService: RoomService, + protected meetingService: MeetingService, protected openviduService: OpenViduService, protected participantService: ParticipantTokenService, protected wcManagerService: WebComponentManagerService, @@ -167,12 +168,12 @@ export class VideoRoomComponent implements OnInit, OnDestroy { async endMeeting() { if (this.participantService.isModeratorParticipant()) { const roomId = this.roomService.getRoomId(); - await this.roomService.endMeeting(roomId); + await this.meetingService.endMeeting(roomId); } } async forceDisconnectParticipant(participant: ParticipantModel) { - await this.roomService.kickParticipant(this.roomId, participant.identity); + await this.meetingService.kickParticipant(this.roomId, participant.identity); } async copyModeratorLink() { diff --git a/frontend/projects/shared-meet-components/src/lib/services/index.ts b/frontend/projects/shared-meet-components/src/lib/services/index.ts index 8736a26..bc4aa17 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/index.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/index.ts @@ -4,6 +4,7 @@ export * from './auth.service'; export * from './global-preferences.service'; export * from './room.service'; export * from './participant-token.service'; +export * from './meeting.service'; export * from './feature-configuration.service'; export * from './recording-manager.service'; export * from './webcomponent-manager.service'; 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 new file mode 100644 index 0000000..694a642 --- /dev/null +++ b/frontend/projects/shared-meet-components/src/lib/services/meeting.service.ts @@ -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 { + 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 { + const path = `${this.MEETINGS_API}/${roomId}/participants/${participantId}`; + await this.httpService.deleteRequest(path); + this.log.d(`Participant ${participantId} kicked from room ${roomId}`); + } +} diff --git a/frontend/projects/shared-meet-components/src/lib/services/room.service.ts b/frontend/projects/shared-meet-components/src/lib/services/room.service.ts index dac1747..c0e0506 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/room.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/room.service.ts @@ -232,21 +232,4 @@ export class RoomService { const path = `${this.INTERNAL_ROOMS_API}/${roomId}/roles/${secret}`; 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 { - const path = `${this.MEETINGS_API}/${roomId}`; - return this.httpService.deleteRequest(path); - } - - 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}`); - } }