day len server theo loi Khoi noi, toi xin tuyen bo mien tru trach nhiem

This commit is contained in:
2024-11-05 15:02:53 +07:00
parent 0f68b51d75
commit 56ba2808c8
22 changed files with 482 additions and 63 deletions

View File

@@ -0,0 +1,7 @@
// import { Module } from '@nestjs/common'
// import { LiveKitService } from './livekit.service'
// @Module({
// providers: [LiveKitService],
// exports: [LiveKitService],
// })
// export class LiveKitModule {}

View File

@@ -0,0 +1,24 @@
import { Injectable } from '@nestjs/common'
// @ts-ignore
import { AccessToken } from 'livekit-server-sdk'
@Injectable()
export class LiveKitParticipantService {
async createAccessToken(participantId: string) {
return new AccessToken(
process.env.LIVEKIT_API_KEY,
process.env.LIVEKIT_API_SECRET,
{
identity: participantId,
},
)
}
async grantRoomJoinPermission(token: AccessToken, roomName: string) {
token.addGrant({ roomJoin: true, room: roomName })
}
async toJWT(token: AccessToken) {
return token.toJwt()
}
}

View File

@@ -0,0 +1,36 @@
// import {
// Room,
// RoomServiceClient,
// RoomCompositeOptions,
// // @ts-ignore
// } from 'livekit-server-sdk'
// import { v4 as uuidv4 } from 'uuid'
// export class LiveKitRoomService {
// private roomServiceClient: RoomServiceClient
// constructor() {
// this.roomServiceClient = new RoomServiceClient(
// process.env.LIVEKIT_URL as string,
// process.env.LIVEKIT_API_KEY as string,
// process.env.LIVEKIT_API_SECRET as string,
// )
// }
// async createServiceMeetingRoom(chattingRoomId: string) {
// const room = await this.roomServiceClient.createRoom({
// maxParticipants: 3,
// name: chattingRoomId,
// })
// return room
// }
// async createWorkshopMeetingRoom(workshopId: string, maxParticipants: number) {
// const room = await this.roomServiceClient.createRoom({
// maxParticipants: maxParticipants,
// name: workshopId,
// })
// return room
// }
// }

View File

@@ -0,0 +1,11 @@
// import { Injectable, OnModuleInit } from '@nestjs/common'
// import { LiveKitRoomService } from './livekit.room.service'
// @Injectable()
// export class LiveKitService implements OnModuleInit {
// private liveKitRoomService: LiveKitRoomService
// async onModuleInit() {
// // init livekit room service
// this.liveKitRoomService = new LiveKitRoomService()
// }
// }

View File

@@ -0,0 +1,5 @@
// @ts-ignore
import { TrackInfo } from 'livekit-server-sdk'
export class LiveKitTrackService {
}