2024-12-12 15:42:09 +01:00
|
|
|
import { execCommandInBackground } from "./helper";
|
|
|
|
|
|
|
|
|
|
const LIVEKIT_URL = "ws://localhost:7880";
|
|
|
|
|
const LIVEKIT_API_KEY = "devkey";
|
|
|
|
|
const LIVEKIT_API_SECRET = "secret";
|
|
|
|
|
|
|
|
|
|
const LK_CLI = "lk";
|
|
|
|
|
|
|
|
|
|
export class Livekit {
|
2026-10-15 20:47:40 +02:00
|
|
|
/** Joins a participant that publishes the demo video and audio tracks; returns the pid of the CLI. */
|
2024-12-12 15:42:09 +01:00
|
|
|
static joinParticipantToRoom(participantIdentity: string, roomName: string): number {
|
|
|
|
|
const args = [
|
|
|
|
|
"room",
|
|
|
|
|
"join",
|
|
|
|
|
"--url",
|
|
|
|
|
LIVEKIT_URL,
|
|
|
|
|
"--api-key",
|
|
|
|
|
LIVEKIT_API_KEY,
|
|
|
|
|
"--api-secret",
|
|
|
|
|
LIVEKIT_API_SECRET,
|
|
|
|
|
"--publish-demo",
|
|
|
|
|
"--identity",
|
|
|
|
|
participantIdentity,
|
|
|
|
|
roomName
|
|
|
|
|
];
|
|
|
|
|
const pid = execCommandInBackground(LK_CLI, args);
|
|
|
|
|
if (!pid) {
|
|
|
|
|
throw new Error("Error joining participant to room");
|
|
|
|
|
}
|
|
|
|
|
return pid;
|
|
|
|
|
}
|
|
|
|
|
}
|