creamy-judge-56458
05/12/2025, 6:27 PMtall-airline-16756
05/12/2025, 6:27 PMtall-airline-16756
05/12/2025, 6:27 PMRemoveParticipant
API in LiveKit, a Disconnected event is emitted. The reason for the disconnection in this case will be PARTICIPANT_REMOVED
.
You can listen for the Disconnected event and check the reason to handle this scenario in your application.
Sources: Connecting to LiveKit | LiveKit Docs | DisconnectReasoncreamy-judge-56458
05/12/2025, 6:31 PMtall-airline-16756
05/12/2025, 6:31 PMDeleteRoom
method from the RoomService API. This method terminates the room entirely and causes all participants to leave at once, ensuring the conversation is effectively hung up.
Here is an example implementation in Go:
import (
lksdk "<http://github.com/livekit/server-sdk-go/v2|github.com/livekit/server-sdk-go/v2>"
livekit "<http://github.com/livekit/protocol/livekit|github.com/livekit/protocol/livekit>"
)
func main() {
hostURL := "host-url" // ex: <https://project-123456.livekit.cloud>
apiKey := "api-key"
apiSecret := "api-secret"
roomId := "your-room-id"
roomClient := lksdk.NewRoomServiceClient(hostURL, apiKey, apiSecret)
// terminate a room and cause participants to leave
roomClient.DeleteRoom(context.Background(), &livekit.DeleteRoomRequest{
Room: roomId,
})
}
This approach is more efficient than removing participants one by one and ensures the room is properly closed.
Sources: lksdk package - github.com/livekit/server-sdk-go/v2 - Go Packages | lksdk package - github.com/livekit/server-sdk-go/v2 - Go Packages | lksdk package - github.com/livekit/server-sdk-go/v2 - Go Packages