Skip to content

Commit

Permalink
remove autoEnd - lifecycle should be controlled by server
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzhao committed Apr 6, 2024
1 parent 62092ba commit 6dba77d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
2 changes: 1 addition & 1 deletion template-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@livekit/egress-sdk",
"version": "0.1.3",
"version": "0.2.0",
"description": "A lightweight SDK for developing RoomComposite templates",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
19 changes: 1 addition & 18 deletions template-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@

import { ParticipantEvent, Room, RoomEvent } from 'livekit-client';

export interface EgressOptions {
// automatically finish recording when the last participant leaves
autoEnd?: boolean;
}

const EgressHelper = {
/**
* RoomComposite will pass URL to your livekit's server instance.
Expand Down Expand Up @@ -62,17 +57,13 @@ const EgressHelper = {
* Call when successfully connected to the room
* @param room
*/
setRoom(room: Room, opts?: EgressOptions) {
setRoom(room: Room) {
if (currentRoom) {
currentRoom.off(RoomEvent.ParticipantDisconnected, onParticipantDisconnected);
currentRoom.off(RoomEvent.Disconnected, EgressHelper.endRecording);
}

currentRoom = room;
currentRoom.localParticipant.on(ParticipantEvent.ParticipantMetadataChanged, onMetadataChanged);
if (opts?.autoEnd) {
currentRoom.on(RoomEvent.ParticipantDisconnected, onParticipantDisconnected);
}
currentRoom.on(RoomEvent.Disconnected, EgressHelper.endRecording);
onMetadataChanged();
},
Expand Down Expand Up @@ -124,14 +115,6 @@ function onMetadataChanged() {
}
}

function onParticipantDisconnected() {
if (currentRoom) {
if (currentRoom.participants.size === 0) {
EgressHelper.endRecording();
}
}
}

function getURLParam(name: string): string | null {
const query = new URLSearchParams(window.location.search);
return query.get(name);
Expand Down

0 comments on commit 6dba77d

Please sign in to comment.