rich-monitor-70665
02/24/2025, 5:35 PMgray-monkey-83525
02/24/2025, 5:35 PMlistRooms
and listParticipants
methods from the RoomServiceClient
class. Here's a brief overview:
1. List Active Rooms: Use the listRooms
method to get a list of active rooms. This method returns a list of rooms that are currently active.
2. Check Participants and Tracks: For each room, use the listParticipants
method to get the list of participants. You can then check if any participant has published tracks.
Here's a code snippet to illustrate this:
const { RoomServiceClient } = require('livekit-server-sdk');
const client = new RoomServiceClient('https://your.livekit.server', 'apiKey', 'secret');
async function checkRoomStatus() {
const rooms = await client.listRooms();
for (const room of rooms) {
const participants = await client.listParticipants(room.name);
const hasTracks = participants.some(participant => participant.tracks.length > 0);
console.log(`Room: ${room.name}, Active: ${participants.length > 0}, Has Tracks: ${hasTracks}`);
}
}
checkRoomStatus();
Would you like more details on any specific part of this process?
Sources:
- RoomServiceClient 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.