From 9d5790b2c735f6fefed9257cad9ab29bcfd3883f Mon Sep 17 00:00:00 2001 From: tgpethan Date: Wed, 2 Sep 2020 11:34:10 +0100 Subject: [PATCH] Disallow BinatoStream from creating duplicate streams --- README.md | 1 - server/Streams.js | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 98d50b0..837b5ac 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ An implementation of osu!bancho in Javascript ## Bugs: - If a client clicks the plus button in the chat window to join another channel the client will "crash", the game will keep running but the user will be unable to do anything - - BinatoStream can create duplicate streams ## How to connect: diff --git a/server/Streams.js b/server/Streams.js index 12aada5..e9d68af 100644 --- a/server/Streams.js +++ b/server/Streams.js @@ -6,6 +6,8 @@ module.exports = class { } addStream(streamName, removeIfEmpty, spectatorHostId = null) { + const streamNames = Object.keys(this.avaliableStreams); + if (streamNames.includes(streamName)) return global.consoleHelper.printBancho(`Did not add stream [${streamName}] A stream with the same name already exists`); // Add new stream to the list of streams this.avaliableStreams[streamName] = { streamUsers: [], // An array containing a list of user IDs of the users in a given stream