frontend: Add numParticipants to OpenViduMeetRoom and update room creation logic
This commit is contained in:
parent
e86a6e8ed6
commit
ac2e9a59f4
@ -214,13 +214,14 @@ export class RoomService {
|
||||
livekitRoom: Room,
|
||||
roomOptions: OpenViduMeetRoomOptions
|
||||
): OpenViduMeetRoom {
|
||||
const { name: roomName, creationTime } = livekitRoom;
|
||||
const { name: roomName, creationTime, numParticipants } = livekitRoom;
|
||||
const { preferences, expirationDate, roomNamePrefix, maxParticipants } = roomOptions;
|
||||
|
||||
const openviduRoom: OpenViduMeetRoom = {
|
||||
roomName,
|
||||
roomNamePrefix,
|
||||
creationDate: Number(creationTime) * 1000,
|
||||
numParticipants,
|
||||
maxParticipants,
|
||||
expirationDate,
|
||||
moderatorRoomUrl: `${baseUrl}/${roomName}?secret=${secureUid(10)}`,
|
||||
|
||||
@ -17,7 +17,7 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
// import { ConfigService } from '@app/services/config.service';
|
||||
import { HttpService, OpenViduMeetRoomOptions } from 'projects/shared-meet-components/src/public-api';
|
||||
import { HttpService, OpenViduMeetRoom, OpenViduMeetRoomOptions } from 'projects/shared-meet-components/src/public-api';
|
||||
|
||||
import packageInfo from '../../../../package.json';
|
||||
|
||||
@ -145,14 +145,15 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
expirationDate: Date.now() + 3600
|
||||
};
|
||||
|
||||
const room = await this.httpService.createRoom(options);
|
||||
const room: OpenViduMeetRoom = await this.httpService.createRoom(options);
|
||||
|
||||
this.roomForm.get('roomNamePrefix')?.setValue(roomNamePrefix);
|
||||
|
||||
// TODO: Should create a way of select the access role (moderator/participant)
|
||||
const publisherUrl = new URL(room.publisherRoomUrl);
|
||||
const secret = publisherUrl.searchParams.get('secret');
|
||||
const path = publisherUrl.pathname;
|
||||
const isFirstParticipant = room.numParticipants === 0;
|
||||
const accessRoomUrl = new URL(isFirstParticipant ? room.moderatorRoomUrl : room.publisherRoomUrl);
|
||||
|
||||
const secret = accessRoomUrl.searchParams.get('secret');
|
||||
const path = accessRoomUrl.pathname;
|
||||
this.router.navigate([path], { queryParams: { secret } });
|
||||
} catch (error) {
|
||||
console.error('Error creating room ', error);
|
||||
|
||||
@ -17,6 +17,7 @@ export type OpenViduMeetRoomOptions = BaseRoomOptions;
|
||||
export interface OpenViduMeetRoom extends BaseRoomOptions {
|
||||
roomName: string;
|
||||
creationDate: number;
|
||||
numParticipants: number;
|
||||
moderatorRoomUrl: string;
|
||||
publisherRoomUrl: string;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user