faint-gold-41196
05/13/2025, 12:53 PMtall-airline-16756
05/13/2025, 12:53 PMtall-airline-16756
05/13/2025, 12:54 PMimport asyncio
from livekit import api
import os
async def entrypoint(ctx: JobContext):
# do some work
# ...
# Wait for 5 seconds
await asyncio.sleep(5)
# Delete the room
api_client = api.LiveKitAPI(
os.getenv("LIVEKIT_URL"),
os.getenv("LIVEKIT_API_KEY"),
os.getenv("LIVEKIT_API_SECRET"),
)
await api_client.room.delete_room(api.DeleteRoomRequest(
room=ctx.job.room.name,
))
This code will execute your task, wait for 5 seconds, and then delete the room using the LiveKit server API. When the room is deleted, all participants will be disconnected, and the Disconnected
room event will be sent to all clients. The room will also be removed from the server.
Sources: Inside a session | LiveKit Docs | Inside a session | LiveKit Docs