Skip to content

Commit

Permalink
fix: fixed leave stream when host leaves and users cant
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis3797 committed Jul 4, 2024
1 parent c9c8556 commit 08a69d6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,10 @@ io.on("connection", (socket) => {

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

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

delete socket.data.streamId;
} else {
const checkIfPresent = stream.viewers.find(
Expand Down Expand Up @@ -673,6 +676,10 @@ io.on("connection", (socket) => {

delete socket.data.streamId;

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

logger.info(
`User ${socket.data.user.username} leaved stream: ${streamId}`
);
Expand Down

0 comments on commit 08a69d6

Please sign in to comment.