delightful-air-266
03/26/2025, 9:58 PMtall-airline-16756
03/26/2025, 9:58 PMtall-airline-16756
03/26/2025, 9:58 PMdelightful-air-266
03/26/2025, 9:58 PMtall-airline-16756
03/26/2025, 9:59 PMdeleteRoom
method. This will terminate the session for everyone in the room. Here's an example in Python:
from livekit import api
async def entrypoint(ctx: JobContext):
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,
))
When you call the deleteRoom
method, a Disconnected
room event will be sent to all participants, and the room will be completely removed from the server. Let me know if you need further assistance!
Sources: Inside a session | LiveKit Docsdelightful-air-266
03/26/2025, 9:59 PMtall-airline-16756
03/26/2025, 9:59 PMdeleteRoom
. If you want to enable this functionality from the front-end, you might need to implement a server-side endpoint that the front-end can call to trigger the deleteRoom
API. Let me know if you need further guidance on this!delightful-air-266
03/26/2025, 10:00 PMtall-airline-16756
03/26/2025, 10:00 PMdeleteRoom
method. For example, in Node.js, you could create an API route that accepts a room name and calls the deleteRoom
function.
2. Front-End: Create a button or action that sends a request to this server endpoint. For example, using JavaScript:
3. Security: Ensure that only authorized users can trigger this action by implementing proper authentication and authorization checks on the server-side endpoint.
Let me know if you need further assistance with the implementation!delightful-air-266
03/26/2025, 10:01 PMtall-airline-16756
03/26/2025, 10:01 PMconst express = require('express');
const bodyParser = require('body-parser');
const { AccessToken } = require('livekit-server-sdk');
const app = express();
const port = 3000;
// Replace these with your LiveKit server details
const LIVEKIT_URL = 'your_livekit_url';
const API_KEY = 'your_api_key';
const API_SECRET = 'your_api_secret';
app.use(bodyParser.json());
// Endpoint to end the call for all participants
<http://app.post|app.post>('/end-call', async (req, res) => {
const { roomName } = req.body;
if (!roomName) {
return res.status(400).send('Room name is required');
}
try {
const livekitServer = new AccessToken(LIVEKIT_URL, API_KEY, API_SECRET);
await livekitServer.deleteRoom(roomName);
res.status(200).send('Room ended successfully');
} catch (error) {
console.error('Error ending room:', error);
res.status(500).send('Failed to end room');
}
});
app.listen(port, () => {
console.log(`Server is running on <http://localhost:${port}`>);
});
Make sure to replace your_livekit_url
, your_api_key
, and your_api_secret
with your actual LiveKit server details. This code sets up an Express server with an endpoint /end-call
that accepts a POST request with the room name to end the call for all participants.
Let me know if you need further clarification or assistance!