53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
/**
|
||
* API для работы с LiveKit
|
||
*/
|
||
|
||
import apiClient from '@/lib/api-client';
|
||
|
||
export interface LiveKitRoomResponse {
|
||
room_name: string;
|
||
ws_url: string;
|
||
access_token: string;
|
||
server_url: string;
|
||
ice_servers?: Array<{
|
||
urls: string[];
|
||
username?: string;
|
||
credential?: string;
|
||
}>;
|
||
video_room_id?: number;
|
||
is_admin?: boolean;
|
||
lesson?: {
|
||
id: number;
|
||
title: string;
|
||
start_time: string;
|
||
end_time: string;
|
||
};
|
||
}
|
||
|
||
export interface LiveKitConfig {
|
||
server_url: string;
|
||
ice_servers?: Array<{
|
||
urls: string[];
|
||
username?: string;
|
||
credential?: string;
|
||
}>;
|
||
}
|
||
|
||
/**
|
||
* Создать LiveKit комнату для занятия
|
||
*/
|
||
export async function createLiveKitRoom(lessonId: number): Promise<LiveKitRoomResponse> {
|
||
const res = await apiClient.post<LiveKitRoomResponse>('/video/livekit/create-room/', {
|
||
lesson_id: lessonId,
|
||
});
|
||
return res.data;
|
||
}
|
||
|
||
/**
|
||
* Получить конфигурацию LiveKit
|
||
*/
|
||
export async function getLiveKitConfig(): Promise<LiveKitConfig> {
|
||
const res = await apiClient.get<LiveKitConfig>('/video/livekit/config/');
|
||
return res.data;
|
||
}
|