Skip to content

Commit

Permalink
fix: leave_stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis3797 committed Jul 5, 2024
1 parent 4ce19e3 commit b8c3731
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,9 @@ io.on("connection", (socket) => {

io.in(streamId).socketsLeave(streamId);

if (stream.viewerCount === 0) {
const socketCount = await io.in(streamId).fetchSockets();

if (stream.viewerCount === 0 && socketCount.length === 0) {
streams.delete(streamId);
}

Expand Down Expand Up @@ -690,7 +692,9 @@ io.on("connection", (socket) => {

delete socket.data.streamId;

if (stream.viewerCount === 0) {
const socketCount = await io.in(streamId).fetchSockets();

if (stream.viewerCount === 0 && socketCount.length === 0) {
streams.delete(streamId);
}

Expand Down

0 comments on commit b8c3731

Please sign in to comment.