victorious-nightfall-39949
02/24/2025, 5:50 AMgray-monkey-83525
02/24/2025, 5:50 AMvictorious-nightfall-39949
02/24/2025, 5:53 AMgray-monkey-83525
02/24/2025, 5:53 AMLIMIT_REACHED
.
Would you like more detailed information on how to manage or extend these limits?
Sources:
- LiveKit Quotas and Limits documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.victorious-nightfall-39949
02/24/2025, 6:35 AMgray-monkey-83525
02/24/2025, 6:35 AMRoomEvent.Disconnected
event in the LiveKit SDK. This event is triggered when a participant disconnects from the room. You can calculate the call duration by recording the time when the participant joins and subtracting it from the time when the Disconnected
event is fired.
Here's a basic example in JavaScript:
import { Room, RoomEvent } from 'livekit-client';
const room = new Room();
let startTime;
// Connect to the room
room.connect('ws://localhost:7800', token).then(() => {
startTime = Date.now();
console.log('Connected to room');
});
// Listen for the Disconnected event
room.on(RoomEvent.Disconnected, () => {
const endTime = Date.now();
const duration = (endTime - startTime) / 1000; // duration in seconds
console.log(`Call duration: ${duration} seconds`);
});
Would you like more detailed information or assistance with a different programming language?
Sources:
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1730726960.854159
- https://docs.livekit.io/home/server/webhooks/ 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.victorious-nightfall-39949
02/24/2025, 6:36 AMgray-monkey-83525
02/24/2025, 6:36 AMparticipant_connected
and participant_disconnected
events. Here's a Python example using the LiveKit SDK:
import asyncio
from datetime import datetime
from livekit import rtc
async def main():
room = rtc.Room()
start_time = None
# Listen for participant connected event
@room.on("participant_connected")
def on_participant_connected(participant):
nonlocal start_time
start_time = datetime.now()
print(f"Participant connected: {participant.identity}")
# Listen for participant disconnected event
@room.on("participant_disconnected")
def on_participant_disconnected(participant):
end_time = datetime.now()
duration = (end_time - start_time).total_seconds()
print(f"Participant disconnected: {participant.identity}")
print(f"Call duration: {duration} seconds")
# Connect to the room
await room.connect("ws://localhost:7880", "your_token")
# Keep the connection alive
try:
while True:
await asyncio.sleep(1)
except KeyboardInterrupt:
print("Disconnecting from room...")
await room.disconnect()
if __name__ == '__main__':
asyncio.run(main())
This script connects to a LiveKit room, records the start time when a participant connects, and calculates the call duration when the participant disconnects.
Would you like more detailed information or assistance with another aspect of LiveKit?
Sources:
- LiveKit Python SDK Documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.