Skip to content

Commit

Permalink
fix: join stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis3797 committed Jul 4, 2024
1 parent 9aa3404 commit 684986e
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions apps/api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,21 @@ io.on("connection", (socket) => {
});
}

if (
!streams.get(streamId) &&
socket.data.user.id === checkStream.streamerId
) {
if (!streams.get(streamId)) {
// stream does not exist in memory and client is not host then return error
if (socket.data.user.id !== checkStream.streamerId) {
return callback({
success: false,
data: null,
error: [
{
name: "Stream Error",
code: -1,
msg: "There is something wrong."
}
]
});
}
// create stream
streams.set(streamId, {
id: checkStream.id,
Expand All @@ -292,18 +303,6 @@ io.on("connection", (socket) => {
});

logger.info(`Created stream: ${streamId}`);
} else {
return callback({
success: false,
data: null,
error: [
{
name: "Stream Error",
code: -1,
msg: "There is something wrong."
}
]
});
}

const stream = streams.get(streamId)!;
Expand Down

0 comments on commit 684986e

Please sign in to comment.