diff --git a/index.js b/index.js index 86b60ad..11309c0 100644 --- a/index.js +++ b/index.js @@ -202,11 +202,19 @@ io.on("connection", (socket) => { if (room == null) { callack({ - status: false + status: false, + message: "No room for this code" }) return } + if (room.players.length >= 2) { + callack({ + status: false, + message: "Room is full" + }) + } + callack({ status: true }) diff --git a/public/scripts/app.js b/public/scripts/app.js index 485e2c4..eb432cb 100644 --- a/public/scripts/app.js +++ b/public/scripts/app.js @@ -177,9 +177,7 @@ function onJoinRoom() { socket.emit("ask for room", roomKey, socket.id, (response) => { if (response.status !== true) { - if (errorHolder.textContent == "") { - errorHolder.append("Error : Room Id don't exist") - } + errorHolder.textContent = "Error : " + response.message } else { loader.style.display = "none"; roomkeyHolder.innerHTML += `Your room key is : ` + roomId + ``;