I'm trying to create a room limit for my application, and I want it to show up on the room list, but it says "Available Rooms." I tried the code below, and I thought that it would work. The room limit is supposed to be defined as how many users the user wants to join the room. I see the following output:
Join Room 6b3d03ab-507b-4186-9ab3-865468393a8f
dsaDSADs
Room Limit: undefined
Here's the code I've tried:below is room.js
'use strict';
// ... (rest of code) ...
module.exports = class Room {
// ... (rest of code) ...
getRoomLimit() { // method to get the room limit
return this.room_limit;
}
// ... (rest of code) ...
}
below is room list html
<html>
<head>
<title>JoinUrSpheres Rooms</title>
</head>
<body>
<h1>Available Rooms</h1>
<div id="room-list"></div>
<script>
// ... (rest of code) ...
</script>
</body>
</html>
Below is part of the form where room_limit is gathered on the form
<body onload="initClient()">
<!-- ... (rest of code) ... -->
<div class="input-box">
<input id="initInputRoomLimit" required type="number" name="room_limit" class="init-common" min="1" onkeyup="checkFields()" />
<label>Room Limit</label>
</div>
<!-- ... (rest of code) ... -->
</body>
Below is server.js room limit related code
// ... (rest of code) ...
const roomList = new Map();
app.get('/joinurspheres', (req, res) => {
// ... (rest of code) ...
});
app.post('/api/rooms', (req, res) => {
// ... (rest of code) ...
const roomLimit = req.body.room_limit; // use the same name as in the client-side HTML form
const room = {
description: description,
room_limit: parseInt(roomLimit), // Convert roomLimit to integer, notice the consistent lowercase here
// other properties...
};
// ... (rest of code) ...
});
// ... (rest of code) ...
below is more related server.js related to room limit
io.on('connection', (socket) => {
console.log('A user connected');
socket.on('createRoom', async ({ room_id, description, room_limit }, callback) => {
socket.room_id = room_id;
if (roomList.has(socket.room_id)) {
callback({ error: 'already exists' });
} else {
log.debug('Created room', { room_id: socket.room_id, description: description, room_limit: room_limit });
let worker = await getMediasoupWorker();
roomList.set(socket.room_id, new Room(socket.room_id, worker, io, description, room_limit));
callback({ room_id: socket.room_id });
}
});
Please let me know what the error is. My code is a lot more extensive; this is just the relevant code for the room_limit.